mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 01:42:32 +01:00
Compare commits
249 Commits
tridentsxb
...
pr/4925
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a71ef5fc2 | ||
|
|
38e0810f93 | ||
|
|
34fefc1e70 | ||
|
|
7f64987585 | ||
|
|
0603faff33 | ||
|
|
dc8a9102fe | ||
|
|
247d1732e2 | ||
|
|
140cd61fd6 | ||
|
|
4a2020d4af | ||
|
|
7f756c25ab | ||
|
|
715f7217f9 | ||
|
|
760e610226 | ||
|
|
e23e8d3884 | ||
|
|
a7762cd015 | ||
|
|
1781a996b9 | ||
|
|
2cc24db615 | ||
|
|
7e86701119 | ||
|
|
24a57fab3d | ||
|
|
78596dc00e | ||
|
|
0b1b753d4c | ||
|
|
3cbdcddcc1 | ||
|
|
25ecb6e1de | ||
|
|
019d22d92a | ||
|
|
e39022cc64 | ||
|
|
a41106ee30 | ||
|
|
b2110d4e1c | ||
|
|
f22043ebb5 | ||
|
|
cc1b511c02 | ||
|
|
e9a020565f | ||
|
|
44ab8d93ab | ||
|
|
78922ea337 | ||
|
|
db01b61371 | ||
|
|
133a60c4bf | ||
|
|
684e96ff6b | ||
|
|
f40f68bdf0 | ||
|
|
640f4b0a9b | ||
|
|
978ee4a9a3 | ||
|
|
0ab93586fd | ||
|
|
921a0228db | ||
|
|
ac68c4ebe6 | ||
|
|
4553310bb9 | ||
|
|
9b0632d63c | ||
|
|
69ef484b86 | ||
|
|
606a92f1ef | ||
|
|
79730383ab | ||
|
|
7264e1a8d6 | ||
|
|
e011f545a7 | ||
|
|
283fa14380 | ||
|
|
5f388a9906 | ||
|
|
cd96bc79d8 | ||
|
|
ae961caeab | ||
|
|
0b4d87aebc | ||
|
|
6106f70c24 | ||
|
|
100a7f8a8f | ||
|
|
4c792c4f2c | ||
|
|
db4b820f80 | ||
|
|
ca710b4302 | ||
|
|
668cc0e4a3 | ||
|
|
6d0542b524 | ||
|
|
d84a5b37b7 | ||
|
|
c072ae4990 | ||
|
|
2d78eaa495 | ||
|
|
6bdc51be76 | ||
|
|
af15617196 | ||
|
|
643dff7915 | ||
|
|
01fbfccc0d | ||
|
|
2362fe994a | ||
|
|
08b08b1285 | ||
|
|
965540dfaf | ||
|
|
75822472fc | ||
|
|
59aecb79a1 | ||
|
|
c865c2d2e3 | ||
|
|
93c64a8770 | ||
|
|
30ac82181e | ||
|
|
2b219f48ec | ||
|
|
fed0483d40 | ||
|
|
101c43a4bc | ||
|
|
fb738d85f6 | ||
|
|
032a407c8a | ||
|
|
33e615f0f1 | ||
|
|
8feba60e2c | ||
|
|
8a4fe8ae5d | ||
|
|
45f96793a5 | ||
|
|
df0362bcba | ||
|
|
25d558a5fa | ||
|
|
c0e4d7a43d | ||
|
|
993b418fbc | ||
|
|
9cf856221d | ||
|
|
4db6e03517 | ||
|
|
eb1393c02c | ||
|
|
e1a54b72a9 | ||
|
|
b266c7ce5b | ||
|
|
38f937fa01 | ||
|
|
6d7982c0cf | ||
|
|
89fa26d0eb | ||
|
|
edd85c2f19 | ||
|
|
88b6517f88 | ||
|
|
2c09a0fdb6 | ||
|
|
90721ee859 | ||
|
|
aa4011a226 | ||
|
|
fa82fe8e67 | ||
|
|
444e1532f2 | ||
|
|
1a34d2f647 | ||
|
|
d543843235 | ||
|
|
c40af913f4 | ||
|
|
f6268fe291 | ||
|
|
27854720f0 | ||
|
|
d19cf1e260 | ||
|
|
4a8630262e | ||
|
|
c41d2d1f39 | ||
|
|
8821fb0b2f | ||
|
|
5ab55c1653 | ||
|
|
8066f7f7f2 | ||
|
|
5ea18e8ba7 | ||
|
|
0bf3f98d95 | ||
|
|
fa33fa3d32 | ||
|
|
8b6a4c1e5b | ||
|
|
0ccd89fad4 | ||
|
|
16e90da8fd | ||
|
|
86e7bfbf89 | ||
|
|
8f0fb76847 | ||
|
|
3be15d3f65 | ||
|
|
74ced18bd0 | ||
|
|
2e0a371ed8 | ||
|
|
68ffe31246 | ||
|
|
405de477d3 | ||
|
|
db0ae36fa7 | ||
|
|
5d2028b5dc | ||
|
|
3e645a022d | ||
|
|
c21a040ddb | ||
|
|
dd4a5a6b9a | ||
|
|
d5ce8fc6ff | ||
|
|
829aaea5d4 | ||
|
|
c92ae16c7f | ||
|
|
40160498ca | ||
|
|
9d08d88f2a | ||
|
|
2ca3544741 | ||
|
|
ef714f98c9 | ||
|
|
dd550feb65 | ||
|
|
ddc9a69f4b | ||
|
|
61388f46f1 | ||
|
|
341dc45202 | ||
|
|
13f7482b39 | ||
|
|
a78dcffde7 | ||
|
|
3671d0b565 | ||
|
|
1b11fd2369 | ||
|
|
c36ff85cbf | ||
|
|
77cefbdfab | ||
|
|
fbe0cd1471 | ||
|
|
728ba512c3 | ||
|
|
10470dde13 | ||
|
|
11245e87ef | ||
|
|
b88d752f61 | ||
|
|
09ce259288 | ||
|
|
519d469cb2 | ||
|
|
cf67e3502a | ||
|
|
9ab4584dfe | ||
|
|
8d27e8fccf | ||
|
|
ba1f15b655 | ||
|
|
5b1a69b3f7 | ||
|
|
d185c7538c | ||
|
|
2347fc294f | ||
|
|
7aaec5b707 | ||
|
|
20a713e04d | ||
|
|
81faf93f31 | ||
|
|
19c0f6757e | ||
|
|
ec0815043e | ||
|
|
182717eacf | ||
|
|
e287ad47d1 | ||
|
|
8eee39b88b | ||
|
|
4bf2ad46ea | ||
|
|
def676d8d7 | ||
|
|
f8433cdbcc | ||
|
|
a2e10dbd0c | ||
|
|
e55ce00d62 | ||
|
|
73c465ee64 | ||
|
|
c30892a0a5 | ||
|
|
58e7323c3e | ||
|
|
7fc6577196 | ||
|
|
162c605dac | ||
|
|
280eb0ba51 | ||
|
|
8e5251ba66 | ||
|
|
1e43e34547 | ||
|
|
5575309b79 | ||
|
|
88dae5d5dd | ||
|
|
da3909c08f | ||
|
|
6cad4993ed | ||
|
|
af6e6b9545 | ||
|
|
cd937a812d | ||
|
|
264c0e2c78 | ||
|
|
b42278932e | ||
|
|
7fc7125ed3 | ||
|
|
d3f012de27 | ||
|
|
dfa16c70a7 | ||
|
|
8805a25d85 | ||
|
|
f91a2217c8 | ||
|
|
64f1ae4af6 | ||
|
|
6d9a9d165d | ||
|
|
5edc0d065d | ||
|
|
a346fc3338 | ||
|
|
dc94fedee1 | ||
|
|
93a6a73b4e | ||
|
|
2c849d9cb4 | ||
|
|
b79d452a6d | ||
|
|
fb94374e3c | ||
|
|
5255ae846d | ||
|
|
e816310da8 | ||
|
|
de6ba4fb6a | ||
|
|
e35bfe758c | ||
|
|
fffbacd239 | ||
|
|
f286af3fff | ||
|
|
7e28799f94 | ||
|
|
78dc56d263 | ||
|
|
e3dfdfc6ee | ||
|
|
4819a45be9 | ||
|
|
5e0f8a334d | ||
|
|
5f0cc2b09a | ||
|
|
6ff37c8baa | ||
|
|
f7dc72359b | ||
|
|
1ab5b82b22 | ||
|
|
28c6c90f23 | ||
|
|
9bb38e3193 | ||
|
|
551fac84a5 | ||
|
|
0bc25b263b | ||
|
|
fa9a3ae766 | ||
|
|
33df92ea3a | ||
|
|
c3d86ba6c5 | ||
|
|
b569b9456e | ||
|
|
4e6e58d9ca | ||
|
|
619eec7667 | ||
|
|
97cfb1cfc7 | ||
|
|
c28c8d164a | ||
|
|
e74e1e6829 | ||
|
|
6dbc7adf48 | ||
|
|
cbaef4a092 | ||
|
|
eb10bcbc96 | ||
|
|
2875545fa4 | ||
|
|
be595f2568 | ||
|
|
882f6197c6 | ||
|
|
0d2f370185 | ||
|
|
da1fcfe30a | ||
|
|
f983f95961 | ||
|
|
d67c561fed | ||
|
|
989f7fd51b | ||
|
|
e4b8b74987 | ||
|
|
9e7bb12dc3 | ||
|
|
95c291d630 | ||
|
|
9b4070d971 | ||
|
|
6d0fe4fb58 |
11
.github/workflows/maven.yml
vendored
11
.github/workflows/maven.yml
vendored
@@ -31,12 +31,13 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# 2. Setup Java 1.8 JDK
|
||||
- name: Java 1.8 setup
|
||||
uses: actions/setup-java@v1.4.3
|
||||
# 2. Setup Java 17 JDK (Adopt)
|
||||
- name: Java 17 setup
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-package: jdk
|
||||
java-version: 1.8
|
||||
java-version: '17'
|
||||
|
||||
# 3. Setup local Maven package cache to speed up building
|
||||
- name: Cache Maven packages
|
||||
@@ -48,4 +49,4 @@ jobs:
|
||||
|
||||
# 4. Build via Maven
|
||||
- name: Build via Maven
|
||||
run: mvn verify -B --file pom.xml
|
||||
run: mvn verify -B --file pom.xml -DdisableXmlReport=true
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -55,3 +55,4 @@
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
||||
/nulllocale_override.properties
|
||||
|
||||
389
Changelog.txt
389
Changelog.txt
@@ -1,8 +1,393 @@
|
||||
Version 2.1.196
|
||||
Crossbows can now be fished up with enchantments
|
||||
Version 2.1.222
|
||||
Fixed dupe exploit
|
||||
Glow Lichen default XP changed from 200 to 5
|
||||
A lot of mcMMO logging was moved from INFO to DEBUG, this should reduce the amount of noise in your logs and console
|
||||
|
||||
NOTES: If you want to see all logging messages, modify config.yml and set General.Verbose_Logging to true
|
||||
You will have to adjust experience.yml to get the balance changes, or delete it to generate a new one
|
||||
Version 2.1.221
|
||||
PAPI Support is now built into mcMMO and loads when mcMMO loads (as long as you have PAPI running)
|
||||
Fixed blast mining bonus drops not working (Thanks warriiorrrr)
|
||||
Added fail safes to prevent bonus drops metadata from lingering on blocks
|
||||
|
||||
NOTES: Placeholders were brought in from electroniccat's original work on a PAPI expansion for mcMMO, the placeholders are the same as a result
|
||||
I will be adding a leaderboard placeholder in the next patch (most likely). Feel free to share details of what functionality you'd want from additional placeholders on discord.
|
||||
Version 2.1.220
|
||||
(API) Added TreeFellerBlockBreakEvent class which extends FakeBlockBreakEvent (see notes), this is sent out during Tree Feller processing to allow other plugins to differentiate between Tree Feller and other fake block break events
|
||||
Config files update automatically again
|
||||
Default configs are now copied to plugins/mcMMO/defaults for easy reference
|
||||
Fixed child skills counting towards power level in /inspect (Thanks Wariorrrr)
|
||||
|
||||
NOTES: For a while configs were not updating automatically as a rewrite of how config files were loaded was partially done, this is now complete and configs will update automatically again.
|
||||
Fake block break events have been sent out historically by mcMMO to check other plugins for a players permission to break or place a block, Tree Feller will now specify via inheritance its own event type for this so mcMMO plugins can handle Tree Feller fake block break events differently if they so choose.
|
||||
You can now view the default configs more easily as they are now copied to plugins/mcMMO/defaults, these configs will be overwritten on start up to match the default values of the config in the JAR
|
||||
Version 2.1.219
|
||||
Fixed Fishing exploit protection being triggered inappropriately by other plugins (Thanks smudgge)
|
||||
Fixed wiki url being incorrect in commands
|
||||
Party loading is more resilient (Thanks Wariorrrr)
|
||||
Fixed periods not being replaced whe nrenaming party (Thanks Wariorrrr)
|
||||
Fixed Party Teleport NPE (Thanks Wariorrrr)
|
||||
Added support for various new things from Minecraft 1.20
|
||||
Fixed double drop issue with Beetroots
|
||||
Added 'Camel' to taming experience in experience.yml
|
||||
Added 'Sniffer' to taming experience in experience.yml
|
||||
Added 'Snifflet' to taming experience in experience.yml
|
||||
Added 'Pitcher_Plant' to bonus drops in config.yml
|
||||
Added 'Torchflower' to bonus drops in config.yml
|
||||
Added 'Pink_Petals' to bonus drops in config.yml
|
||||
Added 'Cherry_Log' to bonus drops in config.yml
|
||||
Added 'Cherry_Wood' to bonus drops in config.yml
|
||||
Added 'Camel' to combat experience in experience.yml
|
||||
Added 'Sniffer' to combat experience in experience.yml
|
||||
Added 'Snifflet' to combat experience in experience.yml
|
||||
Added 'Torchflower' to herbalism experience in experience.yml
|
||||
Added 'Pitcher_Plant' to herbalism experience in experience.yml
|
||||
Added 'Pink_Petals' to herbalism experience in experience.yml
|
||||
Added 'Cherry_Log' to woodcutting experience in experience.yml
|
||||
Added 'Cherry_Wood' to woodcutting experience in experience.yml
|
||||
Added 'Stripped_Cherry_Log' to woodcutting experience in experience.yml
|
||||
Added 'Stripped_Cherry_Wood' to woodcutting experience in experience.yml
|
||||
Added 'Skills.Mining.BlastMining.Bonus_Drops.Enabled' to advanced.yml to enable/disable bonus drops from Blast Mining
|
||||
NOTE: There are plans to add experience and potentially subskills for discovering items via the new brushing mechanic, but this will have to wait for new Spigot API to become available
|
||||
|
||||
Version 2.1.218
|
||||
Fixed locale pt_BR type (thanks MrPowerGamerBR)
|
||||
Updated Russian Locale (thanks imDaniX)
|
||||
Harvest Lumber checks main hand enchantments when delivering bonuses (thanks destro174)
|
||||
Fixed bug where players could use inspect to determine if vanished players were online (thanks DarkKnights22)
|
||||
|
||||
Version 2.1.217
|
||||
Tree Feller will now break blocks within the limit instead of refusing to fell the entire tree (partial big tree destruction)
|
||||
Mangrove trees resulting from growth are now marked as natural (existing trees marked unnatural before this update will not be retroactively fixed)
|
||||
Fixed a bug removing comments from configs (see notes)
|
||||
Fixed mouse-hover tooltip windows (thanks Greymagic27)
|
||||
|
||||
NOTES:
|
||||
Regarding the secure chat feature Minecraft rolled out, once APIs have updated I will look into rolling support for that into admin/party chat.
|
||||
Comments should no longer get removed from config but I haven't added any code to add missing comments back in, for now if you want comments you can delete the config file to regenerate it (sorry for the inconvenience)
|
||||
|
||||
Version 2.1.216
|
||||
Reverted Unarmed changes from 2.1.215 (fixes block breaker/beserk active at all time for all players)
|
||||
Added Sculk_* blocks to Mining XP
|
||||
You can use Hoe(s) to gain mining XP, Hoe(s) won't benefit from Super Breaker nor will they activate it (see notes)
|
||||
|
||||
NOTES:
|
||||
Hoe's being able to gain Mining XP is primarily for Sculk blocks which have Hoe as the fastest tool yet to me feel like Mining blocks, let me know what you think
|
||||
The Sculk blocks don't quite fit perfectly as mining-related, especially since hoes are the fastest tool to use for them. Let me know what you think.
|
||||
Version 2.1.215
|
||||
Fixed Coal Blocks and potentially other fuel sources not showing burning animation to players (see notes)
|
||||
Level up broadcasts from level milestones will now be visible to the player who achieved them
|
||||
Fixed a bug where hovering over skill descriptions did not display anything (thanks Greymagic27)
|
||||
Added Dripstone to experience.yml (thanks Greymagic27)
|
||||
Added Mangrove_Log to experience.yml (should fix behavior for tree-feller etc)
|
||||
Item in main hand is now used for Tree Feller drops (thanks destro174)
|
||||
|
||||
NOTES:
|
||||
The burning animation bug is actually in Spigot, it takes an int for setBurnTime when it really should only take a short as the game is expecting a short value, I implemented a hacky workaround via Math.min
|
||||
There is a bug where you may lose your config comments, this will be complex to solve, for now you can check our GitHub for the configs with comments.
|
||||
|
||||
Version 2.1.214
|
||||
Temporarily removed FakePlayerAnimationEvent (see notes)
|
||||
Players can now see their own level up broadcasts
|
||||
|
||||
NOTES:
|
||||
Spigot updated PlayerAnimationEvent with an API break between versions 1.18 and 1.19, as a temporary fix for mcMMO to be able to support both of these
|
||||
Minecraft versions I have temporarily removed FakePlayerAnimationEvent. I am working on a fix to dynamically use the correct API depending on the version of MC
|
||||
as many people will likely be stuck on 1.18 for a while.
|
||||
FakePlayerAnimationEvent existed to circumvent false positives on anti-cheat plugins such as NoCheat, however
|
||||
I am unsure if it is still needed and removing it may have no ill effects.. however I cannot be certain.
|
||||
Anti-cheat plugin authors should be informed to update if you run into false positives with mcMMO after this update so they can make the appropriate changes.
|
||||
Version 2.1.213
|
||||
Updated various mechanics to recognize and understand the new blocks
|
||||
Added 'Packed_Mud' to mining xp
|
||||
Added 'Mud_Bricks' to mining xp
|
||||
Added 'Reinforced_Deepslate' to mining xp
|
||||
Added 'Mud' to excavation xp
|
||||
Added 'Muddy Mangrove Roots' to excavation xp
|
||||
Added 'Mangrove_Roots' to woodcutting xp
|
||||
Added 'Stripped_Mangrove_Log' to woodcutting xp
|
||||
Added 'Stripped_Crimson_Stem' to woodcutting xp
|
||||
Added 'Stripped_Warped_Stem' to woodcutting xp
|
||||
Added 'Allay' to combat experience
|
||||
Added 'Frog' to combat experience and taming experience
|
||||
Added 'Tadpole' to combat experience
|
||||
Added 'Warden' to combat experience
|
||||
|
||||
Changes to excavation treasures (requires manual editing or regenerating the config)
|
||||
Added Mud as a block which can drop various treasures (see notes)
|
||||
Added Muddy_Mangrove_Roots as a block which can drop various treasures (see notes)
|
||||
Added Stick as a new excavation drop, which drops from mud and muddy mangrove roots (see notes)
|
||||
Added Potato as a new excavation drop, which drops from mud and dirt (see notes)
|
||||
Added Feather as a new excavation drop, which drops from mud (see notes)
|
||||
Added Spyglass as a new excavation drop, which drops rarely from mud and dirt (see notes)
|
||||
Added Trident as a new excavation drop, which drops somewhat rarely from mud, muddy mangrove roots, and clay (see notes)
|
||||
Added Heart of the Sea as a new excavation drop, which drops very rarely from mud and requires a very high excavation level to appear
|
||||
|
||||
NOTES:
|
||||
To get the new excavation drop list, the easiest way is to delete treasures.yml and mcMMO will regenerate it with the newest version
|
||||
I'll likely be tweaking the treasures list in the near future, leave feedback on discord if you have suggestions
|
||||
|
||||
Version 2.1.212
|
||||
An herbalism exploit has been patched (thanks WhatsTheBadNews)
|
||||
Added 'ExploitFix.Combat.XPCeiling.Enabled' to experience.yml
|
||||
Added 'ExploitFix.Combat.XPCeiling.Damage_Limit' to experience.yml
|
||||
Single instances of combat damage above 100 give are capped to give the same reward as 100 by default (100 is a lot, but you can change this in settings)
|
||||
|
||||
NOTES: The damage ceiling won't affect server that don't have mobs running around with abnormally high health, if your server does you'll want to adjust this limit or disable it.
|
||||
Version 2.1.211
|
||||
Added /mmodebug info for players hitting other players
|
||||
Fixed Immortal Player bug
|
||||
Removed all of Spigot's buggy and deprecated DamageModifier API, this fixes the bug where players would become immortal when using certain other plugins
|
||||
Rupture is back to doing "pure" damage (due to the above change)
|
||||
|
||||
NOTES:
|
||||
Rupture damage will be tweaked based on feedback as it is dealing "pure" damage
|
||||
Version 2.1.210
|
||||
Fixed a memory leak involving mob metadata
|
||||
Fixed a potential null pointer exception in InventoryListener
|
||||
|
||||
NOTES:
|
||||
If you're having issues with "immortal players" this is a known plugin incompatibility between mcMMO and another plugin, I need more info on what plugins need to be present to cause it. Please post info to GitHub issues or tag me on discord.
|
||||
There was a big rewrite in this update relating to how various types of metadata were being tracked/stored/retrieved
|
||||
If you run into issues with this version of mcMMO, please post about it on GitHub
|
||||
|
||||
Version 2.1.209
|
||||
Fixed a bug where some config files did not get trimmed completely
|
||||
|
||||
NOTES:
|
||||
This should fix the issue for everyone, let me know if you still run into trouble!
|
||||
Don't be afraid to ping me on discord
|
||||
|
||||
Version 2.1.208
|
||||
Significantly rewrote to how mcMMO loads/updates config files
|
||||
Fixed a bug where huge config files caused the server to take forever to start/shutdown
|
||||
Fixed config files duplicating comments and updated their code to use Spigot API (thanks the456gamer)
|
||||
mcMMO now repairs config files (removing duplicate comments, see notes)
|
||||
Updated lithuanian locale (thanks dexasz)
|
||||
|
||||
NOTES:
|
||||
Due to a change in Spigot mcMMO started growing config files at an alarming rate until they became so big they wouldn't load, and well before they got to that stage they slowed down loading the server
|
||||
mcMMO now uses the Spigot API in a smarter way for config files
|
||||
|
||||
Version 2.1.207
|
||||
Fixed an IndexOutOfBounds exception with our BlockTracker
|
||||
Fixed a bug where leveling up a party at level cap would spam the chat with messages
|
||||
mcMMO will no longer use enchanted repair materials (thanks JeBobs)
|
||||
Added an option to allow enchanted repair materials 'Skills.Repair.Use_Enchanted_Materials' in config.yml
|
||||
Temporarily rolling required Java version back to 16
|
||||
Added unicode (UTF-8) support to locale files (no more UTF-16 codes needed)
|
||||
Added locale key 'Scoreboard.Disabled' to en_US
|
||||
Added locale key 'Scoreboard.NotSetupYet' to en_US
|
||||
Fixed a bug where Salvage sent messages even though the event was cancelled (Thanks TheBusyBiscuit)
|
||||
|
||||
Version 2.1.206
|
||||
Fixed a memory leak involving Herbalism under specific circumstances
|
||||
Fixed a memory leak involving Rupture under specific circumstances
|
||||
Fixed a memory leak involving Dodge
|
||||
Fixed a memory leak involving Endermen and block pickups
|
||||
Fixed a memory leak from plugin conflicts when double drops get activated
|
||||
Fixed a memory leak that required a specific config.yml setup with mob health bars
|
||||
You can no longer set mob health bars to -1 in config.yml to set it to display permanently (this was problematic behavior)
|
||||
Fixed a bug preventing Action Bar messages from showing
|
||||
Fixed a bug where Alchemy XP wasn't being granted
|
||||
Lowered the default volume of level up from .75 to .3 in sounds.yml (delete sounds.yml to get this change automagically)
|
||||
Updated adventure platform dependency
|
||||
Updated to use Java 17
|
||||
|
||||
NOTES:
|
||||
mcMMO will target the newest version of MC moving forward, any backwards compatibility with prior versions of Minecraft should be considered a side effect rather than intended.
|
||||
|
||||
Version 2.1.205
|
||||
Fixed yet another exception preventing Alchemy from working (thanks NemuruYama)
|
||||
Added some code to cleanup potential memory leaks
|
||||
|
||||
NOTES:
|
||||
Sorry for the delay in this patch, I have had a terrible cold all weekend, feeling better now
|
||||
|
||||
Version 2.1.204
|
||||
Fixed IndexOutOfBounds exception (thanks gecko10000) (related to Alchemy)
|
||||
Added double smelt to copper ingot and netherite scrap (thanks Lyther)
|
||||
|
||||
Version 2.1.203
|
||||
mcMMO now requires Java 16
|
||||
mcMMO now requires the newest version of Minecraft (currently 1.17.1)
|
||||
Fixed several API breaks (mostly affected Alchemy)
|
||||
Fixed a bug relating to Shake percentages (thanks Lyther)
|
||||
Fixed hexcolors not displaying correctly in level up milestone broadcasts (thanks gecko10000)
|
||||
(API) Added deprecated constructors for PlayerProfile (thanks PikaMug)
|
||||
mcMMO has had many of its dependencies updated to newer builds
|
||||
|
||||
NOTES:
|
||||
If you want to play mcMMO on older versions, simply use 2.1.202 instead
|
||||
Keeping mcMMO backwards compatible with older versions is getting messy, and I'd rather be able to focus my attention at newer features than having to make an elaborate build process (or alternatively hacky code) to support older versions of the game
|
||||
Furthermore, it seems most people are playing 1.17.1 by a wide margin
|
||||
You may have trouble compiling the source code if your maven is not setup to run JDK16, if you get any errors when compiling this is likely the reason
|
||||
|
||||
The data from bstats went into making this decision (shoutout to Qixils for typing this up too)
|
||||
71.9% of servers are running 1.17.X
|
||||
97.9% of servers are running ≥1.16
|
||||
99.3% of servers are running ≥1.15
|
||||
|
||||
Version 2.1.202
|
||||
Fixed a bug where mcMMO didn't reward XP for Kelp
|
||||
Fixed a bug where mcMMO marked bonemealed Azalea trees as unnatural (and thus did not give XP or get affected by Tree Feller)
|
||||
Added Amethyst_Block to experience.yml for Mining
|
||||
Added Flowering Azalea Leaves to Tree Feller's white list
|
||||
Fixed a bug where mcMMO didn't appropriately flag blocks as natural in some tree growing events
|
||||
(SQL) Added more MySQL/MariaDB settings (allowPublicKeyRetrieval - thanks rosaage)
|
||||
(API) Added CREATED_PARTY and DISBANDED_PARTY to EventReason (used in some party events - thanks PikaMug )
|
||||
Party member name matching is no longer case sensitive (thanks Wariorrrr)
|
||||
Updated zh_CN locale (thanks GhostDC)
|
||||
Added some settings for over fishing (Settings are in experience.yml under Fishing_ExploitFix_Options - thanks tunagohan)
|
||||
|
||||
NOTES:
|
||||
This means tree feller will correctly traverse flowering azalea leaves during its ability
|
||||
|
||||
Version 2.1.201
|
||||
Tweaked the visual/audio effect for Rupture
|
||||
(API) TNT is set as the source in Blast Mining (1.16.1 and up)
|
||||
Fixed an exploit related to Ability Buffs remaining on tools
|
||||
Blast Mining no longer drops Budding Amethyst since its not legal to obtain this item through normal gameplay
|
||||
Added mcinspect and mmoinspect aliases to inspect command
|
||||
Portuguese translation of Woodcutting changed back to Lenhador
|
||||
Updated zh_CN (Chinese) locale, thanks GhostDC!
|
||||
Major changes to zh_TW locale, thanks gregman98
|
||||
Added '/skill keep' shortcut (for example /mining keep) thanks GriffinCodes
|
||||
Impact is now more balanced as the formula has been changed (see notes) thanks emanondev
|
||||
|
||||
NOTES:
|
||||
Impact will deal less durability damage to armors without unbreaking, and more to armors with unbreaking
|
||||
|
||||
Version 2.1.200
|
||||
Fixed a major 1.17 exploit
|
||||
Dodge will no longer trigger while blocking
|
||||
Action Bar messages can now be disabled (thanks TheBusyBiscuit)
|
||||
mcMMO is better at MC version parsing now (thanks stepech & TheBusyBiscuit)
|
||||
|
||||
Version 2.1.199
|
||||
Fixed IndexOutOfBounds error for servers running 1.17 or higher
|
||||
Fixed a bug that caused MySQL/MariaDB to malfunction for 1.17 (see notes)
|
||||
Renamed Deepslate Lapis Lazuli Ore to Deepslate Lapis Ore in experience.yml and config.yml
|
||||
Added some code to prevent mcMMO from breaking if it doesn't recognize the version of the game
|
||||
Optimized CompatibilitySupportLayer - this handles some of the logic for supporting multiple versions of the game
|
||||
Added Unit Tests for MinecraftGameVersion
|
||||
|
||||
NOTES:
|
||||
I have temporarily disabled SSL for MySQL/MariaDB for 1.17 ( proper fix coming soon )
|
||||
|
||||
Version 2.1.198
|
||||
Fixed a bug where Smelting didn't work with the new 1.17 materials
|
||||
Updated dependency Adventure to 4.8.0 (thanks TheBusyBiscuit)
|
||||
|
||||
Version 2.1.197
|
||||
This update adds compatibility for new mobs and blocks from 1.17
|
||||
This build of mcMMO should be more compatible with certain versions of ViaVersion
|
||||
Players are no longer launched from Minecarts when using a Fishing Rod (they are still dismounted) thanks lexikiq
|
||||
Updated Japanese locale (thanks ViaSnake)
|
||||
Updated Brazil Portuguese (pt_BR) locale (thanks Paulo Guilherme)
|
||||
Added Goat to experience.yml for combat and taming
|
||||
Added Axolotl to experience.yml for combat and taming
|
||||
Added Glow_Squid to experience.yml for combat and taming
|
||||
Added Glow Berries to Farmer's Diet
|
||||
Updated Super Breaker to recognize the new pick-axe appropriate blocks
|
||||
Updated Tree Feller to recognize Azalea Leaves
|
||||
|
||||
Added Rooted Dirt to experience.yml for Excavation
|
||||
Added Small Dripleaf to experience.yml for Herbalism
|
||||
Added Big Dripleaf to experience.yml for Herbalism
|
||||
Added Moss Block to experience.yml for Herbalism
|
||||
Added Cave Vines to experience.yml for Herbalism
|
||||
Added Cave Vines Plant to experience.yml for Herbalism
|
||||
Added Glow Lichen to experience.yml for Herbalism
|
||||
Added Tuff to experience.yml for Mining
|
||||
Added Calcite to experience.yml for Mining
|
||||
Added Smooth Basalt to experience.yml for Mining
|
||||
Added Block_Of_Amethyst to experience.yml for Mining
|
||||
Added Budding Amethyst to experience.yml for Mining
|
||||
Added Small_Amethyst_Bud to experience.yml for Mining
|
||||
Added Medium Amethyst Bud to experience.yml for Mining
|
||||
Added Large Amethyst Bud to experience.yml for Mining
|
||||
Added Amethyst Cluster to experience.yml for Mining
|
||||
Added Deepslate to experience.yml for Mining
|
||||
Added Cobbled Deepslate to experience.yml for Mining
|
||||
Added Copper Ore to experience.yml for Mining
|
||||
Added Deepslate Redstone Ore to experience.yml for Mining
|
||||
Added Deepslate Copper Ore to experience.yml for Mining
|
||||
Added Deepslate Coal Ore to experience.yml for Mining
|
||||
Added Deepslate Diamond Ore to experience.yml for Mining
|
||||
Added Deepslate Emerald Ore to experience.yml for Mining
|
||||
Added Deepslate Iron Ore to experience.yml for Mining
|
||||
Added Deepslate Gold Ore to experience.yml for Mining
|
||||
Added Deepslate Lapis Lazuli Ore to experience.yml for Mining
|
||||
Added Lapis Lazuli Ore to experience.yml for Mining (was missing)
|
||||
|
||||
Added Moss Block to Bonus Drops for Herbalism in config.yml
|
||||
Added Glow Berries to Bonus Drops for Herbalism in config.yml
|
||||
Added Cave Vines to Bonus Drops for Herbalism in config.yml
|
||||
Added Cave Vines Plant to Bonus Drops for Herbalism in config.yml
|
||||
Added Tuff to Bonus Drops for Mining in config.yml
|
||||
Added Amethyst Shard to Bonus Drops for Mining in config.yml
|
||||
Added Calcite to Bonus Drops for Mining in config.yml
|
||||
Added Smooth Basalt to Bonus Drops for Mining in config.yml
|
||||
Added Block_Of_Amethyst to Bonus Drops for Mining in config.yml
|
||||
Added Budding Amethyst to Bonus Drops for Mining in config.yml
|
||||
Added Small_Amethyst_Bud to Bonus Drops for Mining in config.yml
|
||||
Added Medium Amethyst Bud to Bonus Drops for Mining in config.yml
|
||||
Added Large Amethyst Bud to Bonus Drops for Mining in config.yml
|
||||
Added Amethyst Cluster to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate to Bonus Drops for Mining in config.yml
|
||||
Added Cobbled Deepslate to Bonus Drops for Mining in config.yml
|
||||
Added Raw Iron to Bonus Drops for Mining in config.yml
|
||||
Added Raw Gold to Bonus Drops for Mining in config.yml
|
||||
Added Raw Copper to Bonus Drops for Mining in config.yml
|
||||
Added Copper Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Redstone Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Copper Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Coal Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Diamond Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Emerald Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Iron Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Gold Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Lapis Lazuli Ore to Bonus Drops for Mining in config.yml
|
||||
Added Lapis Lazuli Ore to Bonus Drops for Mining in config.yml (was missing)
|
||||
|
||||
Added Cobbled Deepslate to experience.yml for Smelting
|
||||
Added Raw Copper to experience.yml for Smelting
|
||||
Added Raw Iron to experience.yml for Smelting
|
||||
Added Raw Gold to experience.yml for Smelting
|
||||
Added Copper Ore to experience.yml for Smelting
|
||||
Added Deepslate Redstone Ore to experience.yml for Smelting
|
||||
Added Deepslate Copper Ore to experience.yml for Smelting
|
||||
Added Deepslate Coal Ore to experience.yml for Smelting
|
||||
Added Deepslate Diamond Ore to experience.yml for Smelting
|
||||
Added Deepslate Emerald Ore to experience.yml for Smelting
|
||||
Added Deepslate Iron Ore to experience.yml for Smelting
|
||||
Added Deepslate Gold Ore to experience.yml for Smelting
|
||||
Added Deepslate Lapis Lazuli Ore to experience.yml for Smelting
|
||||
Added Lapis Lazuli Ore to experience.yml for Smelting (was missing)
|
||||
|
||||
NOTES:
|
||||
Another patch will follow this one shortly to add more 1.17 support, I am waiting on the Spigot API to test some stuff which isn't out yet.
|
||||
You shouldn't need to edit your configs for this update, your configs should update automatically.
|
||||
Expect some patches following this update for Axolotl and other new entities, waiting on the Spigot API to become available
|
||||
If you run into any issues with ViaVersion or ViaBackwards, use the latest dev builds for each.
|
||||
|
||||
Version 2.1.196
|
||||
Removed the explosion from Rupture
|
||||
Adjusted Rupture to play its particle effect less often
|
||||
Fixed a bug where Rupture never applied to additional targets during Serrated Strikes
|
||||
Fixed a bug where players without Rupture permission could use Rupture during Serrated Strikes
|
||||
Fixed a possible null error for our SelfListener
|
||||
Added locale string 'Swords.Combat.Rupture.Note.Update.One'
|
||||
Updated locale string 'Guides.Swords.Section.1'
|
||||
Crossbows can now be fished up with enchantments
|
||||
(API) Added McMMOEntityDamageByRuptureEvent (thanks qixils)
|
||||
|
||||
NOTES:
|
||||
For now Rupture is non-lethal, I may add back a lethal component at the end of its damage
|
||||
Rupture will be in a state of change for a while as I receive feedback (give me feedback in Discord!)
|
||||
Crossbows is not in the default fishing loot list, you'd have to add it yourself.
|
||||
For Devs: McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent and uses CUSTOM type damage
|
||||
|
||||
Version 2.1.195
|
||||
Fixed a null connection error which affected some SQL users
|
||||
|
||||
167
pom.xml
Executable file → Normal file
167
pom.xml
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.196-SNAPSHOT</version>
|
||||
<version>2.1.222</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
@@ -14,6 +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>
|
||||
</properties>
|
||||
|
||||
<issueManagement>
|
||||
@@ -72,28 +75,37 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<version>3.0.0-M7</version>
|
||||
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<version>3.0.0-M7</version>
|
||||
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<version>3.0.0-M6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<release>16</release>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg> <!-- used for ACF syntax stuff -->
|
||||
</compilerArgs>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<excludes>
|
||||
</excludes>
|
||||
</configuration>
|
||||
@@ -118,7 +130,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
@@ -131,7 +143,6 @@
|
||||
<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-common</include>
|
||||
<include>net.kyori:adventure-platform-viaversion</include>
|
||||
<include>net.kyori:adventure-platform-facet</include>
|
||||
<include>net.kyori:adventure-nbt</include>
|
||||
@@ -145,11 +156,10 @@
|
||||
<include>co.aikar:acf-bukkit</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<!-- <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>-->
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.kyori.examination</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.kyori.examination</shadedPattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.examination</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
@@ -179,6 +189,10 @@
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.tcoded.folialib</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.folialib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
@@ -195,10 +209,17 @@
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>3.5.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@@ -209,8 +230,8 @@
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
<id>enginehub-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository> <!-- for development builds -->
|
||||
<id>sonatype-oss</id>
|
||||
@@ -220,100 +241,90 @@
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-oss-snapshots1</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>devmart-other</id>
|
||||
<url>https://nexuslite.gcnt.net/repos/other/</url>
|
||||
</repository>
|
||||
<!-- ... -->
|
||||
<!-- ... -->
|
||||
</repositories>
|
||||
<!-- <dependencyManagement>-->
|
||||
<!-- <dependencies>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.junit</groupId>-->
|
||||
<!-- <artifactId>junit-bom</artifactId>-->
|
||||
<!-- <version>5.7.1</version>-->
|
||||
<!-- <type>pom</type>-->
|
||||
<!-- <scope>import</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- </dependencies>-->
|
||||
<!-- </dependencyManagement>-->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.seeseemelk</groupId>
|
||||
<artifactId>MockBukkit-v1.16</artifactId>
|
||||
<version>0.25.0</version>
|
||||
<scope>test</scope>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-bukkit</artifactId> <!-- Don't forget to replace this -->
|
||||
<version>0.5.0-SNAPSHOT</version> <!-- Replace this as well -->
|
||||
<version>0.5.1-SNAPSHOT</version> <!-- Replace this as well -->
|
||||
</dependency>
|
||||
<!-- adventure-api, adventure-text-serializer-gson, adventure-platform-bukkit-->
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-nbt</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-key</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<version>4.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-api</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-common</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-nbt</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>4.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||
<version>1.9.4</version>
|
||||
<version>2.0.0-M1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-core</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<version>7.0.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- We use jetbrains instead. Excluding this -->
|
||||
@@ -336,50 +347,44 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.7.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>4.6.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>4.6.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jdbc</artifactId>
|
||||
<version>7.0.52</version>
|
||||
<version>10.1.0-M17</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<version>23.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.0.0-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tcoded</groupId>
|
||||
<artifactId>FoliaLib</artifactId>
|
||||
<version>0.2.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -84,7 +84,7 @@ public final class AbilityAPI {
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
if(entity.isValid()) {
|
||||
if(entity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ public final class ExperienceAPI {
|
||||
* @param skillType A string that may or may not be a skill
|
||||
* @return true if this is a valid mcMMO skill
|
||||
*/
|
||||
public static boolean isValidSkillType(String skillType) {
|
||||
public static boolean isValidSkillType(@NotNull String skillType) {
|
||||
return mcMMO.p.getSkillTools().matchSkill(skillType) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the task that gives combat XP.
|
||||
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
|
||||
* Processes combat XP like mcMMO normally would, so mcMMO will check whether the entity should reward XP when giving out the XP
|
||||
*
|
||||
* @param mcMMOPlayer The attacking player
|
||||
* @param target The defending entity
|
||||
@@ -56,7 +56,7 @@ public final class ExperienceAPI {
|
||||
|
||||
/**
|
||||
* Start the task that gives combat XP.
|
||||
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
|
||||
* Processes combat XP like mcMMO normally would, so mcMMO will check whether the entity should reward XP when giving out the XP
|
||||
*
|
||||
* @param mcMMOPlayer The attacking player
|
||||
* @param target The defending entity
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
public enum FakeBlockBreakEventType {
|
||||
FAKE,
|
||||
TREE_FELLER
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TreeFellerBlockBreakEvent extends FakeBlockBreakEvent {
|
||||
public TreeFellerBlockBreakEvent(@NotNull Block theBlock, @NotNull Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class ChatManager {
|
||||
*
|
||||
* @param mmoPlayer target player
|
||||
* @param rawMessage the raw message from the player as it was typed
|
||||
* @param isAsync whether or not this is getting processed via async
|
||||
* @param isAsync whether this is getting processed via async
|
||||
*/
|
||||
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String rawMessage, boolean isAsync) {
|
||||
processPlayerMessage(mmoPlayer, mmoPlayer.getChatChannel(), rawMessage, isAsync);
|
||||
@@ -69,7 +69,7 @@ public class ChatManager {
|
||||
* @param mmoPlayer target player
|
||||
* @param chatChannel target chat channel
|
||||
* @param rawMessage raw chat message as it was typed
|
||||
* @param isAsync whether or not this is getting processed via async
|
||||
* @param isAsync whether this is getting processed via async
|
||||
*/
|
||||
private void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel chatChannel, @NotNull String rawMessage, boolean isAsync) {
|
||||
switch (chatChannel) {
|
||||
@@ -155,7 +155,7 @@ public class ChatManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the player is allowed to send a message to the chat channel they are targeting
|
||||
* Whether the player is allowed to send a message to the chat channel they are targeting
|
||||
* @param mmoPlayer target player
|
||||
* @return true if the player can send messages to that chat channel
|
||||
*/
|
||||
@@ -197,7 +197,7 @@ public class ChatManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a specific chat channel is enabled
|
||||
* Whether a specific chat channel is enabled
|
||||
* ChatChannels are enabled/disabled via user config
|
||||
*
|
||||
* If chat is disabled, this always returns false
|
||||
|
||||
@@ -23,8 +23,7 @@ public class SamePartyPredicate<T extends CommandSender> implements Predicate<T>
|
||||
if(t instanceof ConsoleCommandSender) {
|
||||
return false; //Party audiences are special, we exclude console from them to avoid double messaging since we send a more verbose version to consoles
|
||||
} else {
|
||||
if(t instanceof Player) {
|
||||
Player player = (Player) t;
|
||||
if(t instanceof Player player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
if(mcMMOPlayer != null) {
|
||||
return mcMMOPlayer.getParty() == party;
|
||||
|
||||
@@ -73,7 +73,7 @@ public abstract class AbstractPlayerAuthor implements Author {
|
||||
* Sanitized names are associated with a {@link ChatChannel} as different chat channels have different chat name settings
|
||||
*
|
||||
* @param chatChannel target chat channel
|
||||
* @param useDisplayName whether or not to use this authors display name
|
||||
* @param useDisplayName whether to use this authors display name
|
||||
*/
|
||||
private void updateSanitizedNameCache(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
|
||||
if(useDisplayName) {
|
||||
|
||||
@@ -17,14 +17,14 @@ public interface Author extends Identity {
|
||||
@NotNull String getAuthoredName(@NotNull ChatChannel chatChannel);
|
||||
|
||||
/**
|
||||
* Whether or not this author is a {@link org.bukkit.command.ConsoleCommandSender}
|
||||
* Whether this author is a {@link org.bukkit.command.ConsoleCommandSender}
|
||||
*
|
||||
* @return true if this author is the console
|
||||
*/
|
||||
boolean isConsole();
|
||||
|
||||
/**
|
||||
* Whether or not this author is a {@link org.bukkit.entity.Player}
|
||||
* Whether this author is a {@link org.bukkit.entity.Player}
|
||||
* @return true if this author is a player
|
||||
*/
|
||||
boolean isPlayer();
|
||||
|
||||
@@ -73,8 +73,8 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
*
|
||||
* @param author the author
|
||||
* @param rawString the raw message as the author typed it before any styling
|
||||
* @param isAsync whether or not this is being processed asynchronously
|
||||
* @param canColor whether or not the author can use colors in chat
|
||||
* @param isAsync whether this is being processed asynchronously
|
||||
* @param canColor whether the author can use colors in chat
|
||||
*/
|
||||
public void processChatMessage(@NotNull Author author, @NotNull String rawString, boolean isAsync, boolean canColor) {
|
||||
AdminChatMessage chatMessage = new AdminChatMessage(pluginRef, author, constructAudience(), rawString, addStyle(author, rawString, canColor));
|
||||
|
||||
@@ -27,8 +27,8 @@ public class PartyChatMailer extends AbstractChatMailer {
|
||||
*
|
||||
* @param author the author
|
||||
* @param rawString the raw message as the author typed it before any styling
|
||||
* @param isAsync whether or not this is being processed asynchronously
|
||||
* @param canColor whether or not the author can use colors in chat
|
||||
* @param isAsync whether this is being processed asynchronously
|
||||
* @param canColor whether the author can use colors in chat
|
||||
*/
|
||||
public void processChatMessage(@NotNull Author author, @NotNull String rawString, @NotNull Party party, boolean isAsync, boolean canColor, boolean isLeader) {
|
||||
PartyChatMessage chatMessage = new PartyChatMessage(pluginRef, author, constructPartyAudience(party), rawString, addStyle(author, rawString, canColor, isLeader), party);
|
||||
|
||||
@@ -24,8 +24,10 @@ public class McnotifyCommand implements TabExecutor {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
//Not Loaded yet
|
||||
if (mcMMOPlayer == null)
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
|
||||
@@ -23,6 +23,16 @@ public class McscoreboardCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Scoreboard.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!ScoreboardManager.isPlayerBoardSetup(sender.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Scoreboard.NotSetupYet"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
|
||||
@@ -200,15 +200,19 @@ public class PartyCommand implements TabExecutor {
|
||||
|
||||
if (matches.size() == 0) {
|
||||
Player player = (Player) sender;
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Not Loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(mcMMOPlayer == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
if (mcMMOPlayer.getParty() == null)
|
||||
return ImmutableList.of();
|
||||
|
||||
final Party party = mcMMOPlayer.getParty();
|
||||
|
||||
playerNames = party.getOnlinePlayerNames(player);
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
|
||||
|
||||
@@ -1,6 +1,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.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -15,13 +16,14 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String partyName = playerParty.getName();
|
||||
final Party playerParty = mcMMOPlayer.getParty();
|
||||
final String partyName = playerParty.getName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
@@ -31,7 +33,7 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(playerParty);
|
||||
PartyManager.disbandParty(mcMMOPlayer, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
String oldPartyName = playerParty.getName();
|
||||
String newPartyName = args[1];
|
||||
String newPartyName = args[1].replace(".", "");
|
||||
|
||||
// This is to prevent party leaders from spamming other players with the rename message
|
||||
if (oldPartyName.equalsIgnoreCase(newPartyName)) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -62,6 +63,12 @@ public class InspectCommand implements TabExecutor {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
// Sum power level
|
||||
int powerLevel = 0;
|
||||
for (PrimarySkillType skill : SkillTools.NON_CHILD_SKILLS)
|
||||
powerLevel += profile.getSkillLevel(skill);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", powerLevel));
|
||||
} else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
boolean isVanished = false;
|
||||
@@ -85,10 +92,16 @@ public class InspectCommand implements TabExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
if (isVanished) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
}
|
||||
|
||||
CommandUtils.printGatheringSkills(target, sender);
|
||||
CommandUtils.printCombatSkills(target, sender);
|
||||
CommandUtils.printMiscSkills(target, sender);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -97,11 +98,11 @@ public class McrankCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
|
||||
@@ -5,6 +5,7 @@ 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.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -97,11 +98,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
|
||||
@@ -91,7 +91,7 @@ public class HerbalismCommand extends SkillCommand {
|
||||
protected void permissionsCheck(Player player) {
|
||||
hasHylianLuck = 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.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
|
||||
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);
|
||||
|
||||
@@ -27,12 +27,11 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
/*
|
||||
* Only allow players to use this command
|
||||
*/
|
||||
if(commandSender instanceof Player)
|
||||
if(commandSender instanceof Player player)
|
||||
{
|
||||
if(args.length < 1)
|
||||
return false;
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(Permissions.mmoinfo(player))
|
||||
{
|
||||
if(args == null || args[0] == null)
|
||||
|
||||
@@ -59,18 +59,17 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
boolean isLucky = Permissions.lucky(player, skill);
|
||||
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
||||
boolean hasEndurance = PerksUtils.handleActivationPerks(player, 0, 0) != 0;
|
||||
float skillValue = mcMMOPlayer.getSkillLevel(skill);
|
||||
|
||||
//Send the players a few blank lines to make finding the top of the skill command easier
|
||||
@@ -116,8 +115,21 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if ("keep".equals(args[0].toLowerCase())) {
|
||||
if (!mcMMO.p.getGeneralConfig().getAllowKeepBoard()
|
||||
|| !mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
|
||||
|| !mcMMO.p.getGeneralConfig().getSkillUseBoard()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||
ScoreboardManager.keepBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return skillGuideCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
@@ -211,7 +223,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return ImmutableList.of("?");
|
||||
return ImmutableList.of("?", "keep");
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ public class SwordsCommand extends SkillCommand {
|
||||
ruptureLengthSecondsAgainstMobs));
|
||||
|
||||
messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.TickDamage", rupturePureTickDamageAgainstPlayers, rupturePureTickDamageAgainstMobs));
|
||||
messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.ExplosionDamage", ruptureExplosionDamageAgainstPlayers, ruptureExplosionDamageAgainstMobs));
|
||||
// messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.ExplosionDamage", ruptureExplosionDamageAgainstPlayers, ruptureExplosionDamageAgainstMobs));
|
||||
|
||||
messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note"));
|
||||
messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note.Update.One"));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public class AdvancedConfig extends BukkitConfig {
|
||||
|
||||
public AdvancedConfig(File dataFolder) {
|
||||
super("advanced.yml", dataFolder);
|
||||
@@ -99,8 +99,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* AXES */
|
||||
if(getAxeMasteryRankDamageMultiplier() < 0)
|
||||
{
|
||||
if (getAxeMasteryRankDamageMultiplier() < 0) {
|
||||
reason.add("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
|
||||
}
|
||||
|
||||
@@ -404,12 +403,18 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
protected void loadKeys() {
|
||||
}
|
||||
|
||||
/* GENERAL */
|
||||
|
||||
public boolean canApplyLimitBreakPVE() { return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false); }
|
||||
public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); }
|
||||
public boolean canApplyLimitBreakPVE() {
|
||||
return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false);
|
||||
}
|
||||
|
||||
public int getStartingLevel() {
|
||||
return config.getInt("Skills.General.StartingLevel", 1);
|
||||
}
|
||||
|
||||
public boolean allowPlayerTips() {
|
||||
return config.getBoolean("Feedback.PlayerTips", true);
|
||||
@@ -417,11 +422,12 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
|
||||
* It returns a different value depending on whether or not the server is in retro mode
|
||||
* It returns a different value depending on whether the server is in retro mode
|
||||
*
|
||||
* @return the level at which abilities stop increasing in length
|
||||
*/
|
||||
public int getAbilityLengthCap() {
|
||||
if(!mcMMO.isRetroModeEnabled())
|
||||
if (!mcMMO.isRetroModeEnabled())
|
||||
return config.getInt("Skills.General.Ability.Length.Standard.CapLevel", 50);
|
||||
else
|
||||
return config.getInt("Skills.General.Ability.Length.RetroMode.CapLevel", 500);
|
||||
@@ -429,28 +435,33 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* This returns the frequency at which abilities will increase in length
|
||||
* It returns a different value depending on whether or not the server is in retro mode
|
||||
* It returns a different value depending on whether the server is in retro mode
|
||||
*
|
||||
* @return the number of levels required per ability length increase
|
||||
*/
|
||||
public int getAbilityLength() {
|
||||
if(!mcMMO.isRetroModeEnabled())
|
||||
if (!mcMMO.isRetroModeEnabled())
|
||||
return config.getInt("Skills.General.Ability.Length.Standard.IncreaseLevel", 5);
|
||||
else
|
||||
return config.getInt("Skills.General.Ability.Length.RetroMode.IncreaseLevel", 50);
|
||||
}
|
||||
|
||||
public int getEnchantBuff() { return config.getInt("Skills.General.Ability.EnchantBuff", 5); }
|
||||
public int getEnchantBuff() {
|
||||
return config.getInt("Skills.General.Ability.EnchantBuff", 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the max bonus level for a skill used in RNG calculations
|
||||
* All max level values in the config are multiplied by 10 if the server is in retro mode as the values in the config are based around the new 1-100 skill system scaling
|
||||
* A value of 10 in the file will be returned as 100 for retro mode servers to accommodate the change in scaling
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
*
|
||||
* @return the level at which this skills max benefits will be reached on the curve
|
||||
*/
|
||||
public int getMaxBonusLevel(SubSkillType subSkillType) {
|
||||
String keyPath = subSkillType.getAdvConfigAddress() + ".MaxBonusLevel.";
|
||||
return mcMMO.isRetroModeEnabled() ? config.getInt(keyPath+"RetroMode", 1000) : config.getInt(keyPath+"Standard", 100);
|
||||
return mcMMO.isRetroModeEnabled() ? config.getInt(keyPath + "RetroMode", 1000) : config.getInt(keyPath + "Standard", 100);
|
||||
}
|
||||
|
||||
public int getMaxBonusLevel(AbstractSubSkill abstractSubSkill) {
|
||||
@@ -462,35 +473,29 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
return config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D);
|
||||
}
|
||||
|
||||
public double getMaximumProbability(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public double getMaximumProbability(AbstractSubSkill abstractSubSkill) {
|
||||
return getMaximumProbability(abstractSubSkill.getSubSkillType());
|
||||
}
|
||||
|
||||
/* Notification Settings */
|
||||
|
||||
public boolean doesSkillCommandSendBlankLines()
|
||||
{
|
||||
public boolean doesSkillCommandSendBlankLines() {
|
||||
return config.getBoolean("Feedback.SkillCommand.BlankLinesAboveHeader", true);
|
||||
}
|
||||
|
||||
public boolean doesNotificationUseActionBar(NotificationType notificationType)
|
||||
{
|
||||
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".Enabled", true);
|
||||
public boolean doesNotificationUseActionBar(NotificationType notificationType) {
|
||||
return config.getBoolean("Feedback.ActionBarNotifications." + notificationType.toString() + ".Enabled", true);
|
||||
}
|
||||
|
||||
public boolean doesNotificationSendCopyToChat(NotificationType notificationType)
|
||||
{
|
||||
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".SendCopyOfMessageToChat", false);
|
||||
public boolean doesNotificationSendCopyToChat(NotificationType notificationType) {
|
||||
return config.getBoolean("Feedback.ActionBarNotifications." + notificationType.toString() + ".SendCopyOfMessageToChat", false);
|
||||
}
|
||||
|
||||
public boolean useTitlesForXPEvent()
|
||||
{
|
||||
public boolean useTitlesForXPEvent() {
|
||||
return config.getBoolean("Feedback.Events.XP.SendTitles", true);
|
||||
}
|
||||
|
||||
public boolean sendAbilityNotificationToOtherPlayers()
|
||||
{
|
||||
public boolean sendAbilityNotificationToOtherPlayers() {
|
||||
return config.getBoolean("Feedback.Events.AbilityActivation.SendNotificationToOtherPlayers", true);
|
||||
}
|
||||
|
||||
@@ -509,6 +514,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Used to color our details header in our JSON Hover Object tooltips
|
||||
*
|
||||
* @return the ChatColor for this element
|
||||
*/
|
||||
/*public ChatColor getJSONStatHoverDetailsColor()
|
||||
@@ -557,7 +563,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
{
|
||||
return getChatColor(config.getString("Style.JSON.Notification."+notificationType.toString()+".Color"));
|
||||
}*/
|
||||
|
||||
private ChatColor getChatColorFromKey(String keyLocation) {
|
||||
String colorName = config.getString(keyLocation);
|
||||
|
||||
@@ -598,110 +603,247 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Some SubSkills have the ability to retain classic functionality
|
||||
*
|
||||
* @param subSkillType SubSkillType with classic functionality
|
||||
*
|
||||
* @return true if the subskill is in classic mode
|
||||
*/
|
||||
public boolean isSubSkillClassic(SubSkillType subSkillType)
|
||||
{
|
||||
return config.getBoolean(subSkillType.getAdvConfigAddress()+".Classic");
|
||||
public boolean isSubSkillClassic(SubSkillType subSkillType) {
|
||||
return config.getBoolean(subSkillType.getAdvConfigAddress() + ".Classic");
|
||||
}
|
||||
|
||||
/* ACROBATICS */
|
||||
public double getDodgeDamageModifier() { return config.getDouble("Skills.Acrobatics.Dodge.DamageModifier", 2.0D); }
|
||||
public double getDodgeDamageModifier() {
|
||||
return config.getDouble("Skills.Acrobatics.Dodge.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.Roll.DamageThreshold", 7.0D); }
|
||||
public double getRollDamageThreshold() {
|
||||
return config.getDouble("Skills.Acrobatics.Roll.DamageThreshold", 7.0D);
|
||||
}
|
||||
|
||||
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D); }
|
||||
public double getGracefulRollDamageThreshold() {
|
||||
return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D);
|
||||
}
|
||||
|
||||
/* ALCHEMY */
|
||||
public int getCatalysisMaxBonusLevel() { return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000); }
|
||||
public int getCatalysisMaxBonusLevel() {
|
||||
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000);
|
||||
}
|
||||
|
||||
public double getCatalysisMinSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MinSpeed", 1.0D); }
|
||||
public double getCatalysisMaxSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MaxSpeed", 4.0D); }
|
||||
public double getCatalysisMinSpeed() {
|
||||
return config.getDouble("Skills.Alchemy.Catalysis.MinSpeed", 1.0D);
|
||||
}
|
||||
|
||||
public double getCatalysisMaxSpeed() {
|
||||
return config.getDouble("Skills.Alchemy.Catalysis.MaxSpeed", 4.0D);
|
||||
}
|
||||
|
||||
|
||||
/* ARCHERY */
|
||||
public double getSkillShotRankDamageMultiplier() { return config.getDouble("Skills.Archery.SkillShot.RankDamageMultiplier", 10.0D); }
|
||||
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
|
||||
public double getSkillShotRankDamageMultiplier() {
|
||||
return config.getDouble("Skills.Archery.SkillShot.RankDamageMultiplier", 10.0D);
|
||||
}
|
||||
|
||||
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
|
||||
public double getSkillShotDamageMax() {
|
||||
return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D);
|
||||
}
|
||||
|
||||
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
|
||||
public double getDazeBonusDamage() {
|
||||
return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D);
|
||||
}
|
||||
|
||||
public double getForceMultiplier() {
|
||||
return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D);
|
||||
}
|
||||
|
||||
/* AXES */
|
||||
public double getAxeMasteryRankDamageMultiplier() { return config.getDouble("Skills.Axes.AxeMastery.RankDamageMultiplier", 1.0D); }
|
||||
public double getAxeMasteryRankDamageMultiplier() {
|
||||
return config.getDouble("Skills.Axes.AxeMastery.RankDamageMultiplier", 1.0D);
|
||||
}
|
||||
|
||||
public double getCriticalStrikesPVPModifier() { return config.getDouble("Skills.Axes.CriticalStrikes.PVP_Modifier", 1.5D); }
|
||||
public double getCriticalStrikesPVEModifier() { return config.getDouble("Skills.Axes.CriticalStrikes.PVE_Modifier", 2.0D); }
|
||||
public double getCriticalStrikesPVPModifier() {
|
||||
return config.getDouble("Skills.Axes.CriticalStrikes.PVP_Modifier", 1.5D);
|
||||
}
|
||||
|
||||
public double getGreaterImpactChance() { return config.getDouble("Skills.Axes.GreaterImpact.Chance", 25.0D); }
|
||||
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact.KnockbackModifier", 1.5D); }
|
||||
public double getGreaterImpactBonusDamage() { return config.getDouble("Skills.Axes.GreaterImpact.BonusDamage", 2.0D); }
|
||||
public double getCriticalStrikesPVEModifier() {
|
||||
return config.getDouble("Skills.Axes.CriticalStrikes.PVE_Modifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact.Chance", 25.0D); }
|
||||
public double getImpactDurabilityDamageMultiplier() { return config.getDouble("Skills.Axes.ArmorImpact.DamagePerRank", 6.5D); }
|
||||
public double getGreaterImpactChance() {
|
||||
return config.getDouble("Skills.Axes.GreaterImpact.Chance", 25.0D);
|
||||
}
|
||||
|
||||
public double getSkullSplitterModifier() { return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D); }
|
||||
public double getGreaterImpactModifier() {
|
||||
return config.getDouble("Skills.Axes.GreaterImpact.KnockbackModifier", 1.5D);
|
||||
}
|
||||
|
||||
public double getGreaterImpactBonusDamage() {
|
||||
return config.getDouble("Skills.Axes.GreaterImpact.BonusDamage", 2.0D);
|
||||
}
|
||||
|
||||
public double getImpactChance() {
|
||||
return config.getDouble("Skills.Axes.ArmorImpact.Chance", 25.0D);
|
||||
}
|
||||
|
||||
public double getImpactDurabilityDamageMultiplier() {
|
||||
return config.getDouble("Skills.Axes.ArmorImpact.DamagePerRank", 6.5D);
|
||||
}
|
||||
|
||||
public double getSkullSplitterModifier() {
|
||||
return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
//Nothing to configure, everything is already configurable in config.yml
|
||||
|
||||
/* FISHING */
|
||||
public double getShakeChance(int rank) { return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank); }
|
||||
public int getFishingVanillaXPModifier(int rank) { return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank); }
|
||||
public double getShakeChance(int rank) {
|
||||
return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank);
|
||||
}
|
||||
|
||||
public int getFishingReductionMinWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Min_Wait", 10);}
|
||||
public int getFishingReductionMaxWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Max_Wait", 30);}
|
||||
public int getFishingBoatReductionMinWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Min_Wait", 10);}
|
||||
public int getFishingBoatReductionMaxWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Max_Wait", 30);}
|
||||
public int getFishingReductionMinWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Min_Wait", 40);}
|
||||
public int getFishingReductionMaxWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait", 100);}
|
||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200); }
|
||||
public int getFishingVanillaXPModifier(int rank) {
|
||||
return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank);
|
||||
}
|
||||
|
||||
public int getFishingReductionMinWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Min_Wait", 10);
|
||||
}
|
||||
|
||||
public int getFishingReductionMaxWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Max_Wait", 30);
|
||||
}
|
||||
|
||||
public int getFishingBoatReductionMinWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Min_Wait", 10);
|
||||
}
|
||||
|
||||
public int getFishingBoatReductionMaxWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Max_Wait", 30);
|
||||
}
|
||||
|
||||
public int getFishingReductionMinWaitCap() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Min_Wait", 40);
|
||||
}
|
||||
|
||||
public int getFishingReductionMaxWaitCap() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait", 100);
|
||||
}
|
||||
|
||||
public int getFishermanDietRankChange() {
|
||||
return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200);
|
||||
}
|
||||
|
||||
|
||||
public double getMasterAnglerBoatModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BoatModifier", 2.0); }
|
||||
public double getMasterAnglerBiomeModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BiomeModifier", 2.0); }
|
||||
public double getMasterAnglerBoatModifier() {
|
||||
return config.getDouble("Skills.Fishing.MasterAngler.BoatModifier", 2.0);
|
||||
}
|
||||
|
||||
public double getMasterAnglerBiomeModifier() {
|
||||
return config.getDouble("Skills.Fishing.MasterAngler.BiomeModifier", 2.0);
|
||||
}
|
||||
|
||||
/* HERBALISM */
|
||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.FarmersDiet.RankChange", 200); }
|
||||
public int getFarmerDietRankChange() {
|
||||
return config.getInt("Skills.Herbalism.FarmersDiet.RankChange", 200);
|
||||
}
|
||||
|
||||
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb.StageChange", 200); }
|
||||
public int getGreenThumbStageChange() {
|
||||
return config.getInt("Skills.Herbalism.GreenThumb.StageChange", 200);
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
public boolean getDoubleDropSilkTouchEnabled() { return config.getBoolean("Skills.Mining.DoubleDrops.SilkTouch", true); }
|
||||
public boolean getAllowMiningTripleDrops() { return config.getBoolean("Skills.Mining.SuperBreaker.AllowTripleDrops", true); }
|
||||
public int getBlastMiningRankLevel(int rank) { return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank); }
|
||||
public double getBlastDamageDecrease(int rank) { return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank); }
|
||||
public double getOreBonus(int rank) { return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank); }
|
||||
public double getDebrisReduction(int rank) { return config.getDouble("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank); }
|
||||
public int getDropMultiplier(int rank) { return config.getInt("Skills.Mining.BlastMining.DropMultiplier.Rank_" + rank); }
|
||||
public double getBlastRadiusModifier(int rank) { return config.getDouble("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + rank); }
|
||||
public boolean getDoubleDropSilkTouchEnabled() {
|
||||
return config.getBoolean("Skills.Mining.DoubleDrops.SilkTouch", true);
|
||||
}
|
||||
|
||||
public boolean getAllowMiningTripleDrops() {
|
||||
return config.getBoolean("Skills.Mining.SuperBreaker.AllowTripleDrops", true);
|
||||
}
|
||||
|
||||
public int getBlastMiningRankLevel(int rank) {
|
||||
return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getBlastDamageDecrease(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getOreBonus(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank);
|
||||
}
|
||||
|
||||
public boolean isBlastMiningBonusDropsEnabled() {
|
||||
return config.getBoolean("Skills.Mining.BlastMining.Bonus_Drops.Enabled", true);
|
||||
}
|
||||
|
||||
public double getDebrisReduction(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank);
|
||||
}
|
||||
|
||||
public int getDropMultiplier(int rank) {
|
||||
return config.getInt("Skills.Mining.BlastMining.DropMultiplier.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getBlastRadiusModifier(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + rank);
|
||||
}
|
||||
|
||||
/* REPAIR */
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 100); }
|
||||
public double getRepairMasteryMaxBonus() {
|
||||
return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D);
|
||||
}
|
||||
|
||||
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.May_Lose_Enchants", true); }
|
||||
public double getArcaneForgingKeepEnchantsChance(int rank) { return config.getDouble("Skills.Repair.ArcaneForging.Keep_Enchants_Chance.Rank_" + rank); }
|
||||
public int getRepairMasteryMaxLevel() {
|
||||
return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 100);
|
||||
}
|
||||
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
|
||||
public double getArcaneForgingDowngradeChance(int rank) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + rank); }
|
||||
public boolean getAllowEnchantedRepairMaterials() {
|
||||
return config.getBoolean("Skills.Repair.Use_Enchanted_Materials", false);
|
||||
}
|
||||
|
||||
public boolean getArcaneSalvageEnchantDowngradeEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true); }
|
||||
public boolean getArcaneSalvageEnchantLossEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true); }
|
||||
public boolean getArcaneForgingEnchantLossEnabled() {
|
||||
return config.getBoolean("Skills.Repair.ArcaneForging.May_Lose_Enchants", true);
|
||||
}
|
||||
|
||||
public double getArcaneSalvageExtractFullEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank); }
|
||||
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank); }
|
||||
public double getArcaneForgingKeepEnchantsChance(int rank) {
|
||||
return config.getDouble("Skills.Repair.ArcaneForging.Keep_Enchants_Chance.Rank_" + rank);
|
||||
}
|
||||
|
||||
public boolean getArcaneForgingDowngradeEnabled() {
|
||||
return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true);
|
||||
}
|
||||
|
||||
public double getArcaneForgingDowngradeChance(int rank) {
|
||||
return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + rank);
|
||||
}
|
||||
|
||||
public boolean getArcaneSalvageEnchantDowngradeEnabled() {
|
||||
return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true);
|
||||
}
|
||||
|
||||
public boolean getArcaneSalvageEnchantLossEnabled() {
|
||||
return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true);
|
||||
}
|
||||
|
||||
public double getArcaneSalvageExtractFullEnchantsChance(int rank) {
|
||||
return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) {
|
||||
return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank);
|
||||
}
|
||||
|
||||
/* SMELTING */
|
||||
public int getBurnModifierMaxLevel() {
|
||||
if(mcMMO.isRetroModeEnabled())
|
||||
if (mcMMO.isRetroModeEnabled())
|
||||
return config.getInt("Skills.Smelting.FuelEfficiency.RetroMode.MaxBonusLevel", 1000);
|
||||
else
|
||||
return config.getInt("Skills.Smelting.FuelEfficiency.Standard.MaxBonusLevel", 100);
|
||||
}
|
||||
|
||||
public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining.Chance", 33.0D); }
|
||||
public double getFluxMiningChance() {
|
||||
return config.getDouble("Skills.Smelting.FluxMining.Chance", 33.0D);
|
||||
}
|
||||
|
||||
/* SWORDS */
|
||||
public double getRuptureTickDamage(boolean isTargetPlayer, int rank) {
|
||||
@@ -731,35 +873,68 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
return config.getDouble(root + rank, 33);
|
||||
}
|
||||
|
||||
public double getCounterModifier() { return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D); }
|
||||
public double getCounterModifier() {
|
||||
return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getSerratedStrikesModifier() { return config.getDouble("Skills.Swords.SerratedStrikes.DamageModifier", 4.0D); }
|
||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes.RuptureTicks", 5); }
|
||||
public double getSerratedStrikesModifier() {
|
||||
return config.getDouble("Skills.Swords.SerratedStrikes.DamageModifier", 4.0D);
|
||||
}
|
||||
|
||||
public int getSerratedStrikesTicks() {
|
||||
return config.getInt("Skills.Swords.SerratedStrikes.RuptureTicks", 5);
|
||||
}
|
||||
|
||||
/* TAMING */
|
||||
public double getGoreModifier() { return config.getDouble("Skills.Taming.Gore.Modifier", 2.0D); }
|
||||
public double getGoreModifier() {
|
||||
return config.getDouble("Skills.Taming.Gore.Modifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getFastFoodChance() { return config.getDouble("Skills.Taming.FastFoodService.Chance", 50.0D); }
|
||||
public double getPummelChance() { return config.getDouble("Skills.Taming.Pummel.Chance", 10.0D); }
|
||||
public double getFastFoodChance() {
|
||||
return config.getDouble("Skills.Taming.FastFoodService.Chance", 50.0D);
|
||||
}
|
||||
|
||||
public double getThickFurModifier() { return config.getDouble("Skills.Taming.ThickFur.Modifier", 2.0D); }
|
||||
public double getPummelChance() {
|
||||
return config.getDouble("Skills.Taming.Pummel.Chance", 10.0D);
|
||||
}
|
||||
|
||||
public double getShockProofModifier() { return config.getDouble("Skills.Taming.ShockProof.Modifier", 6.0D); }
|
||||
public double getThickFurModifier() {
|
||||
return config.getDouble("Skills.Taming.ThickFur.Modifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
|
||||
public double getShockProofModifier() {
|
||||
return config.getDouble("Skills.Taming.ShockProof.Modifier", 6.0D);
|
||||
}
|
||||
|
||||
public double getMinHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D); }
|
||||
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
|
||||
public double getSharpenedClawsBonus() {
|
||||
return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D);
|
||||
}
|
||||
|
||||
public double getMinHorseJumpStrength() {
|
||||
return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D);
|
||||
}
|
||||
|
||||
public double getMaxHorseJumpStrength() {
|
||||
return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D);
|
||||
}
|
||||
|
||||
/* UNARMED */
|
||||
|
||||
public boolean isSteelArmDamageCustom() { return config.getBoolean("Skills.Unarmed.SteelArmStyle.Damage_Override", false); }
|
||||
public boolean isSteelArmDamageCustom() {
|
||||
return config.getBoolean("Skills.Unarmed.SteelArmStyle.Damage_Override", false);
|
||||
}
|
||||
|
||||
public double getSteelArmOverride(int rank, double def) {
|
||||
String key = "Rank_" + rank;
|
||||
return config.getDouble("Skills.Unarmed.SteelArmStyle.Override." + key, def);
|
||||
}
|
||||
public boolean getDisarmProtected() { return config.getBoolean("Skills.Unarmed.Disarm.AntiTheft", false); }
|
||||
|
||||
public boolean getDisarmProtected() {
|
||||
return config.getBoolean("Skills.Unarmed.Disarm.AntiTheft", false);
|
||||
}
|
||||
|
||||
/* WOODCUTTING */
|
||||
public boolean isKnockOnWoodXPOrbEnabled() { return config.getBoolean("Skills.Woodcutting.TreeFeller.Knock_On_Wood.Add_XP_Orbs_To_Drops", true); }
|
||||
public boolean isKnockOnWoodXPOrbEnabled() {
|
||||
return config.getBoolean("Skills.Woodcutting.TreeFeller.Knock_On_Wood.Add_XP_Orbs_To_Drops", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
public AutoUpdateConfigLoader(String relativePath, String fileName, File dataFolder) {
|
||||
super(relativePath, fileName, dataFolder);
|
||||
}
|
||||
|
||||
public AutoUpdateConfigLoader(String fileName, File dataFolder) {
|
||||
super(fileName, dataFolder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||
super(relativePath, fileName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AutoUpdateConfigLoader(String fileName) {
|
||||
super(fileName);
|
||||
}
|
||||
|
||||
protected void saveConfig() {
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Saving changes to config file - "+fileName);
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected @NotNull FileConfiguration getInternalConfig() {
|
||||
return YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader(fileName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFile() {
|
||||
super.loadFile();
|
||||
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader(fileName));
|
||||
|
||||
Set<String> configKeys = config.getKeys(true);
|
||||
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
Set<String> oldKeys = new HashSet<>(configKeys);
|
||||
oldKeys.removeAll(internalConfigKeys);
|
||||
|
||||
Set<String> newKeys = new HashSet<>(internalConfigKeys);
|
||||
newKeys.removeAll(configKeys);
|
||||
|
||||
// Don't need a re-save if we have old keys sticking around?
|
||||
// Would be less saving, but less... correct?
|
||||
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
|
||||
needSave = true;
|
||||
}
|
||||
//
|
||||
// for (String key : oldKeys) {
|
||||
// mcMMO.p.debug("Detected potentially unused key: " + key);
|
||||
// //config.set(key, null);
|
||||
// }
|
||||
|
||||
for (String key : newKeys) {
|
||||
mcMMO.p.debug("Adding new key: " + key + " = " + internalConfig.get(key));
|
||||
config.set(key, internalConfig.get(key));
|
||||
}
|
||||
|
||||
if (needSave) {
|
||||
// Get Bukkit's version of an acceptable config with new keys, and no old keys
|
||||
String output = config.saveToString();
|
||||
|
||||
// Convert to the superior 4 space indentation
|
||||
output = output.replace(" ", " ");
|
||||
|
||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||
while (output.replaceAll("[//s]", "").startsWith("#")) {
|
||||
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||
}
|
||||
|
||||
// Read the internal config to get comments, then put them in the new one
|
||||
try {
|
||||
// Read internal
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(mcMMO.p.getResource(fileName)));
|
||||
LinkedHashMap<String, String> comments = new LinkedHashMap<>();
|
||||
StringBuilder temp = new StringBuilder();
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.contains("#")) {
|
||||
temp.append(line).append("\n");
|
||||
}
|
||||
else if (line.contains(":")) {
|
||||
line = line.substring(0, line.indexOf(":") + 1);
|
||||
if (temp.length() > 0) {
|
||||
if(comments.containsKey(line)) {
|
||||
int index = 0;
|
||||
while(comments.containsKey(line + index)) {
|
||||
index++;
|
||||
}
|
||||
|
||||
line = line + index;
|
||||
}
|
||||
|
||||
comments.put(line, temp.toString());
|
||||
temp = new StringBuilder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dump to the new one
|
||||
HashMap<String, Integer> indexed = new HashMap<>();
|
||||
for (String key : comments.keySet()) {
|
||||
String actualkey = key.substring(0, key.indexOf(":") + 1);
|
||||
|
||||
int index = 0;
|
||||
if(indexed.containsKey(actualkey)) {
|
||||
index = indexed.get(actualkey);
|
||||
}
|
||||
boolean isAtTop = !output.contains("\n" + actualkey);
|
||||
index = output.indexOf((isAtTop ? "" : "\n") + actualkey, index);
|
||||
|
||||
if (index >= 0) {
|
||||
output = output.substring(0, index) + "\n" + comments.get(key) + output.substring(isAtTop ? index : index + 1);
|
||||
indexed.put(actualkey, index + comments.get(key).length() + actualkey.length() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Save it
|
||||
if(dataFolder == null) {
|
||||
mcMMO.p.getLogger().severe("Data folder should never be null!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String saveName = fileName;
|
||||
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
|
||||
if (!mcMMO.p.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
|
||||
saveName += ".new";
|
||||
}
|
||||
|
||||
File newSaveFile = new File(dataFolder, saveName);
|
||||
FileWriter fileWriter = new FileWriter(newSaveFile.getAbsolutePath());
|
||||
BufferedWriter writer = new BufferedWriter(fileWriter);
|
||||
writer.write(output);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
|
||||
public AutoUpdateLegacyConfigLoader(String relativePath, String fileName, File dataFolder) {
|
||||
super(relativePath, fileName, dataFolder);
|
||||
}
|
||||
|
||||
public AutoUpdateLegacyConfigLoader(String fileName, File dataFolder) {
|
||||
super(fileName, dataFolder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AutoUpdateLegacyConfigLoader(String relativePath, String fileName) {
|
||||
super(relativePath, fileName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AutoUpdateLegacyConfigLoader(String fileName) {
|
||||
super(fileName);
|
||||
}
|
||||
|
||||
protected void saveConfig() {
|
||||
try {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Saving changes to config file - " + fileName);
|
||||
config.options().indent(2);
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected @NotNull FileConfiguration getInternalConfig() {
|
||||
return YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader(fileName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFile() {
|
||||
super.loadFile();
|
||||
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader(fileName));
|
||||
|
||||
Set<String> configKeys = config.getKeys(true);
|
||||
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
// keys present in current config file that are not in the template
|
||||
Set<String> oldKeys = new HashSet<>(configKeys);
|
||||
oldKeys.removeAll(internalConfigKeys);
|
||||
|
||||
if (!oldKeys.isEmpty()) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "old key(s) in \"" + fileName + "\"");
|
||||
for (String key : oldKeys) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), " old-key:" + key);
|
||||
}
|
||||
}
|
||||
|
||||
// keys present in template that are not in current file
|
||||
Set<String> newKeys = new HashSet<>(internalConfigKeys);
|
||||
newKeys.removeAll(configKeys);
|
||||
|
||||
if (!newKeys.isEmpty()) {
|
||||
needSave = true;
|
||||
}
|
||||
|
||||
for (String key : newKeys) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Adding new key: " + key + " = " + internalConfig.get(key));
|
||||
config.set(key, internalConfig.get(key));
|
||||
}
|
||||
|
||||
if (needSave) {
|
||||
// Save it
|
||||
|
||||
if (dataFolder == null) {
|
||||
mcMMO.p.getLogger().severe("Data folder should never be null!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String saveName = fileName;
|
||||
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
|
||||
if (!mcMMO.p.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
|
||||
saveName += ".new";
|
||||
}
|
||||
|
||||
File newSaveFile = new File(dataFolder, saveName);
|
||||
YamlConfiguration yamlConfiguration = config;
|
||||
yamlConfiguration.options().indent(4);
|
||||
yamlConfiguration.save(newSaveFile);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
181
src/main/java/com/gmail/nossr50/config/BukkitConfig.java
Normal file
181
src/main/java/com/gmail/nossr50/config/BukkitConfig.java
Normal file
@@ -0,0 +1,181 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BukkitConfig {
|
||||
boolean copyDefaults = true;
|
||||
protected final String fileName;
|
||||
protected final File configFile;
|
||||
protected YamlConfiguration defaultYamlConfig;
|
||||
protected YamlConfiguration config;
|
||||
protected @NotNull final File dataFolder;
|
||||
private boolean savedDefaults = false;
|
||||
|
||||
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder, boolean copyDefaults) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Initializing config: " + fileName);
|
||||
this.copyDefaults = copyDefaults;
|
||||
this.fileName = fileName;
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, fileName);
|
||||
this.defaultYamlConfig = saveDefaultConfigToDisk();
|
||||
this.config = initConfig();
|
||||
updateFile();
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Config initialized: " + fileName);
|
||||
}
|
||||
|
||||
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
|
||||
this(fileName, dataFolder, true);
|
||||
}
|
||||
|
||||
public BukkitConfig(@NotNull String fileName) {
|
||||
this(fileName, mcMMO.p.getDataFolder());
|
||||
}
|
||||
public BukkitConfig(@NotNull String fileName, boolean copyDefaults) {
|
||||
this(fileName, mcMMO.p.getDataFolder(), copyDefaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the file on the disk by copying out any new and missing defaults
|
||||
*/
|
||||
public void updateFile() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
|
||||
if(copyDefaults && !savedDefaults) {
|
||||
copyMissingDefaultsFromResource();
|
||||
savedDefaults = true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies missing keys and values from the internal resource config within the JAR
|
||||
*/
|
||||
private void copyMissingDefaultsFromResource() {
|
||||
boolean updated = false;
|
||||
for (String key : defaultYamlConfig.getKeys(true)) {
|
||||
if (!config.contains(key)) {
|
||||
config.set(key, defaultYamlConfig.get(key));
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
updateFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the config from the JAR to defaults/<fileName>
|
||||
*/
|
||||
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) {
|
||||
mcMMO.p.getLogger().severe("Unable to copy default config: " + fileName);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Save default file into defaults/<fileName>
|
||||
File defaultsFolder = new File(dataFolder, "defaults");
|
||||
if (!defaultsFolder.exists()) {
|
||||
defaultsFolder.mkdir();
|
||||
}
|
||||
File defaultFile = new File(defaultsFolder, fileName);
|
||||
Path path = defaultFile.toPath();
|
||||
Files.copy(inputStream, path, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
// Load file into YAML config
|
||||
YamlConfiguration defaultYamlConfig = new YamlConfiguration();
|
||||
defaultYamlConfig.load(defaultFile);
|
||||
return defaultYamlConfig;
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
YamlConfiguration initConfig() {
|
||||
if (!configFile.exists()) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "User config file not found, copying a default config to disk: " + fileName);
|
||||
mcMMO.p.saveResource(fileName, false);
|
||||
}
|
||||
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loading config from disk: " + fileName);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.options().indent(4);
|
||||
|
||||
try {
|
||||
config.options().parseComments(true);
|
||||
} catch (NoSuchMethodError e) {
|
||||
//e.printStackTrace();
|
||||
// mcMMO.p.getLogger().severe("Your Spigot/CraftBukkit API is out of date, update your server software!");
|
||||
}
|
||||
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
try {
|
||||
config.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected boolean validateKeys() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean noErrorsInConfig(List<String> issues) {
|
||||
for (String issue : issues) {
|
||||
mcMMO.p.getLogger().warning(issue);
|
||||
}
|
||||
|
||||
return issues.isEmpty();
|
||||
}
|
||||
|
||||
protected void validate() {
|
||||
if (validateKeys()) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "No errors found in " + fileName + "!");
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
|
||||
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
|
||||
mcMMO.p.noErrorsInConfigFiles = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void backup() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "You are using an old version of the " + fileName + " file.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
|
||||
|
||||
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
||||
|
||||
if (mcMMO.p.getResource(fileName) != null) {
|
||||
mcMMO.p.saveResource(fileName, true);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().warning("Reloading " + fileName + " with new values...");
|
||||
initConfig();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return configFile;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChatConfig extends AutoUpdateConfigLoader {
|
||||
public class ChatConfig extends BukkitConfig {
|
||||
private static ChatConfig instance;
|
||||
|
||||
private ChatConfig() {
|
||||
@@ -40,8 +40,10 @@ public class ChatConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not to use display names for players in target {@link ChatChannel}
|
||||
* Whether to use display names for players in target {@link ChatChannel}
|
||||
*
|
||||
* @param chatChannel target chat channel
|
||||
*
|
||||
* @return true if display names should be used
|
||||
*/
|
||||
public boolean useDisplayNames(@NotNull ChatChannel chatChannel) {
|
||||
|
||||
@@ -4,28 +4,26 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
|
||||
public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||
public class CoreSkillsConfig extends BukkitConfig {
|
||||
private static CoreSkillsConfig instance;
|
||||
|
||||
public CoreSkillsConfig()
|
||||
{
|
||||
public CoreSkillsConfig() {
|
||||
super("coreskills.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static CoreSkillsConfig getInstance() {
|
||||
if (instance == null)
|
||||
instance = new CoreSkillsConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public static CoreSkillsConfig getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
return new CoreSkillsConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
|
||||
@@ -37,23 +35,25 @@ public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether or not a skill is enabled
|
||||
* Whether a skill is enabled
|
||||
* Defaults true
|
||||
*
|
||||
* @param abstractSubSkill SubSkill definition to check
|
||||
*
|
||||
* @return true if subskill is enabled
|
||||
*/
|
||||
public boolean isSkillEnabled(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
return config.getBoolean(StringUtils.getCapitalized(abstractSubSkill.getPrimarySkill().toString())+"."+ abstractSubSkill.getConfigKeyName()+".Enabled", true);
|
||||
public boolean isSkillEnabled(AbstractSubSkill abstractSubSkill) {
|
||||
return config.getBoolean(StringUtils.getCapitalized(abstractSubSkill.getPrimarySkill().toString()) + "." + abstractSubSkill.getConfigKeyName() + ".Enabled", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this primary skill is enabled
|
||||
* Whether this primary skill is enabled
|
||||
*
|
||||
* @param primarySkillType target primary skill
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isPrimarySkillEnabled(PrimarySkillType primarySkillType)
|
||||
{
|
||||
return config.getBoolean(StringUtils.getCapitalized(primarySkillType.toString())+".Enabled", true);
|
||||
public boolean isPrimarySkillEnabled(PrimarySkillType primarySkillType) {
|
||||
return config.getBoolean(StringUtils.getCapitalized(primarySkillType.toString()) + ".Enabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,28 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
protected String fileName;
|
||||
@Deprecated
|
||||
public abstract class LegacyConfigLoader {
|
||||
protected final File configFile;
|
||||
protected FileConfiguration config;
|
||||
protected @NotNull final File dataFolder;
|
||||
protected final @NotNull File dataFolder;
|
||||
protected String fileName;
|
||||
protected YamlConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) {
|
||||
public LegacyConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) {
|
||||
this.fileName = fileName;
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public ConfigLoader(String fileName, @NotNull File dataFolder) {
|
||||
public LegacyConfigLoader(String fileName, @NotNull File dataFolder) {
|
||||
this.fileName = fileName;
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, fileName);
|
||||
@@ -29,7 +30,7 @@ public abstract class ConfigLoader {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ConfigLoader(String relativePath, String fileName) {
|
||||
public LegacyConfigLoader(String relativePath, String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(mcMMO.p.getDataFolder(), relativePath + File.separator + fileName);
|
||||
this.dataFolder = mcMMO.p.getDataFolder();
|
||||
@@ -37,7 +38,7 @@ public abstract class ConfigLoader {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ConfigLoader(String fileName) {
|
||||
public LegacyConfigLoader(String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(mcMMO.p.getDataFolder(), fileName);
|
||||
this.dataFolder = mcMMO.p.getDataFolder();
|
||||
@@ -46,17 +47,15 @@ public abstract class ConfigLoader {
|
||||
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
mcMMO.p.debug("Creating mcMMO " + fileName + " File...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Creating mcMMO " + fileName + " File...");
|
||||
|
||||
try {
|
||||
mcMMO.p.saveResource(fileName, false); // Normal files
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mcMMO.p.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.debug("Loading mcMMO " + fileName + " File...");
|
||||
} else {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
@@ -78,9 +77,8 @@ public abstract class ConfigLoader {
|
||||
|
||||
protected void validate() {
|
||||
if (validateKeys()) {
|
||||
mcMMO.p.debug("No errors found in " + fileName + "!");
|
||||
}
|
||||
else {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "No errors found in " + fileName + "!");
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
|
||||
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
|
||||
mcMMO.p.noErrorsInConfigFiles = false;
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
|
||||
public class PersistentDataConfig extends AutoUpdateConfigLoader {
|
||||
public class PersistentDataConfig extends BukkitConfig {
|
||||
private static PersistentDataConfig instance;
|
||||
|
||||
private PersistentDataConfig() {
|
||||
|
||||
@@ -3,35 +3,34 @@ package com.gmail.nossr50.config;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class RankConfig extends AutoUpdateConfigLoader {
|
||||
public class RankConfig extends BukkitConfig {
|
||||
private static RankConfig instance;
|
||||
|
||||
public RankConfig()
|
||||
{
|
||||
public RankConfig() {
|
||||
super("skillranks.yml");
|
||||
validate();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public static RankConfig getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
public static RankConfig getInstance() {
|
||||
if (instance == null)
|
||||
return new RankConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
List<String> reason = new ArrayList<>();
|
||||
@@ -46,12 +45,13 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank)
|
||||
{
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank) {
|
||||
String key = subSkillType.getRankConfigAddress();
|
||||
|
||||
return findRankByRootAddress(rank, key);
|
||||
@@ -59,33 +59,37 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode)
|
||||
{
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode) {
|
||||
String key = getRankAddressKey(subSkillType, rank, retroMode);
|
||||
return config.getInt(key, getInternalConfig().getInt(key));
|
||||
return config.getInt(key, defaultYamlConfig.getInt(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
*
|
||||
* @param abstractSubSkill target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank)
|
||||
{
|
||||
String key = abstractSubSkill.getPrimaryKeyName()+"."+abstractSubSkill.getConfigKeyName();
|
||||
public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) {
|
||||
String key = abstractSubSkill.getPrimaryKeyName() + "." + abstractSubSkill.getConfigKeyName();
|
||||
|
||||
return findRankByRootAddress(rank, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
* @param key root address of the subskill in the rankskills.yml file
|
||||
*
|
||||
* @param key root address of the subskill in the rankskills.yml file
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
private int findRankByRootAddress(int rank, String key) {
|
||||
@@ -125,62 +129,57 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
private void resetRankValue(@NotNull SubSkillType subSkillType, int rank, boolean retroMode) {
|
||||
String key = getRankAddressKey(subSkillType, rank, retroMode);
|
||||
int defaultValue = getInternalConfig().getInt(key);
|
||||
int defaultValue = defaultYamlConfig.getInt(key);
|
||||
config.set(key, defaultValue);
|
||||
mcMMO.p.getLogger().info(key +" SET -> " + defaultValue);
|
||||
LogUtils.debug(mcMMO.p.getLogger(), key + " SET -> " + defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for valid keys for subskill ranks
|
||||
*/
|
||||
private void checkKeys(@NotNull List<String> reasons)
|
||||
{
|
||||
private void checkKeys(@NotNull List<String> reasons) {
|
||||
HashSet<SubSkillType> badSkillSetup = new HashSet<>();
|
||||
|
||||
|
||||
//For now we will only check ranks of stuff I've overhauled
|
||||
checkConfig(reasons, badSkillSetup, true);
|
||||
checkConfig(reasons, badSkillSetup, false);
|
||||
|
||||
//Fix bad entries
|
||||
if(badSkillSetup.isEmpty())
|
||||
if (badSkillSetup.isEmpty())
|
||||
return;
|
||||
|
||||
mcMMO.p.getLogger().info("(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
|
||||
|
||||
for(SubSkillType subSkillType : badSkillSetup) {
|
||||
mcMMO.p.getLogger().info("(FIXING CONFIG) Resetting rank config settings for skill named - "+subSkillType.toString());
|
||||
for (SubSkillType subSkillType : badSkillSetup) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
|
||||
fixBadEntries(subSkillType);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkConfig(@NotNull List<String> reasons, @NotNull HashSet<SubSkillType> badSkillSetup, boolean retroMode) {
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
for (SubSkillType subSkillType : SubSkillType.values()) {
|
||||
//Keeping track of the rank requirements and making sure there are no logical errors
|
||||
int curRank = 0;
|
||||
int prevRank = 0;
|
||||
|
||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||
{
|
||||
int index = x+1;
|
||||
for (int x = 0; x < subSkillType.getNumRanks(); x++) {
|
||||
int index = x + 1;
|
||||
|
||||
if(curRank > 0)
|
||||
if (curRank > 0)
|
||||
prevRank = curRank;
|
||||
|
||||
curRank = getSubSkillUnlockLevel(subSkillType, index, retroMode);
|
||||
|
||||
//Do we really care if its below 0? Probably not
|
||||
if(curRank < 0)
|
||||
{
|
||||
reasons.add("(CONFIG ISSUE) " + subSkillType.toString() + " should not have any ranks that require a negative level!");
|
||||
if (curRank < 0) {
|
||||
reasons.add("(CONFIG ISSUE) " + subSkillType + " should not have any ranks that require a negative level!");
|
||||
badSkillSetup.add(subSkillType);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(prevRank > curRank)
|
||||
{
|
||||
if (prevRank > curRank) {
|
||||
//We're going to allow this but we're going to warn them
|
||||
mcMMO.p.getLogger().info("(CONFIG ISSUE) You have the ranks for the subskill "+ subSkillType.toString()+" set up poorly, sequential ranks should have ascending requirements");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "(CONFIG ISSUE) You have the ranks for the subskill " + subSkillType + " set up poorly, sequential ranks should have ascending requirements");
|
||||
badSkillSetup.add(subSkillType);
|
||||
}
|
||||
}
|
||||
@@ -188,9 +187,8 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
private void fixBadEntries(@NotNull SubSkillType subSkillType) {
|
||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||
{
|
||||
int index = x+1;
|
||||
for (int x = 0; x < subSkillType.getNumRanks(); x++) {
|
||||
int index = x + 1;
|
||||
|
||||
//Reset Retromode entries
|
||||
resetRankValue(subSkillType, index, true);
|
||||
@@ -198,6 +196,6 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
resetRankValue(subSkillType, index, false);
|
||||
}
|
||||
|
||||
saveConfig();
|
||||
updateFile();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,42 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
|
||||
public class SoundConfig extends AutoUpdateConfigLoader {
|
||||
public class SoundConfig extends BukkitConfig {
|
||||
private static SoundConfig instance;
|
||||
|
||||
public SoundConfig()
|
||||
{
|
||||
public SoundConfig() {
|
||||
super("sounds.yml");
|
||||
validate();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static SoundConfig getInstance() {
|
||||
if (instance == null)
|
||||
return new SoundConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public static SoundConfig getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
return new SoundConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
for(SoundType soundType : SoundType.values())
|
||||
{
|
||||
if(config.getDouble("Sounds."+soundType.toString()+".Volume") < 0)
|
||||
{
|
||||
mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for "+soundType.toString());
|
||||
for (SoundType soundType : SoundType.values()) {
|
||||
if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound volume cannot be below 0 for " + soundType);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Sounds with custom pitching don't use pitch values
|
||||
if(!soundType.usesCustomPitch())
|
||||
{
|
||||
if(config.getDouble("Sounds."+soundType.toString()+".Pitch") < 0)
|
||||
{
|
||||
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for "+soundType.toString());
|
||||
if (!soundType.usesCustomPitch()) {
|
||||
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound pitch cannot be below 0 for " + soundType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -49,23 +44,22 @@ public class SoundConfig extends AutoUpdateConfigLoader {
|
||||
return true;
|
||||
}
|
||||
|
||||
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
||||
public float getMasterVolume() {
|
||||
return (float) config.getDouble("Sounds.MasterVolume", 1.0);
|
||||
}
|
||||
|
||||
public float getVolume(SoundType soundType)
|
||||
{
|
||||
String key = "Sounds."+soundType.toString()+".Volume";
|
||||
public float getVolume(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Volume";
|
||||
return (float) config.getDouble(key);
|
||||
}
|
||||
|
||||
public float getPitch(SoundType soundType)
|
||||
{
|
||||
String key = "Sounds."+soundType.toString()+".Pitch";
|
||||
public float getPitch(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Pitch";
|
||||
return (float) config.getDouble(key);
|
||||
}
|
||||
|
||||
public boolean getIsEnabled(SoundType soundType)
|
||||
{
|
||||
String key = "Sounds."+soundType.toString()+".Enabled";
|
||||
public boolean getIsEnabled(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Enabled";
|
||||
return config.getBoolean(key, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,20 +15,28 @@ public class WorldBlacklist {
|
||||
|
||||
private final String blackListFileName = "world_blacklist.txt";
|
||||
|
||||
public WorldBlacklist(mcMMO plugin)
|
||||
{
|
||||
public WorldBlacklist(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
blacklist = new ArrayList<>();
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
public static boolean isWorldBlacklisted(World world) {
|
||||
|
||||
for (String s : blacklist) {
|
||||
if (world.getName().equalsIgnoreCase(s))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
//Make the blacklist file if it doesn't exist
|
||||
File blackListFile = new File(plugin.getDataFolder() + File.separator + blackListFileName);
|
||||
|
||||
try {
|
||||
if(!blackListFile.exists())
|
||||
if (!blackListFile.exists())
|
||||
blackListFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -48,12 +56,11 @@ public class WorldBlacklist {
|
||||
|
||||
String currentLine;
|
||||
|
||||
while((currentLine = bufferedReader.readLine()) != null)
|
||||
{
|
||||
if(currentLine.length() == 0)
|
||||
while ((currentLine = bufferedReader.readLine()) != null) {
|
||||
if (currentLine.length() == 0)
|
||||
continue;
|
||||
|
||||
if(!blacklist.contains(currentLine))
|
||||
if (!blacklist.contains(currentLine))
|
||||
blacklist.add(currentLine);
|
||||
}
|
||||
|
||||
@@ -66,11 +73,12 @@ public class WorldBlacklist {
|
||||
closeRead(fileReader);
|
||||
}
|
||||
|
||||
plugin.getLogger().info(blacklist.size()+" entries in mcMMO World Blacklist");
|
||||
if(blacklist.size() > 0)
|
||||
plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
|
||||
}
|
||||
|
||||
private void closeRead(Reader reader) {
|
||||
if(reader != null) {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
@@ -78,16 +86,4 @@ public class WorldBlacklist {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWorldBlacklisted(World world)
|
||||
{
|
||||
|
||||
for(String s : blacklist)
|
||||
{
|
||||
if(world.getName().equalsIgnoreCase(s))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.experience;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
@@ -17,7 +17,7 @@ import org.bukkit.entity.EntityType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public class ExperienceConfig extends BukkitConfig {
|
||||
private static ExperienceConfig instance;
|
||||
|
||||
private ExperienceConfig() {
|
||||
@@ -34,7 +34,8 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
protected void loadKeys() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
@@ -139,81 +140,182 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); }
|
||||
public boolean isEarlyGameBoostEnabled() {
|
||||
return config.getBoolean("EarlyGameBoost.Enabled", true);
|
||||
}
|
||||
|
||||
/*
|
||||
* FORMULA SETTINGS
|
||||
*/
|
||||
|
||||
/* EXPLOIT TOGGLES */
|
||||
public boolean isSnowExploitPrevented() { return config.getBoolean("ExploitFix.SnowGolemExcavation", true); }
|
||||
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
|
||||
public boolean isPistonCheatingPrevented() { return config.getBoolean("ExploitFix.PistonCheating", true); }
|
||||
public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
|
||||
public boolean allowUnsafeEnchantments() { return config.getBoolean("ExploitFix.UnsafeEnchantments", false); }
|
||||
public boolean isCOTWBreedingPrevented() { return config.getBoolean("ExploitFix.COTWBreeding", true); }
|
||||
public boolean isNPCInteractionPrevented() { return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true); }
|
||||
public boolean isSnowExploitPrevented() {
|
||||
return config.getBoolean("ExploitFix.SnowGolemExcavation", true);
|
||||
}
|
||||
|
||||
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
|
||||
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
|
||||
public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); }
|
||||
public boolean isEndermanEndermiteFarmingPrevented() {
|
||||
return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true);
|
||||
}
|
||||
|
||||
public boolean isPistonCheatingPrevented() {
|
||||
return config.getBoolean("ExploitFix.PistonCheating", true);
|
||||
}
|
||||
|
||||
public boolean isPistonExploitPrevented() {
|
||||
return config.getBoolean("ExploitFix.Pistons", false);
|
||||
}
|
||||
|
||||
public boolean allowUnsafeEnchantments() {
|
||||
return config.getBoolean("ExploitFix.UnsafeEnchantments", false);
|
||||
}
|
||||
|
||||
public boolean isCOTWBreedingPrevented() {
|
||||
return config.getBoolean("ExploitFix.COTWBreeding", true);
|
||||
}
|
||||
|
||||
public boolean isNPCInteractionPrevented() {
|
||||
return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true);
|
||||
}
|
||||
|
||||
public boolean isFishingExploitingPrevented() {
|
||||
return config.getBoolean("ExploitFix.Fishing", true);
|
||||
}
|
||||
|
||||
public int getFishingExploitingOptionMoveRange() {
|
||||
return config.getInt("Fishing_ExploitFix_Options.MoveRange", 3);
|
||||
}
|
||||
|
||||
public int getFishingExploitingOptionOverFishLimit() {
|
||||
return config.getInt("Fishing_ExploitFix_Options.OverFishLimit", 10);
|
||||
}
|
||||
|
||||
public boolean isAcrobaticsExploitingPrevented() {
|
||||
return config.getBoolean("ExploitFix.Acrobatics", true);
|
||||
}
|
||||
|
||||
public boolean isTreeFellerXPReduced() {
|
||||
return config.getBoolean("ExploitFix.TreeFellerReducedXP", true);
|
||||
}
|
||||
|
||||
/* Curve settings */
|
||||
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
|
||||
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
|
||||
public FormulaType getFormulaType() {
|
||||
return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve"));
|
||||
}
|
||||
|
||||
public boolean getCumulativeCurveEnabled() {
|
||||
return config.getBoolean("Experience_Formula.Cumulative_Curve", false);
|
||||
}
|
||||
|
||||
/* Curve values */
|
||||
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
|
||||
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
|
||||
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
|
||||
public double getMultiplier(FormulaType type) {
|
||||
return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier");
|
||||
}
|
||||
|
||||
public int getBase(FormulaType type) {
|
||||
return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base");
|
||||
}
|
||||
|
||||
public double getExponent(FormulaType type) {
|
||||
return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent");
|
||||
}
|
||||
|
||||
/* Global modifier */
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
|
||||
public double getExperienceGainsGlobalMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Multiplier.Global", 1.0);
|
||||
}
|
||||
|
||||
public void setExperienceGainsGlobalMultiplier(double value) {
|
||||
config.set("Experience_Formula.Multiplier.Global", value);
|
||||
}
|
||||
|
||||
/* PVP modifier */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
|
||||
public double getPlayerVersusPlayerXP() {
|
||||
return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0);
|
||||
}
|
||||
|
||||
/* Spawned Mob modifier */
|
||||
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
||||
public double getEggXpMultiplier() { return config.getDouble("Experience_Formula.Eggs.Multiplier", 0.0); }
|
||||
public double getTamedMobXpMultiplier() { return config.getDouble("Experience_Formula.Player_Tamed.Multiplier", 0.0); }
|
||||
public double getNetherPortalXpMultiplier() { return config.getDouble("Experience_Formula.Nether_Portal.Multiplier", 0.0); }
|
||||
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
|
||||
public double getSpawnedMobXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getEggXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Eggs.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getTamedMobXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Player_Tamed.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getNetherPortalXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Nether_Portal.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getBredMobXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0);
|
||||
}
|
||||
|
||||
/* Skill modifiers */
|
||||
public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
public double getFormulaSkillModifier(PrimarySkillType skill) {
|
||||
return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()));
|
||||
}
|
||||
|
||||
/* Custom XP perk */
|
||||
public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
|
||||
public double getCustomXpPerkBoost() {
|
||||
return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25);
|
||||
}
|
||||
|
||||
/* Diminished Returns */
|
||||
public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
|
||||
public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
|
||||
public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
|
||||
public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
|
||||
public float getDiminishedReturnsCap() {
|
||||
return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D);
|
||||
}
|
||||
|
||||
public boolean getDiminishedReturnsEnabled() {
|
||||
return config.getBoolean("Diminished_Returns.Enabled", false);
|
||||
}
|
||||
|
||||
public int getDiminishedReturnsThreshold(PrimarySkillType skill) {
|
||||
return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000);
|
||||
}
|
||||
|
||||
public int getDiminishedReturnsTimeInterval() {
|
||||
return config.getInt("Diminished_Returns.Time_Interval", 10);
|
||||
}
|
||||
|
||||
/* Conversion */
|
||||
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
|
||||
public double getExpModifier() {
|
||||
return config.getDouble("Conversion.Exp_Modifier", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() {
|
||||
return config.getBoolean("Experience_Values.PVP.Rewards", true);
|
||||
}
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
|
||||
public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); }
|
||||
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
public double getCombatXP(EntityType entity) {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
|
||||
}
|
||||
|
||||
public double getAnimalsXP(EntityType entity) {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP());
|
||||
}
|
||||
|
||||
public double getAnimalsXP() {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0);
|
||||
}
|
||||
|
||||
public boolean hasCombatXP(EntityType entity) {
|
||||
return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Material material)
|
||||
{
|
||||
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"))
|
||||
if (material.toString().equalsIgnoreCase("LILY_PAD"))
|
||||
return 0;
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@@ -230,8 +332,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockState blockState)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, BlockState blockState) {
|
||||
Material data = blockState.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@@ -248,8 +349,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Block block)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, Block block) {
|
||||
Material data = block.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@@ -266,8 +366,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockData data)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, BlockData data) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
@@ -281,8 +380,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
|
||||
{
|
||||
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))
|
||||
@@ -294,8 +392,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return config.contains(wildcardString);
|
||||
}
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
|
||||
{
|
||||
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))
|
||||
@@ -311,32 +408,42 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
* Experience Bar Stuff
|
||||
*/
|
||||
|
||||
public boolean isPartyExperienceBarsEnabled()
|
||||
{
|
||||
public boolean isPartyExperienceBarsEnabled() {
|
||||
return config.getBoolean("Experience_Bars.Update.Party", true);
|
||||
}
|
||||
|
||||
public boolean isPassiveGainsExperienceBarsEnabled()
|
||||
{
|
||||
public boolean isPassiveGainsExperienceBarsEnabled() {
|
||||
return config.getBoolean("Experience_Bars.Update.Passive", true);
|
||||
}
|
||||
|
||||
public boolean getDoExperienceBarsAlwaysUpdateTitle()
|
||||
{
|
||||
public boolean getDoExperienceBarsAlwaysUpdateTitle() {
|
||||
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
|
||||
}
|
||||
|
||||
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
|
||||
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
|
||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
|
||||
public boolean getAddExtraDetails() {
|
||||
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);
|
||||
}
|
||||
public boolean useCombatHPCeiling() {
|
||||
return config.getBoolean("ExploitFix.Combat.XPCeiling.Enabled", true);
|
||||
}
|
||||
|
||||
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
|
||||
{
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color");
|
||||
public int getCombatHPCeiling() {
|
||||
return config.getInt("ExploitFix.Combat.XPCeiling.HP_Modifier_Limit", 100);
|
||||
}
|
||||
|
||||
for(BarColor barColor : BarColor.values())
|
||||
{
|
||||
if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
public boolean isExperienceBarsEnabled() {
|
||||
return config.getBoolean("Experience_Bars.Enable", true);
|
||||
}
|
||||
|
||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) {
|
||||
return config.getBoolean("Experience_Bars." + StringUtils.getCapitalized(primarySkillType.toString()) + ".Enable", true);
|
||||
}
|
||||
|
||||
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars." + StringUtils.getCapitalized(primarySkillType.toString()) + ".Color");
|
||||
|
||||
for (BarColor barColor : BarColor.values()) {
|
||||
if (barColor.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
return barColor;
|
||||
}
|
||||
|
||||
@@ -344,13 +451,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return BarColor.WHITE;
|
||||
}
|
||||
|
||||
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
|
||||
{
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
|
||||
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars." + StringUtils.getCapitalized(primarySkillType.toString()) + ".BarStyle");
|
||||
|
||||
for(BarStyle barStyle : BarStyle.values())
|
||||
{
|
||||
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
for (BarStyle barStyle : BarStyle.values()) {
|
||||
if (barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
return barStyle;
|
||||
}
|
||||
|
||||
@@ -359,29 +464,51 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Acrobatics */
|
||||
public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
|
||||
public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); }
|
||||
public int getDodgeXPModifier() {
|
||||
return config.getInt("Experience_Values.Acrobatics.Dodge", 120);
|
||||
}
|
||||
|
||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||
public int getRollXPModifier() {
|
||||
return config.getInt("Experience_Values.Acrobatics.Roll", 80);
|
||||
}
|
||||
|
||||
public int getFallXPModifier() {
|
||||
return config.getInt("Experience_Values.Acrobatics.Fall", 120);
|
||||
}
|
||||
|
||||
public double getFeatherFallXPModifier() {
|
||||
return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0);
|
||||
}
|
||||
|
||||
/* Alchemy */
|
||||
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
|
||||
public double getPotionXP(PotionStage stage) {
|
||||
return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D);
|
||||
}
|
||||
|
||||
/* Archery */
|
||||
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); }
|
||||
public double getArcheryDistanceMultiplier() {
|
||||
return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025);
|
||||
}
|
||||
|
||||
public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); }
|
||||
public int getFishingShakeXP() {
|
||||
return config.getInt("Experience_Values.Fishing.Shake", 50);
|
||||
}
|
||||
|
||||
/* Repair */
|
||||
public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); }
|
||||
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||
public double getRepairXPBase() {
|
||||
return config.getDouble("Experience_Values.Repair.Base", 1000.0);
|
||||
}
|
||||
|
||||
public double getRepairXP(MaterialType repairMaterialType) {
|
||||
return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString()));
|
||||
}
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXP(EntityType type)
|
||||
{
|
||||
public int getTamingXP(EntityType type) {
|
||||
return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
|
||||
}
|
||||
|
||||
public boolean preventStoneLavaFarming() { return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);}
|
||||
public boolean preventStoneLavaFarming() {
|
||||
return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ArmorConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomArmor(new CustomArmorConfig(fileName));
|
||||
modManager.registerCustomArmor(new CustomArmorLegacyConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class BlockConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomBlocks(new CustomBlockConfig(fileName));
|
||||
modManager.registerCustomBlocks(new CustomBlockLegacyConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.LegacyConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -13,17 +13,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
public class CustomArmorLegacyConfig extends LegacyConfigLoader {
|
||||
public List<Material> customBoots = new ArrayList<>();
|
||||
public List<Material> customChestplates = new ArrayList<>();
|
||||
public List<Material> customHelmets = new ArrayList<>();
|
||||
public List<Material> customLeggings = new ArrayList<>();
|
||||
public List<Repairable> repairables = new ArrayList<>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customBoots = new ArrayList<>();
|
||||
public List<Material> customChestplates = new ArrayList<>();
|
||||
public List<Material> customHelmets = new ArrayList<>();
|
||||
public List<Material> customLeggings = new ArrayList<>();
|
||||
|
||||
public List<Repairable> repairables = new ArrayList<>();
|
||||
|
||||
protected CustomArmorConfig(String fileName) {
|
||||
protected CustomArmorLegacyConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
loadKeys();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.LegacyConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Material;
|
||||
@@ -11,20 +11,18 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
public class CustomBlockLegacyConfig extends LegacyConfigLoader {
|
||||
public List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
public List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
public List<Material> customMiningBlocks = new ArrayList<>();
|
||||
public List<Material> customOres = new ArrayList<>();
|
||||
public List<Material> customLogs = new ArrayList<>();
|
||||
public List<Material> customLeaves = new ArrayList<>();
|
||||
public List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
public List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
public List<Material> customMiningBlocks = new ArrayList<>();
|
||||
public List<Material> customOres = new ArrayList<>();
|
||||
public List<Material> customLogs = new ArrayList<>();
|
||||
public List<Material> customLeaves = new ArrayList<>();
|
||||
public List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
|
||||
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
|
||||
protected CustomBlockConfig(String fileName) {
|
||||
protected CustomBlockLegacyConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
loadKeys();
|
||||
}
|
||||
@@ -85,12 +83,10 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterial);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
} else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockMaterial);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
customLeaves.add(blockMaterial);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.LegacyConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.apache.commons.lang.ClassUtils;
|
||||
@@ -9,11 +9,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CustomEntityConfig extends ConfigLoader {
|
||||
public class CustomEntityLegacyConfig extends LegacyConfigLoader {
|
||||
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>();
|
||||
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
|
||||
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
|
||||
|
||||
protected CustomEntityConfig(String fileName) {
|
||||
protected CustomEntityLegacyConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
loadKeys();
|
||||
}
|
||||
@@ -31,8 +31,7 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
|
||||
try {
|
||||
clazz = ClassUtils.getClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
mcMMO.p.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
|
||||
mcMMO.p.getLogger().warning("This custom entity may not function properly.");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.LegacyConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
@@ -15,21 +15,18 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
public class CustomToolLegacyConfig extends LegacyConfigLoader {
|
||||
public List<Material> customAxes = new ArrayList<>();
|
||||
public List<Material> customBows = new ArrayList<>();
|
||||
public List<Material> customHoes = new ArrayList<>();
|
||||
public List<Material> customPickaxes = new ArrayList<>();
|
||||
public List<Material> customShovels = new ArrayList<>();
|
||||
public List<Material> customSwords = new ArrayList<>();
|
||||
public HashMap<Material, CustomTool> customToolMap = new HashMap<>();
|
||||
public List<Repairable> repairables = new ArrayList<>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customAxes = new ArrayList<>();
|
||||
public List<Material> customBows = new ArrayList<>();
|
||||
public List<Material> customHoes = new ArrayList<>();
|
||||
public List<Material> customPickaxes = new ArrayList<>();
|
||||
public List<Material> customShovels = new ArrayList<>();
|
||||
public List<Material> customSwords = new ArrayList<>();
|
||||
|
||||
public HashMap<Material, CustomTool> customToolMap = new HashMap<>();
|
||||
|
||||
public List<Repairable> repairables = new ArrayList<>();
|
||||
|
||||
protected CustomToolConfig(String fileName) {
|
||||
protected CustomToolLegacyConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
loadKeys();
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class EntityConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomEntities(new CustomEntityConfig(fileName));
|
||||
modManager.registerCustomEntities(new CustomEntityLegacyConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ToolConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomTools(new CustomToolConfig(fileName));
|
||||
modManager.registerCustomTools(new CustomToolLegacyConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ItemWeightConfig extends ConfigLoader {
|
||||
public class ItemWeightConfig extends BukkitConfig {
|
||||
private static ItemWeightConfig instance;
|
||||
|
||||
private ItemWeightConfig() {
|
||||
@@ -40,5 +40,6 @@ public class ItemWeightConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
protected void loadKeys() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.gmail.nossr50.config.skills.alchemy;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
@@ -15,7 +16,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PotionConfig extends ConfigLoader {
|
||||
public class PotionConfig extends LegacyConfigLoader {
|
||||
private static PotionConfig instance;
|
||||
|
||||
private final List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<>();
|
||||
@@ -95,13 +96,12 @@ public class PotionConfig extends ConfigLoader {
|
||||
if (potion != null) {
|
||||
potionMap.put(potionName, potion);
|
||||
pass++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,13 +114,13 @@ public class PotionConfig extends ConfigLoader {
|
||||
*/
|
||||
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
String name = potion_section.getString("Name");
|
||||
if (name != null) {
|
||||
name = ChatColor.translateAlternateColorCodes('&', name);
|
||||
}
|
||||
|
||||
|
||||
PotionData data;
|
||||
if (!potion_section.contains("PotionData")) { // Backwards config compatability
|
||||
short dataValue = Short.parseShort(potion_section.getName());
|
||||
@@ -130,7 +130,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
|
||||
data = new PotionData(PotionType.valueOf(potionData.getString("PotionType", "WATER")), potionData.getBoolean("Extended", false), potionData.getBoolean("Upgraded", false));
|
||||
}
|
||||
|
||||
|
||||
Material material = Material.POTION;
|
||||
String mat = potion_section.getString("Material", null);
|
||||
if (mat != null) {
|
||||
@@ -155,18 +155,16 @@ public class PotionConfig extends ConfigLoader {
|
||||
|
||||
if (type != null) {
|
||||
effects.add(new PotionEffect(type, duration, amplifier));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse effect for potion " + name + ": " + effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Color color;
|
||||
if (potion_section.contains("Color")) {
|
||||
color = Color.fromRGB(potion_section.getInt("Color"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
color = this.generateColor(effects);
|
||||
}
|
||||
|
||||
@@ -176,16 +174,14 @@ public class PotionConfig extends ConfigLoader {
|
||||
ItemStack ingredient = loadIngredient(child);
|
||||
if (ingredient != null) {
|
||||
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new AlchemyPotion(material, data, name, lore, effects, color, children);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
||||
return null;
|
||||
}
|
||||
@@ -243,7 +239,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
public AlchemyPotion getPotion(String name) {
|
||||
return potionMap.get(name);
|
||||
}
|
||||
|
||||
|
||||
public AlchemyPotion getPotion(ItemStack item) {
|
||||
for (AlchemyPotion potion : potionMap.values()) {
|
||||
if (potion.isSimilar(item)) {
|
||||
@@ -252,7 +248,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Color generateColor(List<PotionEffect> effects) {
|
||||
if (effects != null && !effects.isEmpty()) {
|
||||
List<Color> colors = new ArrayList<>();
|
||||
@@ -270,7 +266,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Color calculateAverageColor(List<Color> colors) {
|
||||
int red = 0;
|
||||
int green = 0;
|
||||
@@ -280,7 +276,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
green += color.getGreen();
|
||||
blue += color.getBlue();
|
||||
}
|
||||
return Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size());
|
||||
return Color.fromRGB(red / colors.size(), green / colors.size(), blue / colors.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
package com.gmail.nossr50.config.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private List<Repairable> repairables;
|
||||
public class RepairConfig extends BukkitConfig {
|
||||
private final HashSet<String> notSupported;
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(String fileName) {
|
||||
super(fileName);
|
||||
public RepairConfig(String fileName, boolean copyDefaults) {
|
||||
super(fileName, copyDefaults);
|
||||
notSupported = new HashSet<>();
|
||||
loadKeys();
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class RepairConfig extends ConfigLoader {
|
||||
Material itemMaterial = Material.matchMaterial(key);
|
||||
|
||||
if (itemMaterial == null) {
|
||||
//mcMMO.p.getLogger().info("No support for repair item "+key+ " in this version of Minecraft, skipping.");
|
||||
//LogUtils.debug(mcMMO.p.getLogger(), "No support for repair item "+key+ " in this version of Minecraft, skipping.");
|
||||
notSupported.add(key); //Collect names of unsupported items
|
||||
continue;
|
||||
}
|
||||
@@ -62,33 +63,25 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isWoodTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(repairItem)) {
|
||||
} else if (ItemUtils.isStoneTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.STONE;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(repairItem)) {
|
||||
} else if (ItemUtils.isStringTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.STRING;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(repairItem)) {
|
||||
} else if (ItemUtils.isLeatherArmor(repairItem)) {
|
||||
repairMaterialType = MaterialType.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
||||
} else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.IRON;
|
||||
}
|
||||
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
||||
} else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.GOLD;
|
||||
}
|
||||
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
||||
} else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.DIAMOND;
|
||||
} else if (ItemUtils.isNetheriteArmor(repairItem) || ItemUtils.isNetheriteTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.NETHERITE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
}
|
||||
}
|
||||
@@ -122,16 +115,13 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isMinecraftTool(repairItem)) {
|
||||
repairItemType = ItemType.TOOL;
|
||||
}
|
||||
else if (ItemUtils.isArmor(repairItem)) {
|
||||
} else if (ItemUtils.isArmor(repairItem)) {
|
||||
repairItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
repairItemType = ItemType.valueOf(repairItemTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
}
|
||||
}
|
||||
@@ -146,7 +136,7 @@ public class RepairConfig extends ConfigLoader {
|
||||
// Minimum Quantity
|
||||
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity");
|
||||
|
||||
if(minimumQuantity == 0) {
|
||||
if (minimumQuantity == 0) {
|
||||
minimumQuantity = -1;
|
||||
}
|
||||
|
||||
@@ -158,21 +148,21 @@ public class RepairConfig extends ConfigLoader {
|
||||
//Report unsupported
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
if(notSupported.size() > 0) {
|
||||
if (notSupported.size() > 0) {
|
||||
stringBuilder.append("mcMMO found the following materials in the Repair config that are not supported by the version of Minecraft running on this server: ");
|
||||
|
||||
for (Iterator<String> iterator = notSupported.iterator(); iterator.hasNext(); ) {
|
||||
String unsupportedMaterial = iterator.next();
|
||||
|
||||
if(!iterator.hasNext()) {
|
||||
if (!iterator.hasNext()) {
|
||||
stringBuilder.append(unsupportedMaterial);
|
||||
} else {
|
||||
stringBuilder.append(unsupportedMaterial).append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info(stringBuilder.toString());
|
||||
mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), stringBuilder.toString());
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Items using materials that are not supported will simply be skipped.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package com.gmail.nossr50.config.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.FixSpellingNetheriteUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private final List<Repairable> repairables = new ArrayList<>();
|
||||
public static final String REPAIR_VANILLA_YML = "repair.vanilla.yml";
|
||||
private static final Collection<Repairable> repairables = new HashSet<>();
|
||||
|
||||
public RepairConfigManager(mcMMO plugin) {
|
||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("repair.vanilla.yml", false);
|
||||
}
|
||||
RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML, true);
|
||||
repairables.addAll(mainRepairConfig.getLoadedRepairables());
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if(fileName.equals(REPAIR_VANILLA_YML))
|
||||
continue;
|
||||
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
@@ -33,19 +33,12 @@ public class RepairConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_SPELLING_NETHERITE_REPAIR)) {
|
||||
//Check spelling mistakes (early versions of 1.16 support had Netherite misspelled)
|
||||
plugin.getLogger().info("Checking for certain invalid material names in Repair config...");
|
||||
FixSpellingNetheriteUtil.processFileCheck(mcMMO.p, fileName, UpgradeType.FIX_SPELLING_NETHERITE_REPAIR);
|
||||
}
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(fileName);
|
||||
RepairConfig rConfig = new RepairConfig(fileName, false);
|
||||
repairables.addAll(rConfig.getLoadedRepairables());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
public Collection<Repairable> getLoadedRepairables() {
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
@@ -8,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -15,20 +16,21 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SalvageConfig extends ConfigLoader {
|
||||
private List<Salvageable> salvageables;
|
||||
public class SalvageConfig extends BukkitConfig {
|
||||
private final HashSet<String> notSupported;
|
||||
private Set<Salvageable> salvageables;
|
||||
|
||||
public SalvageConfig(String fileName) {
|
||||
super(fileName);
|
||||
public SalvageConfig(String fileName, boolean copyDefaults) {
|
||||
super(fileName, copyDefaults);
|
||||
notSupported = new HashSet<>();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
salvageables = new ArrayList<>();
|
||||
salvageables = new HashSet<>();
|
||||
|
||||
if (!config.isConfigurationSection("Salvageables")) {
|
||||
mcMMO.p.getLogger().severe("Could not find Salvageables section in " + fileName);
|
||||
@@ -40,18 +42,18 @@ public class SalvageConfig extends ConfigLoader {
|
||||
|
||||
//Original version of 1.16 support had maximum quantities that were bad, this fixes it
|
||||
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
|
||||
mcMMO.p.getLogger().info("Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
|
||||
for(String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
|
||||
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
|
||||
mcMMO.p.getLogger().log(Level.INFO, "Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
|
||||
for (String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
|
||||
config.set("Salvageables." + namespacedkey.toUpperCase() + ".MaximumQuantity", 4); //TODO: Doesn't make sense to default to 4 for everything
|
||||
}
|
||||
|
||||
try {
|
||||
config.save(getFile());
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES);
|
||||
mcMMO.p.getLogger().info("Fixed incorrect Salvage quantities for Netherite gear!");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Fixed incorrect Salvage quantities for Netherite gear!");
|
||||
} catch (IOException e) {
|
||||
mcMMO.p.getLogger().info("Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -78,33 +80,25 @@ public class SalvageConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isWoodTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(salvageItem)) {
|
||||
} else if (ItemUtils.isStoneTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.STONE;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(salvageItem)) {
|
||||
} else if (ItemUtils.isStringTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.STRING;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
||||
} else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
||||
} else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.IRON;
|
||||
}
|
||||
else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
||||
} else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.GOLD;
|
||||
}
|
||||
else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
||||
} else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.DIAMOND;
|
||||
} else if (ItemUtils.isNetheriteTool(salvageItem) || ItemUtils.isNetheriteArmor(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.NETHERITE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||
}
|
||||
}
|
||||
@@ -130,16 +124,13 @@ public class SalvageConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isMinecraftTool(salvageItem)) {
|
||||
salvageItemType = ItemType.TOOL;
|
||||
}
|
||||
else if (ItemUtils.isArmor(salvageItem)) {
|
||||
} else if (ItemUtils.isArmor(salvageItem)) {
|
||||
salvageItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
|
||||
}
|
||||
}
|
||||
@@ -176,26 +167,26 @@ public class SalvageConfig extends ConfigLoader {
|
||||
//Report unsupported
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
if(notSupported.size() > 0) {
|
||||
if (notSupported.size() > 0) {
|
||||
stringBuilder.append("mcMMO found the following materials in the Salvage config that are not supported by the version of Minecraft running on this server: ");
|
||||
|
||||
for (Iterator<String> iterator = notSupported.iterator(); iterator.hasNext(); ) {
|
||||
String unsupportedMaterial = iterator.next();
|
||||
|
||||
if(!iterator.hasNext()) {
|
||||
if (!iterator.hasNext()) {
|
||||
stringBuilder.append(unsupportedMaterial);
|
||||
} else {
|
||||
stringBuilder.append(unsupportedMaterial).append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info(stringBuilder.toString());
|
||||
mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), stringBuilder.toString());
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Items using materials that are not supported will simply be skipped.");
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables == null ? new ArrayList<>() : salvageables;
|
||||
protected Collection<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables == null ? new HashSet<>() : salvageables;
|
||||
}
|
||||
|
||||
private boolean noErrorsInSalvageable(List<String> issues) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.util.FixSpellingNetheriteUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -11,18 +9,21 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SalvageConfigManager {
|
||||
private final List<Salvageable> salvageables = new ArrayList<>();
|
||||
public static final String SALVAGE_VANILLA_YML = "salvage.vanilla.yml";
|
||||
private final List<Salvageable> salvageables = new ArrayList<>(); //TODO: Collision checking, make the list a set
|
||||
|
||||
|
||||
public SalvageConfigManager(mcMMO plugin) {
|
||||
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "salvage.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("salvage.vanilla.yml", false);
|
||||
}
|
||||
SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML, true);
|
||||
salvageables.addAll(mainSalvageConfig.getLoadedSalvageables());
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if(fileName.equals(SALVAGE_VANILLA_YML))
|
||||
continue;
|
||||
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
@@ -33,20 +34,12 @@ public class SalvageConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_SPELLING_NETHERITE_SALVAGE)) {
|
||||
//Check spelling mistakes (early versions of 1.16 support had Netherite misspelled)
|
||||
plugin.getLogger().info("Checking for certain invalid material names in Salvage config...");
|
||||
FixSpellingNetheriteUtil.processFileCheck(mcMMO.p, fileName, UpgradeType.FIX_SPELLING_NETHERITE_SALVAGE);
|
||||
}
|
||||
|
||||
|
||||
SalvageConfig salvageConfig = new SalvageConfig(fileName);
|
||||
SalvageConfig salvageConfig = new SalvageConfig(fileName, false);
|
||||
salvageables.addAll(salvageConfig.getLoadedSalvageables());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables;
|
||||
return new ArrayList<>(salvageables);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.treasure.*;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -18,17 +19,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FishingTreasureConfig extends ConfigLoader {
|
||||
public class FishingTreasureConfig extends BukkitConfig {
|
||||
|
||||
public static final String FILENAME = "fishing_treasures.yml";
|
||||
private static FishingTreasureConfig instance;
|
||||
|
||||
public @NotNull HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
|
||||
public @NotNull HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
|
||||
public @NotNull HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
|
||||
public @NotNull HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
|
||||
public @NotNull HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
|
||||
|
||||
private FishingTreasureConfig() {
|
||||
super(FILENAME);
|
||||
super(FILENAME, false);
|
||||
loadKeys();
|
||||
validate();
|
||||
}
|
||||
@@ -45,33 +46,39 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
List<String> reason = new ArrayList<>();
|
||||
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
|
||||
double totalEnchantDropRate = 0;
|
||||
double totalItemDropRate = 0;
|
||||
ConfigurationSection enchantment_drop_rates = config.getConfigurationSection("Enchantment_Drop_Rates");
|
||||
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
|
||||
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity.toString());
|
||||
if(enchantment_drop_rates != null) {
|
||||
for (String tier : enchantment_drop_rates.getKeys(false)) {
|
||||
double totalEnchantDropRate = 0;
|
||||
double totalItemDropRate = 0;
|
||||
|
||||
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) {
|
||||
reason.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
|
||||
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity);
|
||||
|
||||
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) {
|
||||
reason.add("The enchant drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
|
||||
}
|
||||
|
||||
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
|
||||
reason.add("The item drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
|
||||
}
|
||||
|
||||
totalEnchantDropRate += enchantDropRate;
|
||||
totalItemDropRate += itemDropRate;
|
||||
}
|
||||
|
||||
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
|
||||
reason.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
||||
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
||||
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
}
|
||||
|
||||
totalEnchantDropRate += enchantDropRate;
|
||||
totalItemDropRate += itemDropRate;
|
||||
}
|
||||
|
||||
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
||||
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
}
|
||||
|
||||
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
||||
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
||||
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Your fishing treasures config is empty, is this intentional? Delete it to regenerate.");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
@@ -89,7 +96,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
|
||||
for (EntityType entity : EntityType.values()) {
|
||||
if (entity.isAlive()) {
|
||||
loadTreasures("Shake." + entity.toString());
|
||||
loadTreasures("Shake." + entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +182,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
if (isFishing) {
|
||||
String rarityStr = config.getString(type + "." + treasureName + ".Rarity");
|
||||
|
||||
if(rarityStr != null) {
|
||||
if (rarityStr != null) {
|
||||
rarity = Rarity.getRarity(rarityStr);
|
||||
} else {
|
||||
mcMMO.p.getLogger().severe("Please edit your config and add a Rarity definition for - " + treasureName);
|
||||
@@ -192,7 +199,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
|
||||
String customName = null;
|
||||
|
||||
if(hasCustomName(type, treasureName)) {
|
||||
if (hasCustomName(type, treasureName)) {
|
||||
customName = config.getString(type + "." + treasureName + ".Custom_Name");
|
||||
}
|
||||
|
||||
@@ -204,7 +211,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
item = new ItemStack(mat, amount, data);
|
||||
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
if(itemMeta == null) {
|
||||
if (itemMeta == null) {
|
||||
mcMMO.p.getLogger().severe("Item meta when adding potion to fishing treasure was null, contact the mcMMO devs!");
|
||||
continue;
|
||||
}
|
||||
@@ -232,7 +239,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
} else if(material == Material.ENCHANTED_BOOK) {
|
||||
} else if (material == Material.ENCHANTED_BOOK) {
|
||||
//If any whitelisted enchants exist we use whitelist-based matching
|
||||
item = new ItemStack(material, 1);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
@@ -276,7 +283,6 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (noErrorsInConfig(reason)) {
|
||||
if (isFishing) {
|
||||
addFishingTreasure(rarity, new FishingTreasure(item, xp));
|
||||
@@ -307,26 +313,27 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
/**
|
||||
* Matches enchantments on a list (user provided string) to known enchantments in the Spigot API
|
||||
* Any matches are added to the passed set
|
||||
*
|
||||
* @param enchantListStr the users string list of enchantments
|
||||
* @param permissiveList the permissive list of enchantments
|
||||
*/
|
||||
private void matchAndFillSet(@NotNull List<String> enchantListStr, @NotNull Set<Enchantment> permissiveList) {
|
||||
if(enchantListStr.isEmpty()) {
|
||||
if (enchantListStr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(String str : enchantListStr) {
|
||||
for (String str : enchantListStr) {
|
||||
boolean foundMatch = false;
|
||||
for(Enchantment enchantment : Enchantment.values()) {
|
||||
if(enchantment.getKey().getKey().equalsIgnoreCase(str)) {
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
if (enchantment.getKey().getKey().equalsIgnoreCase(str)) {
|
||||
permissiveList.add(enchantment);
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundMatch) {
|
||||
mcMMO.p.getLogger().info("[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: "+str);
|
||||
if (!foundMatch) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +351,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
for (String enchantmentName : enchantmentSection.getKeys(false)) {
|
||||
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
|
||||
int level = config.getInt("Enchantments_Rarity." + rarity + "." + enchantmentName);
|
||||
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
||||
|
||||
if (enchantment == null) {
|
||||
@@ -374,10 +381,10 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
public double getItemDropRate(int tier, @NotNull Rarity rarity) {
|
||||
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
||||
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity);
|
||||
}
|
||||
|
||||
public double getEnchantmentDropRate(int tier, @NotNull Rarity rarity) {
|
||||
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
||||
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -20,7 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TreasureConfig extends ConfigLoader {
|
||||
public class TreasureConfig extends BukkitConfig {
|
||||
|
||||
public static final String FILENAME = "treasures.yml";
|
||||
public static final String LEVEL_REQUIREMENT_RETRO_MODE = ".Level_Requirement.Retro_Mode";
|
||||
@@ -32,10 +33,10 @@ public class TreasureConfig extends ConfigLoader {
|
||||
private static TreasureConfig instance;
|
||||
|
||||
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
|
||||
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
|
||||
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
|
||||
|
||||
private TreasureConfig() {
|
||||
super(FILENAME);
|
||||
super(FILENAME, false);
|
||||
loadKeys();
|
||||
validate();
|
||||
}
|
||||
@@ -115,32 +116,32 @@ public class TreasureConfig extends ConfigLoader {
|
||||
DropLevelKeyConversionType conversionType;
|
||||
|
||||
//Check for legacy drop level values and convert
|
||||
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.LEGACY) != -1) {
|
||||
if (getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.LEGACY) != -1) {
|
||||
//Legacy Drop level, needs to be converted
|
||||
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.LEGACY);
|
||||
}
|
||||
|
||||
//Check for a bad key that was accidentally shipped out to some users
|
||||
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD) != -1) {
|
||||
if (getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD) != -1) {
|
||||
//Partially converted to the new system, I had a dyslexic moment so some configs have this
|
||||
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD);
|
||||
}
|
||||
|
||||
//Check for a bad key that was accidentally shipped out to some users
|
||||
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO) != -1) {
|
||||
if (getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO) != -1) {
|
||||
//Partially converted to the new system, I had a dyslexic moment so some configs have this
|
||||
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO);
|
||||
}
|
||||
|
||||
int dropLevel = -1;
|
||||
|
||||
if(mcMMO.isRetroModeEnabled()) {
|
||||
if (mcMMO.isRetroModeEnabled()) {
|
||||
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, -1);
|
||||
} else {
|
||||
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, -1);
|
||||
}
|
||||
|
||||
if(dropLevel == -1) {
|
||||
if (dropLevel == -1) {
|
||||
mcMMO.p.getLogger().severe("Could not find a Level_Requirement entry for treasure " + treasureName);
|
||||
mcMMO.p.getLogger().severe("Skipping treasure");
|
||||
continue;
|
||||
@@ -258,7 +259,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
//Apply our fix
|
||||
if(shouldWeUpdateFile) {
|
||||
if (shouldWeUpdateFile) {
|
||||
try {
|
||||
config.save(getFile());
|
||||
} catch (IOException e) {
|
||||
@@ -272,18 +273,18 @@ public class TreasureConfig extends ConfigLoader {
|
||||
case LEGACY:
|
||||
int legacyDropLevel = getWrongKeyValue(type, treasureName, conversionType); //Legacy only had one value, Retro Mode didn't have a setting
|
||||
//Config needs to be updated to be more specific
|
||||
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
|
||||
config.set(type + "." + treasureName + LEGACY_DROP_LEVEL, null); //Remove legacy entry
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, legacyDropLevel * 10); //Multiply by 10 for Retro
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, legacyDropLevel);
|
||||
shouldWeUpdateTheFile = true;
|
||||
break;
|
||||
case WRONG_KEY_STANDARD:
|
||||
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
|
||||
int wrongKeyValueStandard = getWrongKeyValue(type, treasureName, conversionType);
|
||||
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
|
||||
|
||||
if(wrongKeyValueStandard != -1) {
|
||||
if (wrongKeyValueStandard != -1) {
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, wrongKeyValueStandard);
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueStandard * 10); //Multiply by 10 for Retro
|
||||
}
|
||||
@@ -291,11 +292,11 @@ public class TreasureConfig extends ConfigLoader {
|
||||
shouldWeUpdateTheFile = true;
|
||||
break;
|
||||
case WRONG_KEY_RETRO:
|
||||
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
|
||||
int wrongKeyValueRetro = getWrongKeyValue(type, treasureName, conversionType);
|
||||
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
|
||||
|
||||
if(wrongKeyValueRetro != -1) {
|
||||
if (wrongKeyValueRetro != -1) {
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueRetro);
|
||||
}
|
||||
|
||||
@@ -306,22 +307,12 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
private int getWrongKeyValue(String type, String treasureName, DropLevelKeyConversionType dropLevelKeyConversionType) {
|
||||
switch (dropLevelKeyConversionType) {
|
||||
case LEGACY:
|
||||
return config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
|
||||
case WRONG_KEY_STANDARD:
|
||||
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_STANDARD, -1);
|
||||
case WRONG_KEY_RETRO:
|
||||
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_RETRO, -1);
|
||||
}
|
||||
return switch (dropLevelKeyConversionType) {
|
||||
case LEGACY -> config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
|
||||
case WRONG_KEY_STANDARD -> config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_STANDARD, -1);
|
||||
case WRONG_KEY_RETRO -> config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_RETRO, -1);
|
||||
};
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private enum DropLevelKeyConversionType {
|
||||
LEGACY,
|
||||
WRONG_KEY_STANDARD,
|
||||
WRONG_KEY_RETRO
|
||||
}
|
||||
|
||||
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
|
||||
@@ -329,4 +320,10 @@ public class TreasureConfig extends ConfigLoader {
|
||||
hylianMap.put(dropper, new ArrayList<>());
|
||||
hylianMap.get(dropper).add(treasure);
|
||||
}
|
||||
|
||||
private enum DropLevelKeyConversionType {
|
||||
LEGACY,
|
||||
WRONG_KEY_STANDARD,
|
||||
WRONG_KEY_RETRO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
|
||||
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -16,14 +17,14 @@ public class DatabaseManagerFactory {
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.debug("Could not create custom database manager");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Could not create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
mcMMO.p.debug("Failed to create custom database manager");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Failed to create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
mcMMO.p.debug("Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||
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);
|
||||
@@ -62,16 +63,16 @@ public class DatabaseManagerFactory {
|
||||
public static @Nullable DatabaseManager createDatabaseManager(@NotNull DatabaseType type, @NotNull String userFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
|
||||
switch (type) {
|
||||
case FLATFILE:
|
||||
mcMMO.p.getLogger().info("Using FlatFile Database");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Using FlatFile Database");
|
||||
return new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
|
||||
|
||||
case SQL:
|
||||
mcMMO.p.getLogger().info("Using SQL Database");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Using SQL Database");
|
||||
return new SQLDatabaseManager();
|
||||
|
||||
case CUSTOM:
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Attempting to use Custom Database");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Attempting to use Custom Database");
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.player.UniqueDataType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -25,7 +26,7 @@ import java.util.logging.Logger;
|
||||
public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
public static final String IGNORED = "IGNORED";
|
||||
public static final String LEGACY_INVALID_OLD_USERNAME = "_INVALID_OLD_USERNAME_'";
|
||||
private final @NotNull EnumMap<PrimarySkillType, List<PlayerStat>> playerStatHash = new EnumMap<PrimarySkillType, List<PlayerStat>>(PrimarySkillType.class);
|
||||
private final @NotNull EnumMap<PrimarySkillType, List<PlayerStat>> playerStatHash = new EnumMap<>(PrimarySkillType.class);
|
||||
private final @NotNull List<PlayerStat> powerLevels = new ArrayList<>();
|
||||
private long lastUpdate = 0;
|
||||
private final @NotNull String usersFilePath;
|
||||
@@ -115,12 +116,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
public int purgePowerlessUsers() {
|
||||
int purgedUsers = 0;
|
||||
|
||||
logger.info("Purging powerless users...");
|
||||
LogUtils.debug(logger, "Purging powerless users...");
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
|
||||
// This code is O(n) instead of O(n²)
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
@@ -184,7 +184,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
int removedPlayers = 0;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
logger.info("Purging old users...");
|
||||
LogUtils.debug(logger, "Purging old users...");
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
@@ -198,7 +198,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
String name = character[USERNAME_INDEX];
|
||||
String uuidString = character[UUID_INDEX];
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
long lastPlayed = 0;
|
||||
boolean rewrite = false;
|
||||
|
||||
@@ -209,7 +210,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (lastPlayed == -1) {
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid);
|
||||
|
||||
if(player.getLastPlayed() != 0) {
|
||||
lastPlayed = player.getLastPlayed();
|
||||
@@ -217,7 +218,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (lastPlayed != -1 && lastPlayed != 0 && currentTime - lastPlayed > purgeTime) {
|
||||
if (lastPlayed < 1 && (currentTime - lastPlayed > purgeTime)) {
|
||||
removedPlayers++;
|
||||
} else {
|
||||
if (rewrite) {
|
||||
@@ -715,7 +716,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
boolean matchingName = dbPlayerName.equalsIgnoreCase(playerName);
|
||||
|
||||
if (!matchingName) {
|
||||
logger.info("When loading user: "+playerName +" with UUID of (" + uuid.toString()
|
||||
logger.warning("When loading user: "+playerName +" with UUID of (" + uuid.toString()
|
||||
+") 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;
|
||||
@@ -840,7 +841,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
|
||||
}
|
||||
finally {
|
||||
logger.info(i + " entries written while saving UUID for " + userName);
|
||||
LogUtils.debug(logger, i + " entries written while saving UUID for " + userName);
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
@@ -898,7 +899,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
logger.severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e);
|
||||
}
|
||||
finally {
|
||||
logger.info(i + " entries written while saving UUID batch");
|
||||
LogUtils.debug(logger, i + " entries written while saving UUID batch");
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
@@ -1092,7 +1093,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
|
||||
public @Nullable List<FlatFileDataFlag> checkFileHealthAndStructure() {
|
||||
ArrayList<FlatFileDataFlag> flagsFound = null;
|
||||
logger.info("(" + usersFile.getPath() + ") Validating database file..");
|
||||
LogUtils.debug(logger, "(" + usersFile.getPath() + ") Validating database file..");
|
||||
FlatFileDataProcessor dataProcessor = null;
|
||||
|
||||
if (usersFile.exists()) {
|
||||
@@ -1127,7 +1128,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
//Only update the file if needed
|
||||
if(dataProcessor.getFlatFileDataFlags().size() > 0) {
|
||||
flagsFound = new ArrayList<>(dataProcessor.getFlatFileDataFlags());
|
||||
logger.info("Saving the updated and or repaired FlatFile Database...");
|
||||
logger.info("Updating FlatFile Database...");
|
||||
fileWriter = new FileWriter(usersFilePath);
|
||||
//Write data to file
|
||||
if(dbCommentDate != null)
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
@@ -51,7 +52,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
|
||||
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().getMySQLSSL())
|
||||
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"+
|
||||
@@ -60,6 +62,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
connectionString+=
|
||||
"?useSSL=false";
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().getMySQLPublicKeyRetrieval()) {
|
||||
connectionString+=
|
||||
"&allowPublicKeyRetrieval=true";
|
||||
}
|
||||
|
||||
try {
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName(driverPath);
|
||||
@@ -1007,7 +1014,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
*/
|
||||
private void checkDatabaseStructure(Connection connection, UpgradeType upgrade) {
|
||||
if (!mcMMO.getUpgradeManager().shouldUpgrade(upgrade)) {
|
||||
mcMMO.p.debug("Skipping " + upgrade.name() + " upgrade (unneeded)");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Skipping " + upgrade.name() + " upgrade (unneeded)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1116,8 +1123,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException {
|
||||
Map<PrimarySkillType, Integer> skills = new EnumMap<PrimarySkillType, Integer>(PrimarySkillType.class); // Skill & Level
|
||||
Map<PrimarySkillType, Float> skillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class); // Skill & XP
|
||||
Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
|
||||
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;
|
||||
@@ -1571,7 +1578,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
mcMMO.p.debug("Releasing connection pool resource...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Releasing connection pool resource...");
|
||||
miscPool.close();
|
||||
loadPool.close();
|
||||
savePool.close();
|
||||
|
||||
@@ -29,8 +29,7 @@ public class FlatFileDataUtil {
|
||||
/*
|
||||
* First fix the bad data values if they exist
|
||||
*/
|
||||
if(dataContainer instanceof BadCategorizedFlatFileData) {
|
||||
BadCategorizedFlatFileData badData = (BadCategorizedFlatFileData) dataContainer;
|
||||
if(dataContainer instanceof BadCategorizedFlatFileData badData) {
|
||||
splitData = repairBadData(dataContainer.getSplitData(), badData.getBadDataIndexes());
|
||||
} else {
|
||||
splitData = dataContainer.getSplitData();
|
||||
|
||||
@@ -37,8 +37,7 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
|
||||
return false;
|
||||
}
|
||||
|
||||
if(t instanceof Player) {
|
||||
Player listeningPlayer = (Player) t;
|
||||
if(t instanceof Player listeningPlayer) {
|
||||
|
||||
//Party Member Check
|
||||
if(mcMMO.p.getGeneralConfig().isLevelUpBroadcastsPartyMembersOnly()) {
|
||||
@@ -75,7 +74,7 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
|
||||
}
|
||||
|
||||
//Visibility checks
|
||||
if(!listeningPlayer.canSee(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
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ public class PowerLevelUpBroadcastPredicate<T extends CommandSender> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
if(t instanceof Player) {
|
||||
Player listeningPlayer = (Player) t;
|
||||
if(t instanceof Player listeningPlayer) {
|
||||
|
||||
//Party Member Check
|
||||
if(mcMMO.p.getGeneralConfig().isPowerLevelUpBroadcastsPartyMembersOnly()) {
|
||||
@@ -75,7 +74,7 @@ public class PowerLevelUpBroadcastPredicate<T extends CommandSender> implements
|
||||
}
|
||||
|
||||
//Visibility checks
|
||||
if(!listeningPlayer.canSee(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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.interactions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This class helps define the types of information interactions we will have with players
|
||||
*/
|
||||
@@ -23,14 +25,14 @@ public enum NotificationType {
|
||||
CHAT_ONLY("ChatOnly"),
|
||||
PARTY_MESSAGE("PartyMessage");
|
||||
|
||||
final String niceName;
|
||||
private final String niceName;
|
||||
|
||||
NotificationType(String niceName)
|
||||
{
|
||||
NotificationType(@NotNull String niceName) {
|
||||
this.niceName = niceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public @NotNull String toString() {
|
||||
return niceName;
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ public class McMMOUrl {
|
||||
public static final String urlWebsite = "https://www.mcmmo.org";
|
||||
public static final String urlDiscord = "https://discord.gg/bJ7pFS9";
|
||||
public static final String urlPatreon = "https://www.patreon.com/nossr50";
|
||||
public static final String urlWiki = "https://www.mcmmo.org/wiki/";
|
||||
public static final String urlSpigot = "http://spigot.mcmmo.org";
|
||||
public static final String urlWiki = "https://wiki.mcmmo.org/";
|
||||
public static final String urlSpigot = "https://spigot.mcmmo.org";
|
||||
public static final String urlTranslate = "https://translate.mcmmo.org/";
|
||||
|
||||
public static String getUrl(McMMOWebLinks webLinks)
|
||||
|
||||
@@ -252,10 +252,10 @@ public class Party {
|
||||
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
}
|
||||
|
||||
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
}
|
||||
|
||||
public boolean hasReachedLevelCap() {
|
||||
@@ -327,7 +327,7 @@ public class Party {
|
||||
}
|
||||
|
||||
public boolean hasMember(String memberName) {
|
||||
return this.getMembers().containsValue(memberName);
|
||||
return this.getMembers().values().stream().anyMatch(memberName::equalsIgnoreCase);
|
||||
}
|
||||
|
||||
public boolean hasMember(UUID uuid) {
|
||||
@@ -403,12 +403,10 @@ public class Party {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Party)) {
|
||||
if (!(obj instanceof Party other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party other = (Party) obj;
|
||||
|
||||
if ((this.getName() == null) || (other.getName() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,10 +41,7 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -82,7 +79,7 @@ public class McMMOPlayer implements Identified {
|
||||
private final Player player;
|
||||
private final PlayerProfile profile;
|
||||
|
||||
private final Map<PrimarySkillType, SkillManager> skillManagers = new EnumMap<PrimarySkillType, SkillManager>(PrimarySkillType.class);
|
||||
private final Map<PrimarySkillType, SkillManager> skillManagers = new EnumMap<>(PrimarySkillType.class);
|
||||
private final ExperienceBarManager experienceBarManager;
|
||||
|
||||
private Party party;
|
||||
@@ -101,10 +98,10 @@ public class McMMOPlayer implements Identified {
|
||||
|
||||
private ChatChannel chatChannel;
|
||||
|
||||
private final Map<SuperAbilityType, Boolean> abilityMode = new EnumMap<SuperAbilityType, Boolean>(SuperAbilityType.class);
|
||||
private final Map<SuperAbilityType, Boolean> abilityInformed = new EnumMap<SuperAbilityType, Boolean>(SuperAbilityType.class);
|
||||
private final Map<SuperAbilityType, Boolean> abilityMode = new EnumMap<>(SuperAbilityType.class);
|
||||
private final Map<SuperAbilityType, Boolean> abilityInformed = new EnumMap<>(SuperAbilityType.class);
|
||||
|
||||
private final Map<ToolType, Boolean> toolMode = new EnumMap<ToolType, Boolean>(ToolType.class);
|
||||
private final Map<ToolType, Boolean> toolMode = new EnumMap<>(ToolType.class);
|
||||
|
||||
private int recentlyHurt;
|
||||
private int respawnATS;
|
||||
@@ -580,7 +577,7 @@ public class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a player is level capped
|
||||
* Whether a player is level capped
|
||||
* If they are at the power level cap, this will return true, otherwise it checks their skill level
|
||||
* @param primarySkillType
|
||||
* @return
|
||||
@@ -593,7 +590,7 @@ public class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a player is power level capped
|
||||
* Whether a player is power level capped
|
||||
* Compares their power level total to the current set limit
|
||||
* @return true if they have reached the power level cap
|
||||
*/
|
||||
@@ -645,7 +642,7 @@ public class McMMOPlayer implements Identified {
|
||||
|
||||
applyXpGain(skill, modifyXpGain(skill, xp), xpGainReason, xpGainSource);
|
||||
|
||||
if (party == null) {
|
||||
if (party == null || party.hasReachedLevelCap()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -915,7 +912,7 @@ public class McMMOPlayer implements Identified {
|
||||
return;
|
||||
}
|
||||
|
||||
//These values change depending on whether or not the server is in retro mode
|
||||
//These values change depending on whether the server is in retro mode
|
||||
int abilityLengthVar = mcMMO.p.getAdvancedConfig().getAbilityLength();
|
||||
int abilityLengthCap = mcMMO.p.getAdvancedConfig().getAbilityLengthCap();
|
||||
|
||||
@@ -946,7 +943,7 @@ public class McMMOPlayer implements Identified {
|
||||
SkillUtils.removeAbilityBuff(player.getInventory().getItemInMainHand());
|
||||
|
||||
// Enable the ability
|
||||
profile.setAbilityDATS(superAbilityType, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
profile.setAbilityDATS(superAbilityType, System.currentTimeMillis() + ((long) ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
setAbilityMode(superAbilityType, true);
|
||||
|
||||
if (superAbilityType == SuperAbilityType.SUPER_BREAKER || superAbilityType == SuperAbilityType.GIGA_DRILL_BREAKER) {
|
||||
@@ -954,7 +951,7 @@ public class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
setToolPreparationMode(tool, false);
|
||||
new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, (long) ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
|
||||
@@ -1137,13 +1134,13 @@ public class McMMOPlayer implements Identified {
|
||||
*/
|
||||
public void logout(boolean syncSave) {
|
||||
Player thisPlayer = getPlayer();
|
||||
if(getPlayer().hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) getPlayer().getMetadata(mcMMO.RUPTURE_META_KEY).get(0);
|
||||
if(getPlayer().hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) getPlayer().getMetadata(MetadataConstants.METADATA_KEY_RUPTURE).get(0);
|
||||
|
||||
//Punish a logout
|
||||
ruptureTaskMeta.getRuptureTimerTask().explode();
|
||||
ruptureTaskMeta.getRuptureTimerTask().explode();
|
||||
ruptureTaskMeta.getRuptureTimerTask().explode();
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
}
|
||||
|
||||
cleanup();
|
||||
|
||||
@@ -14,10 +14,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.DelayQueue;
|
||||
|
||||
public class PlayerProfile {
|
||||
@@ -35,20 +32,28 @@ public class PlayerProfile {
|
||||
/* Skill Data */
|
||||
private final Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
|
||||
private final Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
||||
private final Map<SuperAbilityType, Integer> abilityDATS = new EnumMap<SuperAbilityType, Integer>(SuperAbilityType.class); // Ability & Cooldown
|
||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
private final Map<SuperAbilityType, Integer> abilityDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
|
||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new EnumMap<>(UniqueDataType.class); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
|
||||
// Store previous XP gains for diminished returns
|
||||
private final DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<>();
|
||||
private final Map<PrimarySkillType, Float> rollingSkillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class);
|
||||
private final Map<PrimarySkillType, Float> rollingSkillsXp = new EnumMap<>(PrimarySkillType.class);
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName) {
|
||||
this(playerName, null, 0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName, UUID uuid) {
|
||||
this(playerName, uuid, 0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
//TODO: Add deprecated constructor w/o startinglevel
|
||||
public PlayerProfile(String playerName, int startingLevel) {
|
||||
this(playerName, null, startingLevel);
|
||||
}
|
||||
|
||||
//TODO: Add deprecated constructor w/o startinglevel
|
||||
public PlayerProfile(String playerName, @Nullable UUID uuid, int startingLevel) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
@@ -80,7 +85,7 @@ public class PlayerProfile {
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
public PlayerProfile(@NotNull String playerName, UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) {
|
||||
public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) {
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
@@ -152,14 +157,10 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Get this users last login, will return current java.lang.System#currentTimeMillis() if it doesn't exist
|
||||
* @return the last login
|
||||
* @deprecated This is only function for FlatFileDB atm and its only here for unit testing right now
|
||||
* @deprecated This is only function for FlatFileDB atm, and it's only here for unit testing right now
|
||||
*/
|
||||
@Deprecated
|
||||
public @NotNull Long getLastLogin() {
|
||||
if(lastLogin == null)
|
||||
return -1L;
|
||||
else
|
||||
return lastLogin;
|
||||
return Objects.requireNonNullElse(lastLogin, -1L);
|
||||
}
|
||||
|
||||
public void updateLastLogin() {
|
||||
|
||||
@@ -27,40 +27,6 @@ public enum PrimarySkillType {
|
||||
TAMING,
|
||||
UNARMED,
|
||||
WOODCUTTING;
|
||||
// boolean issueWarning = true;
|
||||
|
||||
/*
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
*/
|
||||
|
||||
|
||||
// private void processWarning() {
|
||||
// if(issueWarning) {
|
||||
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
// Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
|
||||
// mcMMO.p.getLogger().severe("A plugin that hooks into mcMMO via the mcMMO API is using soon to be deprecated API calls. Contact the plugin author and inform them to update their code before it breaks.");
|
||||
// mcMMO.p.getLogger().severe("Deprecation Call from: " + stackTraceElements[2].toString());
|
||||
// mcMMO.p.getLogger().severe("This warning will not repeat itself. Nothing is broken for now, but in the future it will be.");
|
||||
// });
|
||||
//
|
||||
// issueWarning = !issueWarning;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Collection;
|
||||
|
||||
public interface Toolable {
|
||||
/**
|
||||
* Whether or not this Skill requires a tool
|
||||
* Whether this Skill requires a tool
|
||||
* Not all skills will require a tool
|
||||
* @return true if tool is required
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this subskill is enabled
|
||||
* Whether this subskill is enabled
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ public interface SubSkill extends Skill {
|
||||
void addStats(TextComponent.Builder componentBuilder, Player player);
|
||||
|
||||
/**
|
||||
* Whether or not this subskill is enabled
|
||||
* Whether this subskill is enabled
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,7 +27,7 @@ public class FishingTreasureBook extends FishingTreasure {
|
||||
}
|
||||
|
||||
private void initLegalEnchantments() {
|
||||
mcMMO.p.getLogger().info("Registering enchantments for Fishing Book...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Registering enchantments for Fishing Book...");
|
||||
|
||||
for(Enchantment enchantment : Enchantment.values()) {
|
||||
if(isEnchantAllowed(enchantment)) {
|
||||
|
||||
@@ -3,9 +3,12 @@ package com.gmail.nossr50.events.fake;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.inventory.BrewEvent;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FakeBrewEvent extends BrewEvent implements FakeEvent {
|
||||
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
|
||||
super(brewer, contents, fuelLevel);
|
||||
public FakeBrewEvent(Block brewer, BrewerInventory contents, List<ItemStack> results, int fuelLevel) {
|
||||
super(brewer, contents, results, fuelLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,14 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements FakeEvent {
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
|
||||
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
|
||||
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
|
||||
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
|
||||
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
modifierFunctions.put(modifier, ZERO);
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,14 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Called when mcMMO applies damage due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageEvent extends EntityDamageEvent implements FakeEvent {
|
||||
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||
super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
|
||||
super(damagee, cause, damage);
|
||||
}
|
||||
|
||||
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
|
||||
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
|
||||
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
modifierFunctions.put(modifier, ZERO);
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
|
||||
/**
|
||||
* Called when handling extra drops to avoid issues with NoCheat.
|
||||
*/
|
||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent implements FakeEvent {
|
||||
public FakePlayerAnimationEvent(Player player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.fake;
|
||||
//
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
//import org.bukkit.event.player.PlayerAnimationType;
|
||||
//
|
||||
///**
|
||||
// * Called when handling extra drops to avoid issues with NoCheat.
|
||||
// */
|
||||
//public class FakePlayerAnimationEvent extends PlayerAnimationEvent implements FakeEvent {
|
||||
// public FakePlayerAnimationEvent(Player player, PlayerAnimationType playerAnimationType) {
|
||||
// super(player, playerAnimationType);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.gmail.nossr50.events.items;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when mcMMO is preparing to drop an item.
|
||||
@@ -16,14 +18,25 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
||||
private ItemStack itemStack;
|
||||
private boolean cancelled;
|
||||
private final ItemSpawnReason itemSpawnReason;
|
||||
private final Player player;
|
||||
|
||||
public McMMOItemSpawnEvent(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public McMMOItemSpawnEvent(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason, @Nullable Player player) {
|
||||
this.location = location;
|
||||
this.itemStack = itemStack;
|
||||
this.itemSpawnReason = itemSpawnReason;
|
||||
this.player = player;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated player
|
||||
* This can be null
|
||||
* @return the associated player if one exists null otherwise
|
||||
*/
|
||||
public @Nullable Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reason an item is being spawned by mcMMO
|
||||
* @see ItemSpawnReason
|
||||
|
||||
@@ -53,6 +53,16 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Created a party.
|
||||
*/
|
||||
CREATED_PARTY,
|
||||
|
||||
/**
|
||||
* Disbanded a party.
|
||||
*/
|
||||
DISBANDED_PARTY,
|
||||
|
||||
/**
|
||||
* Joined a party for the first time.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.events.skills.rupture;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent {
|
||||
private final McMMOPlayer mcMMODamager;
|
||||
|
||||
public McMMOEntityDamageByRuptureEvent(@NotNull McMMOPlayer damager, @NotNull Entity damagee, double damage) {
|
||||
super(damager.getPlayer(), damagee, DamageCause.CUSTOM, damage);
|
||||
this.mcMMODamager = damager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public McMMOPlayer getMcMMODamager() {
|
||||
return mcMMODamager;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
@@ -20,7 +21,6 @@ import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.compat.layers.world.WorldCompatibilityLayer;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@@ -46,9 +46,22 @@ public class BlockListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
|
||||
public void onBlockDropItemEvent(BlockDropItemEvent event)
|
||||
{
|
||||
//Make sure we clean up metadata on these blocks
|
||||
if(event.isCancelled()) {
|
||||
if(event.getBlock().hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS))
|
||||
event.getBlock().removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
int tileEntityTolerance = 1;
|
||||
|
||||
// beetroot hotfix, potentially other plants may need this fix
|
||||
if(event.getBlockState().getType() == Material.BEETROOTS)
|
||||
tileEntityTolerance = 2;
|
||||
|
||||
//Track how many "things" are being dropped
|
||||
HashSet<Material> uniqueMaterials = new HashSet<>();
|
||||
boolean dontRewardTE = false; //If we suspect TEs are mixed in with other things don't reward bonus drops for anything that isn't a block
|
||||
@@ -63,7 +76,7 @@ public class BlockListener implements Listener {
|
||||
blockCount++;
|
||||
}
|
||||
|
||||
if(uniqueMaterials.size() > 1) {
|
||||
if(uniqueMaterials.size() > tileEntityTolerance) {
|
||||
//Too many things are dropping, assume tile entities might be duped
|
||||
//Technically this would also prevent something like coal from being bonus dropped if you placed a TE above a coal ore when mining it but that's pretty edge case and this is a good solution for now
|
||||
dontRewardTE = true;
|
||||
@@ -91,19 +104,19 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0) {
|
||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).get(0);
|
||||
if (event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).size() > 0) {
|
||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).get(0);
|
||||
int bonusCount = bonusDropMeta.asInt();
|
||||
|
||||
for (int i = 0; i < bonusCount; i++) {
|
||||
Misc.spawnItemNaturally(event.getBlockState().getLocation(), is, ItemSpawnReason.BONUS_DROPS);
|
||||
Misc.spawnItemNaturally(event.getPlayer(), event.getBlockState().getLocation(), is, ItemSpawnReason.BONUS_DROPS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(event.getBlock().hasMetadata(mcMMO.BONUS_DROPS_METAKEY))
|
||||
event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
|
||||
if(event.getBlock().hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS))
|
||||
event.getBlock().removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,16 +134,16 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockFace direction = event.getDirection();
|
||||
Block movedBlock;
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
final BlockFace direction = event.getDirection();
|
||||
|
||||
for (Block block : event.getBlocks()) {
|
||||
movedBlock = block.getRelative(direction);
|
||||
for (final Block block : event.getBlocks()) {
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtLocation(block.getLocation(), () -> {
|
||||
final Block movedBlock = block.getRelative(direction);
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, movedBlock)) {
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
}
|
||||
if (BlockUtils.isWithinWorldBounds(movedBlock)) {
|
||||
BlockUtils.setUnnaturalBlock(movedBlock);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,16 +166,15 @@ public class BlockListener implements Listener {
|
||||
BlockFace direction = event.getDirection();
|
||||
Block movedBlock = event.getBlock().getRelative(direction);
|
||||
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
//Spigot makes bad things happen in its API
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, movedBlock)) {
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
if(BlockUtils.isWithinWorldBounds(movedBlock)) {
|
||||
BlockUtils.setUnnaturalBlock(movedBlock);
|
||||
}
|
||||
|
||||
for (Block block : event.getBlocks()) {
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
||||
if(BlockUtils.isWithinWorldBounds(block) && BlockUtils.isWithinWorldBounds(block.getRelative(direction))) {
|
||||
Block relativeBlock = block.getRelative(direction);
|
||||
BlockUtils.setUnnaturalBlock(relativeBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,15 +192,13 @@ public class BlockListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
|
||||
BlockState blockState = event.getNewState();
|
||||
|
||||
if(ExperienceConfig.getInstance().isSnowExploitPrevented() && BlockUtils.shouldBeWatched(blockState)) {
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
BlockUtils.setUnnaturalBlock(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,11 +217,11 @@ public class BlockListener implements Listener {
|
||||
|
||||
if(ExperienceConfig.getInstance().preventStoneLavaFarming()) {
|
||||
BlockState newState = event.getNewState();
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
if(newState.getType() != Material.OBSIDIAN && ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, newState.getBlockData())) {
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, newState.getBlock())) {
|
||||
mcMMO.getPlaceStore().setTrue(newState);
|
||||
Block block = newState.getBlock();
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
BlockUtils.setUnnaturalBlock(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,10 +245,11 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
//NOTE: BlockMultiPlace has its own logic so don't handle anything that would overlap
|
||||
if (!(event instanceof BlockMultiPlaceEvent)) {
|
||||
BlockUtils.setUnnaturalBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -272,11 +283,18 @@ public class BlockListener implements Listener {
|
||||
BlockState blockState = replacedBlockState.getBlock().getState();
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
//Updated: 10/5/2021
|
||||
//Note: For some reason Azalea trees trigger this event but no other tree does (as of 10/5/2021) but if this changes in the future we may need to update this
|
||||
if(BlockUtils.isPartOfTree(event.getBlockPlaced())) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Track unnatural blocks
|
||||
for(BlockState replacedState : event.getReplacedBlockStates()) {
|
||||
BlockUtils.setUnnaturalBlock(replacedState.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,9 +309,7 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
|
||||
// Minecraft is dumb, the events still throw when a plant "grows" higher than the max block height. Even though no new block is created
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
}
|
||||
}
|
||||
@@ -306,21 +322,27 @@ public class BlockListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
|
||||
return;
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
if(WorldBlacklist.isWorldBlacklisted(block.getWorld())) {
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer())) {
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
// if (!BlockUtils.shouldBeWatched(blockState)) {
|
||||
@@ -335,6 +357,7 @@ public class BlockListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,7 +366,8 @@ public class BlockListener implements Listener {
|
||||
//Check if profile is loaded
|
||||
if(mcMMOPlayer == null) {
|
||||
/* Remove metadata from placed watched blocks */
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,7 +397,10 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState)
|
||||
&& (ItemUtils.isPickaxe(heldItem) || ItemUtils.isHoe(heldItem))
|
||||
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.MINING)
|
||||
&& !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
@@ -405,7 +432,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* Remove metadata from placed watched blocks */
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,6 +442,9 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreakHigher(BlockBreakEvent event) {
|
||||
if(event instanceof FakeEvent)
|
||||
return;
|
||||
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
||||
return;
|
||||
@@ -426,10 +456,6 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
@@ -535,7 +561,7 @@ public class BlockListener implements Listener {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
|
||||
|
||||
if(mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK)) {
|
||||
if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
||||
if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player)) {
|
||||
event.setInstaBreak(true);
|
||||
|
||||
if(blockState.getType().getKey().getKey().contains("glass")) {
|
||||
@@ -610,11 +636,11 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
|
||||
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
|
||||
if (EventUtils.simulateBlockBreak(block, player, true) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||
if (EventUtils.simulateBlockBreak(block, player) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||
blockState.update();
|
||||
}
|
||||
}
|
||||
else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||
else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player)) {
|
||||
event.setInstaBreak(true);
|
||||
|
||||
if(blockState.getType().getKey().getKey().contains("glass")) {
|
||||
@@ -624,7 +650,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player)) {
|
||||
event.setInstaBreak(true);
|
||||
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
||||
}
|
||||
@@ -682,9 +708,8 @@ public class BlockListener implements Listener {
|
||||
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region");
|
||||
}
|
||||
|
||||
if(blockState instanceof Furnace)
|
||||
if(blockState instanceof Furnace furnace)
|
||||
{
|
||||
Furnace furnace = (Furnace) blockState;
|
||||
if(mcMMO.getSmeltingTracker().isFurnaceOwned(furnace))
|
||||
{
|
||||
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
|
||||
|
||||
@@ -8,20 +8,19 @@ import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.metadata.MobMetadataService;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.TravelingBlockMetaCleanup;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@@ -29,9 +28,11 @@ import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.*;
|
||||
@@ -52,7 +53,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
private final mcMMO pluginRef;
|
||||
private final @NotNull AbstractPersistentDataLayer persistentDataLayer;
|
||||
private final @NotNull MobMetadataService mobMetadataService;
|
||||
|
||||
/**
|
||||
* We can use this {@link NamespacedKey} for {@link Enchantment} comparisons to
|
||||
@@ -62,7 +63,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
public EntityListener(final mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
persistentDataLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
|
||||
mobMetadataService = mcMMO.getMetadataService().getMobMetadataService();
|
||||
}
|
||||
|
||||
// @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@@ -91,15 +92,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityTransform(EntityTransformEvent event) {
|
||||
if(event.getEntity() instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||
if(event.getEntity() instanceof LivingEntity livingEntity) {
|
||||
|
||||
//Transfer metadata keys from mob-spawned mobs to new mobs
|
||||
if(persistentDataLayer.hasMobFlags(livingEntity)) {
|
||||
if(mobMetadataService.hasMobFlags(livingEntity)) {
|
||||
for(Entity entity : event.getTransformedEntities()) {
|
||||
if(entity instanceof LivingEntity) {
|
||||
LivingEntity transformedEntity = (LivingEntity) entity;
|
||||
persistentDataLayer.addMobFlags(livingEntity, transformedEntity);
|
||||
if(entity instanceof LivingEntity transformedEntity) {
|
||||
mobMetadataService.addMobFlags(livingEntity, transformedEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,11 +119,10 @@ public class EntityListener implements Listener {
|
||||
//Prevent entities from giving XP if they target endermite
|
||||
if(event.getTarget() instanceof Endermite)
|
||||
{
|
||||
if(event.getEntity() instanceof Enderman) {
|
||||
Enderman enderman = (Enderman) event.getEntity();
|
||||
if(event.getEntity() instanceof Enderman enderman) {
|
||||
|
||||
if(!persistentDataLayer.hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
|
||||
persistentDataLayer.flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
|
||||
if(!mobMetadataService.hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
|
||||
mobMetadataService.flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,9 +134,8 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
if(event.getEntity() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
@@ -158,11 +155,11 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (bow != null
|
||||
&& bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_INF_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
//Cleanup metadata in 1 minute in case normal collection falls through
|
||||
CombatUtils.delayArrowMetaCleanup((Projectile) projectile);
|
||||
}
|
||||
@@ -174,9 +171,8 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity().getShooter() instanceof Player)
|
||||
if(event.getEntity().getShooter() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
@@ -190,11 +186,11 @@ public class EntityListener implements Listener {
|
||||
if(entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
|
||||
CombatUtils.delayArrowMetaCleanup(projectile); //Cleans up metadata 1 minute from now in case other collection methods fall through
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.bowForceKey))
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0));
|
||||
if(!projectile.hasMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE))
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, new FixedMetadataValue(pluginRef, 1.0));
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
if(!projectile.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE))
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
|
||||
//Check both hands
|
||||
if(ItemUtils.doesPlayerHaveEnchantmentInHands(player, "piercing")) {
|
||||
@@ -202,7 +198,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
||||
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,17 +235,21 @@ public class EntityListener implements Listener {
|
||||
* It's a headache to read but it works, I'm tempted to just remove it
|
||||
*/
|
||||
if (entity instanceof FallingBlock || entity instanceof Enderman) {
|
||||
boolean isTracked = entity.hasMetadata(mcMMO.travelingBlock);
|
||||
boolean isTracked = entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK);
|
||||
|
||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
|
||||
entity.setMetadata(mcMMO.travelingBlock, mcMMO.metadataValue);
|
||||
entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
TravelingBlockMetaCleanup metaCleanupTask = new TravelingBlockMetaCleanup(entity, pluginRef);
|
||||
metaCleanupTask.runTaskTimer(pluginRef, 20, 20*60); //6000 ticks is 5 minutes
|
||||
}
|
||||
else if (isTracked) {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
BlockUtils.setUnnaturalBlock(block);
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
|
||||
}
|
||||
} else if ((block.getType() == Material.REDSTONE_ORE)) {
|
||||
} else if ((block.getType() == Material.REDSTONE_ORE || block.getType().getKey().getKey().equalsIgnoreCase("deepslate_redstone_ore"))) {
|
||||
//Redstone ore fire this event and should be ignored
|
||||
}
|
||||
else {
|
||||
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||
@@ -262,19 +262,15 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) {
|
||||
//Prevent players from setting fire to each other if they are in the same party
|
||||
if(event.getEntity() instanceof Player) {
|
||||
Player defender = (Player) event.getEntity();
|
||||
if(event.getEntity() instanceof Player defender) {
|
||||
|
||||
if(event.getCombuster() instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) event.getCombuster();
|
||||
if(projectile.getShooter() instanceof Player) {
|
||||
Player attacker = (Player) projectile.getShooter();
|
||||
if(event.getCombuster() instanceof Projectile projectile) {
|
||||
if(projectile.getShooter() instanceof Player attacker) {
|
||||
if(checkParties(event, defender, attacker)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if(event.getCombuster() instanceof Player) {
|
||||
Player attacker = (Player) event.getCombuster();
|
||||
} else if(event.getCombuster() instanceof Player attacker) {
|
||||
if(checkParties(event, defender, attacker)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -290,7 +286,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent || event instanceof McMMOEntityDamageByRuptureEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -306,9 +302,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
} else if(attacker instanceof Projectile) {
|
||||
|
||||
Projectile projectile = (Projectile) attacker;
|
||||
} else if(attacker instanceof Projectile projectile) {
|
||||
|
||||
if(projectile.getShooter() instanceof Player) {
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag((Player) projectile.getShooter())) {
|
||||
@@ -337,12 +331,10 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(defender)) || !defender.isValid() || !(defender instanceof LivingEntity)) {
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(defender)) || !defender.isValid() || !(defender instanceof LivingEntity target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity target = (LivingEntity) defender;
|
||||
|
||||
if (CombatUtils.isInvincible(target, damage)) {
|
||||
return;
|
||||
}
|
||||
@@ -369,43 +361,31 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
//Friendly fire checks
|
||||
if (defender instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
Player attackingPlayer;
|
||||
|
||||
if (defender instanceof Player defendingPlayer) {
|
||||
//If the attacker is a Player or a projectile belonging to a player
|
||||
if(attacker instanceof Projectile || attacker instanceof Player) {
|
||||
if(attacker instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) attacker;
|
||||
if(((Projectile) attacker).getShooter() instanceof Player) {
|
||||
attackingPlayer = (Player) projectile.getShooter();
|
||||
if(attacker instanceof Projectile projectile) {
|
||||
if(projectile.getShooter() instanceof Player attackingPlayer && !attackingPlayer.equals(defendingPlayer)) {
|
||||
//Check for party friendly fire and cancel the event
|
||||
if (checkParties(event, defendingPlayer, attackingPlayer)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Check for party friendly fire and cancel the event
|
||||
if (checkParties(event, defendingPlayer, attackingPlayer))
|
||||
{
|
||||
//Deflect checks
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
|
||||
if (mcMMOPlayer != null) {
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
|
||||
if (unarmedManager.canDeflect()) {
|
||||
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Deflect checks
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
|
||||
if (mcMMOPlayer != null) {
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
|
||||
if (unarmedManager.canDeflect()) {
|
||||
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
attackingPlayer = (Player) attacker;
|
||||
//Check for party friendly fire and cancel the event
|
||||
if (checkParties(event, defendingPlayer, attackingPlayer))
|
||||
return;
|
||||
}
|
||||
} else if (attacker instanceof Player attackingPlayer){
|
||||
if (checkParties(event, defendingPlayer, attackingPlayer))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,8 +418,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||
public void onEntityDamageMonitor(EntityDamageByEntityEvent entityDamageEvent) {
|
||||
if(entityDamageEvent.getEntity() instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) entityDamageEvent.getEntity();
|
||||
if(entityDamageEvent.getEntity() instanceof LivingEntity livingEntity) {
|
||||
|
||||
if(entityDamageEvent.getFinalDamage() >= livingEntity.getHealth()) {
|
||||
//This sets entity names back to whatever they are supposed to be
|
||||
@@ -450,6 +429,74 @@ public class EntityListener implements Listener {
|
||||
if(entityDamageEvent.getDamager() instanceof Projectile) {
|
||||
CombatUtils.cleanupArrowMetadata((Projectile) entityDamageEvent.getDamager());
|
||||
}
|
||||
|
||||
if(entityDamageEvent.getEntity() instanceof Player player && entityDamageEvent.getDamager() instanceof Player) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
if(mmoPlayer != null) {
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
player.sendMessage(ChatColor.GOLD + "(mmodebug start of combat report) EntityDamageByEntityEvent DEBUG Info:");
|
||||
player.sendMessage("You are being damaged by another player in this event");
|
||||
player.sendMessage("Raw Damage: " + entityDamageEvent.getDamage());
|
||||
player.sendMessage("Your max health: "+player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
player.sendMessage("Your current health: "+player.getHealth());
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Damage Modifiers (final damage)");
|
||||
for (EntityDamageEvent.DamageModifier modifier : EntityDamageEvent.DamageModifier.values()) {
|
||||
player.sendMessage("Modifier "+modifier.name()+": " + entityDamageEvent.getDamage(modifier));
|
||||
}
|
||||
|
||||
player.sendMessage("Final damage: " + entityDamageEvent.getFinalDamage());
|
||||
|
||||
if(entityDamageEvent instanceof FakeEntityDamageByEntityEvent) {
|
||||
player.sendMessage("This report is for a fake damage event used by mcMMO to test a players permission to hurt another");
|
||||
}
|
||||
|
||||
if(entityDamageEvent instanceof McMMOEntityDamageByRuptureEvent) {
|
||||
player.sendMessage("This report is for a Rupture damage event, which is sent out by mcMMO");
|
||||
}
|
||||
|
||||
if(entityDamageEvent.isCancelled()) {
|
||||
player.sendMessage("Event was cancelled, which means no damage should be done.");
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED + "(mmodebug end of combat report)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(entityDamageEvent.getDamager() instanceof Player player && entityDamageEvent.getEntity() instanceof Player otherPlayer) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
if(mmoPlayer != null) {
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
player.sendMessage(ChatColor.GOLD + "(mmodebug start of combat report) EntityDamageByEntityEvent DEBUG Info:");
|
||||
player.sendMessage("You are dealing damage to another player in this event");
|
||||
player.sendMessage("Raw Damage: " + entityDamageEvent.getDamage());
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Damage Modifiers (final damage)");
|
||||
for (EntityDamageEvent.DamageModifier modifier : EntityDamageEvent.DamageModifier.values()) {
|
||||
player.sendMessage("Modifier "+modifier.name()+": " + entityDamageEvent.getDamage(modifier));
|
||||
}
|
||||
|
||||
player.sendMessage("Final damage: " + entityDamageEvent.getFinalDamage());
|
||||
player.sendMessage("Target players max health: "+otherPlayer.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
player.sendMessage("Target players current health: "+otherPlayer.getHealth());
|
||||
|
||||
if(entityDamageEvent instanceof FakeEntityDamageByEntityEvent) {
|
||||
player.sendMessage("This report is for a fake damage event used by mcMMO to test a players permission to hurt another");
|
||||
}
|
||||
|
||||
if(entityDamageEvent instanceof McMMOEntityDamageByRuptureEvent) {
|
||||
player.sendMessage("This report is for a Rupture damage event, which is sent out by mcMMO");
|
||||
}
|
||||
|
||||
if(entityDamageEvent.isCancelled()) {
|
||||
player.sendMessage("Event was cancelled, which means no damage should be done.");
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED + "(mmodebug end of combat report)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkParties(Cancellable event, Player defendingPlayer, Player attackingPlayer) {
|
||||
@@ -487,13 +534,12 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity().hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
|
||||
event.getEntity().removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
if(event.getEntity().hasMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE)) {
|
||||
event.getEntity().removeMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
if(event.getEntity() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
@@ -532,12 +578,10 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
*/
|
||||
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !entity.isValid() || !(entity instanceof LivingEntity)) {
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !entity.isValid() || !(entity instanceof LivingEntity livingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (CombatUtils.isInvincible(livingEntity, damage)) {
|
||||
return;
|
||||
}
|
||||
@@ -569,13 +613,11 @@ public class EntityListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
else if (livingEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) livingEntity;
|
||||
else if (livingEntity instanceof Tameable pet) {
|
||||
AnimalTamer owner = pet.getOwner();
|
||||
|
||||
if(owner instanceof Player)
|
||||
if(owner instanceof Player player)
|
||||
{
|
||||
Player player = (Player) owner;
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
@@ -663,7 +705,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDeathLowest(EntityDeathEvent event) {
|
||||
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getEntity());
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -726,11 +768,11 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
private void trackSpawnedAndPassengers(LivingEntity livingEntity, MobMetaFlagType mobMetaFlagType) {
|
||||
persistentDataLayer.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
mobMetadataService.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
|
||||
for(Entity passenger : livingEntity.getPassengers()) {
|
||||
if(passenger != null) {
|
||||
persistentDataLayer.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
mobMetadataService.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -738,7 +780,7 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onEntityBreed(EntityBreedEvent event) {
|
||||
if(ExperienceConfig.getInstance().isCOTWBreedingPrevented()) {
|
||||
if(persistentDataLayer.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getFather()) || persistentDataLayer.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getMother())) {
|
||||
if(mobMetadataService.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getFather()) || mobMetadataService.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getMother())) {
|
||||
event.setCancelled(true);
|
||||
Animals mom = (Animals) event.getMother();
|
||||
Animals father = (Animals) event.getFather();
|
||||
@@ -748,8 +790,7 @@ public class EntityListener implements Listener {
|
||||
father.setLoveModeTicks(0);
|
||||
|
||||
//Inform the player
|
||||
if(event.getBreeder() instanceof Player) {
|
||||
Player player = (Player) event.getBreeder();
|
||||
if(event.getBreeder() instanceof Player player) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.BreedingDisallowed");
|
||||
}
|
||||
}
|
||||
@@ -770,13 +811,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@@ -816,13 +857,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@@ -863,12 +904,10 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof Player)) {
|
||||
if (!(entity instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) entity;
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
@@ -911,6 +950,16 @@ public class EntityListener implements Listener {
|
||||
* is based on how 'common' the item is We can adjust this quite easily
|
||||
* if we find something is giving too much of a bonus
|
||||
*/
|
||||
|
||||
//Hacky 1.17 support
|
||||
if(foodInHand.getKey().getKey().equalsIgnoreCase("glow_berries")) {
|
||||
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (foodInHand) {
|
||||
case BAKED_POTATO: /*
|
||||
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
||||
@@ -994,12 +1043,12 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)
|
||||
|| (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(livingEntity))
|
||||
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|
||||
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
|
||||
|| mobMetadataService.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|
||||
|| mobMetadataService.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
persistentDataLayer.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
|
||||
mobMetadataService.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
@@ -1025,12 +1074,10 @@ public class EntityListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (!(entity instanceof Tameable) || !(target instanceof Player)) {
|
||||
if (!(entity instanceof Tameable tameable) || !(target instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) target;
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
@@ -1038,8 +1085,6 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Tameable tameable = (Tameable) entity;
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
|
||||
return;
|
||||
}
|
||||
@@ -1082,4 +1127,6 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -52,7 +53,7 @@ public class InteractionManager {
|
||||
//Register in name map
|
||||
subSkillNameMap.putIfAbsent(lowerCaseName, abstractSubSkill);
|
||||
|
||||
mcMMO.p.getLogger().info("Registered subskill: "+ abstractSubSkill.getConfigKeyName());
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Registered subskill: "+ abstractSubSkill.getConfigKeyName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,12 +10,12 @@ import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -53,35 +53,29 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
Furnace furnace = (Furnace) furnaceState;
|
||||
|
||||
OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getFurnaceOwner(furnace);
|
||||
Player player;
|
||||
|
||||
if(offlinePlayer != null && offlinePlayer.isOnline()) {
|
||||
if(offlinePlayer != null && offlinePlayer.isOnline() && offlinePlayer instanceof Player) {
|
||||
player = (Player) offlinePlayer;
|
||||
|
||||
Player player = Bukkit.getPlayer(offlinePlayer.getUniqueId());
|
||||
if (!Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(player != null) {
|
||||
if (!Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
|
||||
return;
|
||||
}
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Profile doesn't exist
|
||||
if(UserManager.getOfflinePlayer(offlinePlayer) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean debugMode = player.isOnline() && UserManager.getPlayer(player).isDebugMode();
|
||||
if(mmoPlayer != null) {
|
||||
boolean debugMode = mmoPlayer.isDebugMode();
|
||||
|
||||
if(debugMode) {
|
||||
player.sendMessage("FURNACE FUEL EFFICIENCY DEBUG REPORT");
|
||||
player.sendMessage("Furnace - "+furnace.hashCode());
|
||||
player.sendMessage("Furnace Type: "+furnaceBlock.getType().toString());
|
||||
player.sendMessage("Furnace Type: "+furnaceBlock.getType());
|
||||
player.sendMessage("Burn Length before Fuel Efficiency is applied - "+event.getBurnTime());
|
||||
}
|
||||
|
||||
event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
|
||||
event.setBurnTime(mmoPlayer.getSmeltingManager().fuelEfficiency(event.getBurnTime()));
|
||||
|
||||
if(debugMode) {
|
||||
player.sendMessage("New Furnace Burn Length (after applying fuel efficiency) "+event.getBurnTime());
|
||||
@@ -89,7 +83,6 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@@ -105,8 +98,7 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(blockState instanceof Furnace) {
|
||||
Furnace furnace = (Furnace) blockState;
|
||||
if(blockState instanceof Furnace furnace) {
|
||||
OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getFurnaceOwner(furnace);
|
||||
|
||||
if(offlinePlayer != null) {
|
||||
@@ -191,7 +183,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
|
||||
if (!(holder instanceof BrewingStand)) {
|
||||
if (!(holder instanceof BrewingStand stand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,7 +200,6 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
BrewingStand stand = (BrewingStand) holder;
|
||||
ItemStack clicked = event.getCurrentItem();
|
||||
ItemStack cursor = event.getCursor();
|
||||
|
||||
@@ -403,6 +394,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
SkillUtils.removeAbilityBuff(event.getCurrentItem());
|
||||
|
||||
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
|
||||
if(isOutsideWindowClick(event))
|
||||
return;
|
||||
@@ -427,7 +419,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
final HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
|
||||
if (!whoClicked.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
||||
import com.gmail.nossr50.events.McMMOReplaceVanillaTreasureEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
@@ -119,9 +118,8 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntityHighest(EntityDamageByEntityEvent event) {
|
||||
// we only care about players as this is for fixing player death messages
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
if (!(event.getEntity() instanceof Player player))
|
||||
return;
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
// get the attacker
|
||||
LivingEntity attacker;
|
||||
@@ -184,7 +182,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player killedPlayer = event.getEntity();
|
||||
|
||||
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
if (!killedPlayer.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -212,6 +210,11 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
|
||||
public void onPlayerDeathNormal(PlayerDeathEvent playerDeathEvent) {
|
||||
SkillUtils.removeAbilityBoostsFromInventory(playerDeathEvent.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerChangedWorldEvents.
|
||||
* <p>
|
||||
@@ -267,7 +270,7 @@ public class PlayerListener implements Listener {
|
||||
ItemStack dropStack = drop.getItemStack();
|
||||
|
||||
if (ItemUtils.isSharable(dropStack)) {
|
||||
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
|
||||
drop.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ITEM, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
SkillUtils.removeAbilityBuff(dropStack);
|
||||
@@ -398,7 +401,7 @@ public class PlayerListener implements Listener {
|
||||
//Track the hook
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
|
||||
{
|
||||
if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0)
|
||||
if(event.getHook().getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() == 0)
|
||||
{
|
||||
fishingManager.setFishHookReference(event.getHook());
|
||||
}
|
||||
@@ -408,9 +411,8 @@ public class PlayerListener implements Listener {
|
||||
{
|
||||
event.setExpToDrop(0);
|
||||
|
||||
if(caught instanceof Item)
|
||||
if(caught instanceof Item caughtItem)
|
||||
{
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
}
|
||||
|
||||
@@ -425,7 +427,9 @@ public class PlayerListener implements Listener {
|
||||
ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||
|
||||
//Grab lure level
|
||||
if(inHand != null && inHand.getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) {
|
||||
if(inHand != null
|
||||
&& inHand.getItemMeta() != null
|
||||
&& inHand.getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) {
|
||||
if(inHand.getItemMeta().hasEnchants()) {
|
||||
for(Enchantment enchantment : inHand.getItemMeta().getEnchants().keySet()) {
|
||||
if(enchantment.toString().toLowerCase().contains("lure")) {
|
||||
@@ -433,17 +437,24 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fishingManager.masterAngler(event.getHook(), lureLevel);
|
||||
fishingManager.setFishingTarget();
|
||||
// Prevent any potential odd behavior by only processing if no offhand fishing rod is present
|
||||
if(!player.getInventory().getItemInOffHand().getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) {
|
||||
// In case of offhand fishing rod, don't process anything
|
||||
fishingManager.masterAngler(event.getHook(), lureLevel);
|
||||
fishingManager.setFishingTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
case CAUGHT_FISH:
|
||||
if(caught instanceof Item) {
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
|
||||
|
||||
fishingManager.processExploiting(event.getHook().getLocation().toVector());
|
||||
|
||||
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
||||
event.setExpToDrop(0);
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
@@ -484,9 +495,8 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
if(event.getEntity() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
@@ -509,19 +519,19 @@ public class PlayerListener implements Listener {
|
||||
ItemStack dropStack = drop.getItemStack();
|
||||
|
||||
//Remove tracking
|
||||
if(drop.hasMetadata(mcMMO.trackedArrow)) {
|
||||
drop.removeMetadata(mcMMO.trackedArrow, mcMMO.p);
|
||||
if(drop.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW)) {
|
||||
drop.removeMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, mcMMO.p);
|
||||
}
|
||||
|
||||
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
|
||||
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
|
||||
if (drop.hasMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM)) {
|
||||
if (!player.getName().equals(drop.getMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM).get(0).asString())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
if (!drop.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ITEM) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -568,7 +578,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
//Use a sync save if the server is shutting down to avoid race conditions
|
||||
mcMMOPlayer.logout(mcMMO.isServerShutdownExecuted());
|
||||
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getPlayer());
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -794,7 +804,6 @@ public class PlayerListener implements Listener {
|
||||
if(player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart))
|
||||
{
|
||||
player.getVehicle().eject();
|
||||
player.setVelocity(player.getEyeLocation().getDirection().multiply(10));
|
||||
}
|
||||
|
||||
//mcMMOPlayer.getFishingManager().setFishingRodCastTimestamp();
|
||||
@@ -832,30 +841,32 @@ public class PlayerListener implements Listener {
|
||||
ChimaeraWing.activationCheck(player);
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
|
||||
if (heldItem.getType() == Material.BONE_MEAL) {
|
||||
switch (blockState.getType()) {
|
||||
case BEETROOTS:
|
||||
case CARROT:
|
||||
case COCOA:
|
||||
case WHEAT:
|
||||
case NETHER_WART_BLOCK:
|
||||
case POTATO:
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
|
||||
// FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer(), PlayerAnimationType.ARM_SWING); //PlayerAnimationEvent compat
|
||||
if(!event.isCancelled() || event.useInteractedBlock() != Event.Result.DENY) {
|
||||
//TODO: Is this code to set false from bone meal even needed? I'll have to double check later.
|
||||
if (heldItem.getType() == Material.BONE_MEAL) {
|
||||
switch (blockState.getType().toString()) {
|
||||
case "BEETROOTS":
|
||||
case "CARROT":
|
||||
case "COCOA":
|
||||
case "WHEAT":
|
||||
case "NETHER_WART_BLOCK":
|
||||
case "POTATO":
|
||||
case "MANGROVE_PROPAGULE":
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
//call event for Green Thumb Block
|
||||
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
// Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
|
||||
player.updateInventory();
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
@@ -863,10 +874,10 @@ public class PlayerListener implements Listener {
|
||||
/* SHROOM THUMB CHECK */
|
||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
// Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
event.setCancelled(true);
|
||||
if (herbalismManager.processShroomThumb(blockState)
|
||||
&& EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
&& EventUtils.simulateBlockBreak(block, player)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
@@ -880,7 +891,7 @@ public class PlayerListener implements Listener {
|
||||
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (mcMMO.p.getGeneralConfig().getAbilitiesEnabled()) {
|
||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
|
||||
@@ -947,8 +958,8 @@ public class PlayerListener implements Listener {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
|
||||
mcMMO.p.debug("Party & Admin chat will not work properly for this player.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), player.getName() + "is chatting, but is currently not logged in to the server.");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Party & Admin chat will not work properly for this player.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -999,7 +1010,7 @@ public class PlayerListener implements Listener {
|
||||
* When a {@link Player} attempts to place an {@link ItemStack}
|
||||
* into an {@link ItemFrame}, we want to make sure to remove any
|
||||
* Ability buffs from that item.
|
||||
*
|
||||
*
|
||||
* @param event The {@link PlayerInteractEntityEvent} to handle
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
@@ -1008,8 +1019,7 @@ public class PlayerListener implements Listener {
|
||||
* We can check for an instance instead of EntityType here, so we are
|
||||
* ready for the infamous "Glow Item Frame" in 1.17 too!
|
||||
*/
|
||||
if (event.getRightClicked() instanceof ItemFrame) {
|
||||
ItemFrame frame = (ItemFrame) event.getRightClicked();
|
||||
if (event.getRightClicked() instanceof ItemFrame frame) {
|
||||
|
||||
// Check for existing items (ignore rotations)
|
||||
if (frame.getItem().getType() != Material.AIR) {
|
||||
@@ -1031,17 +1041,9 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
// public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
|
||||
// /* WORLD BLACKLIST CHECK */
|
||||
// if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
|
||||
// return;
|
||||
//
|
||||
// if (!mcMMO.getHolidayManager().isAprilFirst()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// mcMMO.getHolidayManager().handleStatisticEvent(event);
|
||||
// }
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||
SkillUtils.removeAbilityBuff(event.getMainHandItem());
|
||||
SkillUtils.removeAbilityBuff(event.getOffHandItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@ public class SelfListener implements Listener {
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PrimarySkillType skill = event.getSkill();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//TODO: Handle proper validation at the event level
|
||||
if(mcMMOPlayer == null || !mcMMOPlayer.getProfile().isLoaded())
|
||||
return;
|
||||
|
||||
if(player.isOnline()) {
|
||||
//Players can gain multiple levels especially during xprate events
|
||||
for(int i = 0; i < event.getLevelsGained(); i++)
|
||||
@@ -73,6 +80,11 @@ public class SelfListener implements Listener {
|
||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//TODO: Handle proper validation at the event level
|
||||
if(mcMMOPlayer == null || !mcMMOPlayer.getProfile().isLoaded())
|
||||
return;
|
||||
|
||||
PrimarySkillType primarySkillType = event.getSkill();
|
||||
|
||||
if(mcMMOPlayer.isDebugMode()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
|
||||
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -11,6 +12,8 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@@ -29,13 +32,12 @@ public class WorldListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
|
||||
return;
|
||||
|
||||
if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
// Using 50 ms later as I do not know of a way to run one tick later (safely)
|
||||
plugin.getFoliaLib().getImpl().runLater(() -> {
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
}, 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.locale;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.text.TextUtils;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -57,7 +58,7 @@ public final class LocaleLoader {
|
||||
*
|
||||
* @return The properly formatted text component
|
||||
*/
|
||||
public static TextComponent getTextComponent(String key, Object... messageArguments) {
|
||||
public static @NotNull TextComponent getTextComponent(@NotNull String key, Object... messageArguments) {
|
||||
if (bundle == null) {
|
||||
initialize();
|
||||
}
|
||||
@@ -113,7 +114,7 @@ public final class LocaleLoader {
|
||||
return string;
|
||||
}
|
||||
|
||||
public static TextComponent formatComponent(String string, Object... messageArguments) {
|
||||
public static @NotNull TextComponent formatComponent(@NotNull String string, Object... messageArguments) {
|
||||
if (messageArguments != null) {
|
||||
MessageFormat formatter = new MessageFormat("");
|
||||
formatter.applyPattern(string.replace("'", "''"));
|
||||
@@ -192,7 +193,7 @@ public final class LocaleLoader {
|
||||
//Use the new locale file
|
||||
if (Files.exists(overridePath) && Files.isRegularFile(overridePath)) {
|
||||
try (Reader localeReader = Files.newBufferedReader(overridePath)) {
|
||||
mcMMO.p.getLogger().log(Level.INFO, "Loading locale from {0}", overridePath);
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loading locale from " + overridePath.toString());
|
||||
filesystemBundle = new PropertyResourceBundle(localeReader);
|
||||
} catch (IOException e) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to load locale from " + overridePath, e);
|
||||
@@ -246,7 +247,6 @@ public final class LocaleLoader {
|
||||
"# If you wish to replace every line in some way, feel free to copy the entire contents of this file, just be advised that you will need to be on top of locale updates in mcMMO and follow our changelog closely.\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# WARNING: Locales only support ASCII and UTF16 characters at the moment, so you'll need to run special characters through a UTF16 converter (google it) to get them to work. This will be fixed in the future!\n" +
|
||||
"# FIND KEYS HERE: On our github repo (en_US is our master file and has ALL the keys) -> https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"# WARNING: Some keys in our master file are unused, make gratuitous use of Ctrl+F\n" +
|
||||
"# HOW TO APPLY: You can either restart the server for these changes to take effect or run /mcreloadlocale.\n" +
|
||||
@@ -257,45 +257,49 @@ public final class LocaleLoader {
|
||||
|
||||
@NotNull
|
||||
private static String getExamples() {
|
||||
return "This.Is.An.Example.Put.Locale.Keys.Here.One=&aExample text using hex color codes\n" +
|
||||
"This.Is.An.Example.Put.Locale.Keys.Here.Two=[[DARK_AQUA]]Example text using our own color codes\n" +
|
||||
"This.Is.An.Example.Put.Locale.Keys.Here.Three=Example text with no colors\n";
|
||||
return """
|
||||
This.Is.An.Example.Put.Locale.Keys.Here.One=&aExample text using hex color codes
|
||||
This.Is.An.Example.Put.Locale.Keys.Here.Two=[[DARK_AQUA]]Example text using our own color codes
|
||||
This.Is.An.Example.Put.Locale.Keys.Here.Three=Example text with no colors
|
||||
""";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getLocaleHelpTextWithoutExamples() {
|
||||
String localeExplanation =
|
||||
"# -- Are you looking to change the language of mcMMO but without editing it yourself? --\n" +
|
||||
"\n" +
|
||||
"# mcMMO has quite a few built in translations, you can choose which translation by editing config.yml with the appropriate locale code. The setting is `General.Locale` in config.yml\n" +
|
||||
"# Odds are, if you speak a popular language on earth we already have a translation for it.\n" +
|
||||
"# However our translations are done by the community, and update infrequently. (Please help us out <3)\n" +
|
||||
"# We would love more people to help update our locales, submit any updated translation file to our GitHub or email it to me at business@neetgames.com\n" +
|
||||
"# For a list of built in translations, view this link: https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# -- Using a built in translation -- \n" +
|
||||
"# Assuming you read the above section, edit config.yml's General.Locale from en_US to the locale code that we support (see the above link), then reboot your server\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# -- Do you want to change the text in mcMMO? Including adding colors? ( Locale Override ) -- \n" +
|
||||
"# First, a brief explanation.\n" +
|
||||
"# Locales are the language files used by mcMMO, they also contain color codes and most of the styling used by mcMMO.\n" +
|
||||
"# You can customize a locale outside of the JAR in version 2.1.51 and up.\n" +
|
||||
"#\n" +
|
||||
"# Locales can be overridden by editing this file\n" +
|
||||
"# You can find the up to date current locale files here https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"# The master file is en_US, if a translation is missing entries (as they often are) it will pull from the en_US file https://github.com/mcMMO-Dev/mcMMO/blob/master/src/main/resources/locale/locale_en_US.properties\n" +
|
||||
"#\n" +
|
||||
"# To override a locale, add entries to this file and copy ** only ** the strings you want to replace, otherwise you will not see any updated strings when mcMMO updates and will have to manually change them and read patch notes carefully.\n" +
|
||||
"# If you wish to replace every line in some way, feel free to copy the entire contents of this file, just be advised that you will need to be on top of locale updates in mcMMO and follow our changelog closely.\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# WARNING: Locales only support ASCII and UTF16 characters at the moment, so you'll need to run special characters through a UTF16 converter (google it) to get them to work. This will be fixed in the future!\n" +
|
||||
"# FIND KEYS HERE: On our github repo (en_US is our master file and has ALL the keys) -> https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"# WARNING: Some keys in our master file are unused, make gratuitous use of Ctrl+F\n" +
|
||||
"# HOW TO APPLY: You can either restart the server for these changes to take effect or run /mcreloadlocale.\n" +
|
||||
"# -- Add Keys Below --\n";
|
||||
"""
|
||||
# -- Are you looking to change the language of mcMMO but without editing it yourself? --
|
||||
|
||||
# mcMMO has quite a few built in translations, you can choose which translation by editing config.yml with the appropriate locale code. The setting is `General.Locale` in config.yml
|
||||
# Odds are, if you speak a popular language on earth we already have a translation for it.
|
||||
# However our translations are done by the community, and update infrequently. (Please help us out <3)
|
||||
# We would love more people to help update our locales, submit any updated translation file to our GitHub or email it to me at business@neetgames.com
|
||||
# For a list of built in translations, view this link: https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale
|
||||
|
||||
|
||||
# -- Using a built in translation --\s
|
||||
# Assuming you read the above section, edit config.yml's General.Locale from en_US to the locale code that we support (see the above link), then reboot your server
|
||||
|
||||
|
||||
# -- Do you want to change the text in mcMMO? Including adding colors? ( Locale Override ) --\s
|
||||
# First, a brief explanation.
|
||||
# Locales are the language files used by mcMMO, they also contain color codes and most of the styling used by mcMMO.
|
||||
# You can customize a locale outside of the JAR in version 2.1.51 and up.
|
||||
#
|
||||
# Locales can be overridden by editing this file
|
||||
# You can find the up to date current locale files here https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale
|
||||
# The master file is en_US, if a translation is missing entries (as they often are) it will pull from the en_US file https://github.com/mcMMO-Dev/mcMMO/blob/master/src/main/resources/locale/locale_en_US.properties
|
||||
#
|
||||
# To override a locale, add entries to this file and copy ** only ** the strings you want to replace, otherwise you will not see any updated strings when mcMMO updates and will have to manually change them and read patch notes carefully.
|
||||
# If you wish to replace every line in some way, feel free to copy the entire contents of this file, just be advised that you will need to be on top of locale updates in mcMMO and follow our changelog closely.
|
||||
|
||||
|
||||
# WARNING: Locales only support ASCII and UTF16 characters at the moment, so you'll need to run special characters through a UTF16 converter (google it) to get them to work. This will be fixed in the future!
|
||||
# FIND KEYS HERE: On our github repo (en_US is our master file and has ALL the keys) -> https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale
|
||||
# WARNING: Some keys in our master file are unused, make gratuitous use of Ctrl+F
|
||||
# HOW TO APPLY: You can either restart the server for these changes to take effect or run /mcreloadlocale.
|
||||
# -- Add Keys Below --
|
||||
""";
|
||||
return localeExplanation;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
|
||||
import com.gmail.nossr50.listeners.*;
|
||||
import com.gmail.nossr50.metadata.MetadataService;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.placeholders.PapiExpansion;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||
import com.gmail.nossr50.runnables.commands.NotifySquelchReminderTask;
|
||||
@@ -51,6 +53,8 @@ import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.gmail.nossr50.util.skills.SmeltingTracker;
|
||||
import com.gmail.nossr50.util.upgrade.UpgradeManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.tcoded.folialib.FoliaLib;
|
||||
import com.tcoded.folialib.impl.ServerImplementation;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@@ -67,16 +71,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
/* Managers */
|
||||
|
||||
|
||||
/* Managers & Services */
|
||||
private static PlatformManager platformManager;
|
||||
private static MetadataService metadataService;
|
||||
private static ChunkManager placeStore;
|
||||
private static RepairableManager repairableManager;
|
||||
private static SalvageableManager salvageableManager;
|
||||
@@ -129,33 +136,13 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
private static boolean isRetroModeEnabled;
|
||||
|
||||
/* Metadata Values */
|
||||
public static final String REPLANT_META_KEY = "mcMMO: Recently Replanted";
|
||||
public static final String EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
|
||||
public static final String RUPTURE_META_KEY = "mcMMO: RuptureTask";
|
||||
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
|
||||
public static final String DODGE_TRACKER = "mcMMO: Dodge Tracker";
|
||||
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
|
||||
public static final String travelingBlock = "mcMMO: Traveling Block";
|
||||
public static final String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
public static final String tntMetadataKey = "mcMMO: Tracked TNT";
|
||||
public static final String customNameKey = "mcMMO: Custom Name";
|
||||
public static final String customVisibleKey = "mcMMO: Name Visibility";
|
||||
public static final String droppedItemKey = "mcMMO: Tracked Item";
|
||||
public static final String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
||||
public static final String trackedArrow = "mcMMO: Tracked Arrow";
|
||||
public static final String bowForceKey = "mcMMO: Bow Force";
|
||||
public static final String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||
public static final String BONUS_DROPS_METAKEY = "mcMMO: Double Drops";
|
||||
public static final String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||
public static final String playerDataKey = "mcMMO: Player Data";
|
||||
public static final String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
private long purgeTime = 2630000000L;
|
||||
|
||||
private GeneralConfig generalConfig;
|
||||
private AdvancedConfig advancedConfig;
|
||||
|
||||
private FoliaLib foliaLib;
|
||||
|
||||
// private RepairConfig repairConfig;
|
||||
// private SalvageConfig salvageConfig;
|
||||
// private PersistentDataConfig persistentDataConfig;
|
||||
@@ -183,6 +170,12 @@ public class mcMMO extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
//Filter out any debug messages (if debug/verbose logging is not enabled)
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
|
||||
//Folia lib plugin instance
|
||||
foliaLib = new FoliaLib(this);
|
||||
|
||||
setupFilePaths();
|
||||
generalConfig = new GeneralConfig(getDataFolder()); //Load before skillTools
|
||||
skillTools = new SkillTools(this); //Load after general config
|
||||
@@ -196,10 +189,10 @@ public class mcMMO extends JavaPlugin {
|
||||
//Platform Manager
|
||||
platformManager = new PlatformManager();
|
||||
|
||||
//Filter out any debug messages (if debug/verbose logging is not enabled)
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
//metadata service
|
||||
metadataService = new MetadataService(this);
|
||||
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
MetadataConstants.MCMMO_METADATA_VALUE = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
@@ -207,7 +200,6 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
upgradeManager = new UpgradeManager();
|
||||
|
||||
|
||||
modManager = new ModManager();
|
||||
|
||||
//Init Material Maps
|
||||
@@ -246,18 +238,19 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
if(serverAPIOutdated)
|
||||
{
|
||||
Bukkit
|
||||
.getScheduler()
|
||||
.scheduleSyncRepeatingTask(this,
|
||||
foliaLib
|
||||
.getImpl()
|
||||
.runTimer(
|
||||
() -> getLogger().severe("You are running an outdated version of "+platformManager.getServerSoftware()+", mcMMO will not work unless you update to a newer version!"),
|
||||
20, 20*60*30);
|
||||
20 * 50L, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
|
||||
if(platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT)
|
||||
{
|
||||
Bukkit.getScheduler()
|
||||
.scheduleSyncRepeatingTask(this,
|
||||
foliaLib
|
||||
.getImpl()
|
||||
.runTimer(
|
||||
() -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."),
|
||||
20, 20*60*30);
|
||||
20 * 50L, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
} else {
|
||||
registerEvents();
|
||||
@@ -272,7 +265,7 @@ public class mcMMO extends JavaPlugin {
|
||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||
}
|
||||
|
||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Version " + getDescription().getVersion() + " is enabled!");
|
||||
|
||||
scheduleTasks();
|
||||
CommandRegistrationManager.registerCommands();
|
||||
@@ -299,9 +292,7 @@ public class mcMMO extends JavaPlugin {
|
||||
else
|
||||
metrics.addCustomChart(new SimplePie("leveling_system", () -> "Standard"));
|
||||
}
|
||||
}
|
||||
|
||||
catch (Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
getLogger().severe("There was an error while enabling mcMMO!");
|
||||
|
||||
if (!(t instanceof ExceptionInInitializerError)) {
|
||||
@@ -337,6 +328,10 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
transientEntityTracker = new TransientEntityTracker();
|
||||
setServerShutdown(false); //Reset flag, used to make decisions about async saves
|
||||
|
||||
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PapiExpansion().register();
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerLevelUtils getPlayerLevelUtils() {
|
||||
@@ -397,26 +392,21 @@ public class mcMMO extends JavaPlugin {
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMOBackup();
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
catch(NoClassDefFoundError e) {
|
||||
} catch(NoClassDefFoundError e) {
|
||||
getLogger().severe("Backup class not found!");
|
||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||
}
|
||||
catch (Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
debug("Canceling all tasks...");
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
debug("Unregister all events...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Canceling all tasks...");
|
||||
getFoliaLib().getImpl().cancelAllTasks(); // This removes our tasks
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Unregister all events...");
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
|
||||
databaseManager.onDisable();
|
||||
debug("Was disabled."); // How informative!
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Was disabled."); // How informative!
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
@@ -451,10 +441,6 @@ public class mcMMO extends JavaPlugin {
|
||||
xpEventEnabled = !xpEventEnabled;
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
getLogger().info("[Debug] " + message);
|
||||
}
|
||||
|
||||
public static FormulaManager getFormulaManager() {
|
||||
return formulaManager;
|
||||
}
|
||||
@@ -483,10 +469,14 @@ public class mcMMO extends JavaPlugin {
|
||||
return upgradeManager;
|
||||
}
|
||||
|
||||
public static CompatibilityManager getCompatibilityManager() {
|
||||
public static @Nullable CompatibilityManager getCompatibilityManager() {
|
||||
return platformManager.getCompatibilityManager();
|
||||
}
|
||||
|
||||
public static MetadataService getMetadataService() {
|
||||
return metadataService;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
||||
mcMMO.databaseManager = databaseManager;
|
||||
@@ -599,7 +589,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
// Load salvage configs, make manager and register them at this time
|
||||
SalvageConfigManager sManager = new SalvageConfigManager(this);
|
||||
List<Salvageable> salvageables = new ArrayList<>(sManager.getLoadedSalvageables());
|
||||
List<Salvageable> salvageables = sManager.getLoadedSalvageables();
|
||||
salvageableManager = new SimpleSalvageableManager(salvageables.size());
|
||||
salvageableManager.registerSalvageables(salvageables);
|
||||
}
|
||||
@@ -631,7 +621,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
if(CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS))
|
||||
{
|
||||
getLogger().info("Enabling Acrobatics Skills");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Enabling Acrobatics Skills");
|
||||
|
||||
//TODO: Should do this differently
|
||||
Roll roll = new Roll();
|
||||
@@ -641,11 +631,11 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void registerCustomRecipes() {
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
getFoliaLib().getImpl().runLater(() -> {
|
||||
if (generalConfig.getChimaeraEnabled()) {
|
||||
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||
}
|
||||
}, 40);
|
||||
}, 40 * 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
@@ -655,10 +645,10 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
long saveIntervalTicks = Math.max(minute, generalConfig.getSaveInterval() * minute);
|
||||
|
||||
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
|
||||
new SaveTimerTask().runTaskTimer(saveIntervalTicks, saveIntervalTicks);
|
||||
|
||||
// Cleanup the backups folder
|
||||
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
|
||||
getFoliaLib().getImpl().runAsync(new CleanBackupsTask());
|
||||
|
||||
// Old & Powerless User remover
|
||||
long purgeIntervalTicks = generalConfig.getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
|
||||
@@ -790,4 +780,8 @@ public class mcMMO extends JavaPlugin {
|
||||
public @NotNull AdvancedConfig getAdvancedConfig() {
|
||||
return advancedConfig;
|
||||
}
|
||||
|
||||
public @NotNull FoliaLib getFoliaLib() {
|
||||
return foliaLib;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataHolder;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.gmail.nossr50.metadata.MetadataService.NSK_FURNACE_UUID_LEAST_SIG;
|
||||
import static com.gmail.nossr50.metadata.MetadataService.NSK_FURNACE_UUID_MOST_SIG;
|
||||
|
||||
public class BlockMetadataService {
|
||||
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public BlockMetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public @Nullable UUID getFurnaceOwner(@NotNull Furnace furnace) {
|
||||
//Get container from entity
|
||||
PersistentDataContainer dataContainer = ((PersistentDataHolder) furnace).getPersistentDataContainer();
|
||||
|
||||
//Too lazy to make a custom data type for this stuff
|
||||
Long mostSigBits = dataContainer.get(NSK_FURNACE_UUID_MOST_SIG, PersistentDataType.LONG);
|
||||
Long leastSigBits = dataContainer.get(NSK_FURNACE_UUID_LEAST_SIG, PersistentDataType.LONG);
|
||||
|
||||
if (mostSigBits != null && leastSigBits != null) {
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFurnaceOwner(@NotNull Furnace furnace, @NotNull UUID uuid) {
|
||||
PersistentDataContainer dataContainer = ((PersistentDataHolder) furnace).getPersistentDataContainer();
|
||||
|
||||
dataContainer.set(NSK_FURNACE_UUID_MOST_SIG, PersistentDataType.LONG, uuid.getMostSignificantBits());
|
||||
dataContainer.set(NSK_FURNACE_UUID_LEAST_SIG, PersistentDataType.LONG, uuid.getLeastSignificantBits());
|
||||
|
||||
furnace.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.gmail.nossr50.metadata.MetadataService.NSK_SUPER_ABILITY_BOOSTED_ITEM;
|
||||
|
||||
public class ItemMetadataService {
|
||||
|
||||
public final @NotNull String LEGACY_ABILITY_TOOL_LORE = "mcMMO Ability Tool";
|
||||
public final @NotNull mcMMO pluginRef;
|
||||
|
||||
public ItemMetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public void setSuperAbilityBoostedItem(@NotNull ItemStack itemStack, int originalDigSpeed) {
|
||||
if (itemStack.getItemMeta() == null) {
|
||||
mcMMO.p.getLogger().severe("Can not assign persistent data to an item with null item metadata");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
dataContainer.set(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER, originalDigSpeed);
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public boolean isSuperAbilityBoosted(@NotNull ItemStack itemStack) {
|
||||
if (itemStack.getItemMeta() == null)
|
||||
return false;
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
//Get container from entity
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
//If this value isn't null, then the tool can be considered dig speed boosted
|
||||
Integer boostValue = dataContainer.get(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER);
|
||||
|
||||
return boostValue != null;
|
||||
}
|
||||
|
||||
public int getSuperAbilityToolOriginalDigSpeed(@NotNull ItemStack itemStack) {
|
||||
//Get container from entity
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (itemMeta == null)
|
||||
return 0;
|
||||
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
if (dataContainer.get(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER) == null) {
|
||||
mcMMO.p.getLogger().severe("Value should never be null for a boosted item");
|
||||
return 0;
|
||||
} else {
|
||||
//Too lazy to make a custom data type for this stuff
|
||||
Integer boostValue = dataContainer.get(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER);
|
||||
return Math.max(boostValue, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBonusDigSpeedOnSuperAbilityTool(@NotNull ItemStack itemStack) {
|
||||
int originalSpeed = getSuperAbilityToolOriginalDigSpeed(itemStack);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta != null) {
|
||||
//TODO: can be optimized
|
||||
if (itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
|
||||
if (originalSpeed > 0) {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, originalSpeed, true);
|
||||
}
|
||||
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
dataContainer.remove(NSK_SUPER_ABILITY_BOOSTED_ITEM); //Remove persistent data
|
||||
|
||||
//TODO: needed?
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLegacyAbilityTool(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (itemMeta == null)
|
||||
return false;
|
||||
|
||||
List<String> lore = itemMeta.getLore();
|
||||
|
||||
if (lore == null || lore.isEmpty())
|
||||
return false;
|
||||
|
||||
return lore.contains(LEGACY_ABILITY_TOOL_LORE);
|
||||
}
|
||||
|
||||
public @NotNull String getLegacyAbilityToolLore() {
|
||||
return LEGACY_ABILITY_TOOL_LORE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MetadataService {
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
protected static final @NotNull NamespacedKey NSK_SUPER_ABILITY_BOOSTED_ITEM;
|
||||
protected static final @NotNull NamespacedKey NSK_MOB_SPAWNER_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_EGG_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_NETHER_GATE_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_COTW_SUMMONED_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_PLAYER_BRED_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_PLAYER_TAMED_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_VILLAGER_TRADE_ORIGIN_ITEM;
|
||||
protected static final @NotNull NamespacedKey NSK_EXPLOITED_ENDERMEN;
|
||||
protected static final @NotNull NamespacedKey NSK_FURNACE_UUID_MOST_SIG;
|
||||
protected static final @NotNull NamespacedKey NSK_FURNACE_UUID_LEAST_SIG;
|
||||
|
||||
static {
|
||||
NSK_SUPER_ABILITY_BOOSTED_ITEM = getNamespacedKey(MetadataConstants.METADATA_KEY_SUPER_ABILITY_BOOSTED_ITEM);
|
||||
NSK_MOB_SPAWNER_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_MOB_SPAWNER_MOB);
|
||||
NSK_EGG_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_EGG_MOB);
|
||||
NSK_NETHER_GATE_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_NETHER_PORTAL_MOB);
|
||||
NSK_COTW_SUMMONED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_COTW_SUMMONED_MOB);
|
||||
NSK_PLAYER_BRED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_PLAYER_BRED_MOB);
|
||||
NSK_PLAYER_TAMED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_PLAYER_TAMED_MOB);
|
||||
NSK_VILLAGER_TRADE_ORIGIN_ITEM = getNamespacedKey(MetadataConstants.METADATA_KEY_VILLAGER_TRADE_ORIGIN_ITEM);
|
||||
NSK_EXPLOITED_ENDERMEN = getNamespacedKey(MetadataConstants.METADATA_KEY_EXPLOITED_ENDERMEN);
|
||||
NSK_FURNACE_UUID_MOST_SIG = getNamespacedKey(MetadataConstants.METADATA_KEY_FURNACE_UUID_MOST_SIG);
|
||||
NSK_FURNACE_UUID_LEAST_SIG = getNamespacedKey(MetadataConstants.METADATA_KEY_FURNACE_UUID_LEAST_SIG);
|
||||
}
|
||||
|
||||
private final @NotNull ItemMetadataService itemMetadataService;
|
||||
private final @NotNull MobMetadataService mobMetadataService;
|
||||
private final @NotNull BlockMetadataService blockMetadataService;
|
||||
|
||||
public MetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
|
||||
blockMetadataService = new BlockMetadataService(pluginRef);
|
||||
mobMetadataService = new MobMetadataService(pluginRef);
|
||||
itemMetadataService = new ItemMetadataService(pluginRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify generating namespaced keys
|
||||
*
|
||||
* @param key the {@link String} value of the key
|
||||
*
|
||||
* @return the generated {@link NamespacedKey}
|
||||
*/
|
||||
public static @NotNull NamespacedKey getNamespacedKey(@NotNull String key) {
|
||||
return new NamespacedKey(mcMMO.p, key);
|
||||
}
|
||||
|
||||
public @NotNull ItemMetadataService getItemMetadataService() {
|
||||
return itemMetadataService;
|
||||
}
|
||||
|
||||
public @NotNull MobMetadataService getMobMetadataService() {
|
||||
return mobMetadataService;
|
||||
}
|
||||
|
||||
public @NotNull BlockMetadataService getBlockMetadataService() {
|
||||
return blockMetadataService;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
public enum MobMetaFlagType {
|
||||
MOB_SPAWNER_MOB,
|
||||
177
src/main/java/com/gmail/nossr50/metadata/MobMetadataService.java
Normal file
177
src/main/java/com/gmail/nossr50/metadata/MobMetadataService.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.IncompleteNamespacedKeyRegister;
|
||||
import com.gmail.nossr50.config.PersistentDataConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import static com.gmail.nossr50.metadata.MetadataService.*;
|
||||
|
||||
//TODO: Use SpawnReason where appropriate instead of MobMetaFlagType
|
||||
public class MobMetadataService {
|
||||
private final @NotNull WeakHashMap<Entity, HashSet<MobMetaFlagType>> mobRegistry; //transient data
|
||||
private final @NotNull EnumMap<MobMetaFlagType, NamespacedKey> mobFlagKeyMap; //used for persistent data
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
private boolean isUsingPersistentData = false;
|
||||
|
||||
public MobMetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
mobFlagKeyMap = new EnumMap<>(MobMetaFlagType.class);
|
||||
mobRegistry = new WeakHashMap<>();
|
||||
initMobFlagKeyMap();
|
||||
|
||||
for (MobMetaFlagType metaFlagType : MobMetaFlagType.values()) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(metaFlagType))
|
||||
isUsingPersistentData = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the namespaced keys required by the API (CB/Spigot)
|
||||
* Used primarily for persistent data
|
||||
*/
|
||||
private void initMobFlagKeyMap() throws IncompleteNamespacedKeyRegister {
|
||||
for (MobMetaFlagType mobMetaFlagType : MobMetaFlagType.values()) {
|
||||
switch (mobMetaFlagType) {
|
||||
case MOB_SPAWNER_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_MOB_SPAWNER_MOB);
|
||||
case EGG_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_EGG_MOB);
|
||||
case NETHER_PORTAL_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_NETHER_GATE_MOB);
|
||||
case COTW_SUMMONED_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_COTW_SUMMONED_MOB);
|
||||
case PLAYER_BRED_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_PLAYER_BRED_MOB);
|
||||
case EXPLOITED_ENDERMEN -> mobFlagKeyMap.put(mobMetaFlagType, NSK_EXPLOITED_ENDERMEN);
|
||||
case PLAYER_TAMED_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_PLAYER_TAMED_MOB);
|
||||
default -> throw new IncompleteNamespacedKeyRegister("missing namespaced key register for type: " + mobMetaFlagType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a target {@link LivingEntity} has a specific mcMMO mob flags
|
||||
*
|
||||
* @param flag the type of mob flag to check for
|
||||
* @param livingEntity the living entity to check for metadata
|
||||
*
|
||||
* @return true if the mob has metadata values for target {@link MobMetaFlagType}
|
||||
*/
|
||||
public boolean hasMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
return livingEntity.getPersistentDataContainer().has(mobFlagKeyMap.get(flag), PersistentDataType.BYTE);
|
||||
} else {
|
||||
if (mobRegistry.containsKey(livingEntity)) {
|
||||
return mobRegistry.get(livingEntity).contains(flag);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a target {@link LivingEntity} has any mcMMO mob flags
|
||||
*
|
||||
* @param livingEntity the living entity to check for metadata
|
||||
*
|
||||
* @return true if the mob has any mcMMO mob related metadata values
|
||||
*/
|
||||
public boolean hasMobFlags(@NotNull LivingEntity livingEntity) {
|
||||
if (isUsingPersistentData) {
|
||||
for (MobMetaFlagType metaFlagType : MobMetaFlagType.values()) {
|
||||
if (hasMobFlag(metaFlagType, livingEntity))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return mobRegistry.containsKey(livingEntity) && mobRegistry.get(livingEntity).size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all mcMMO mob flags from one {@link LivingEntity} to another {@link LivingEntity}
|
||||
* This does not clear existing mcMMO mob flags on the target
|
||||
*
|
||||
* @param sourceEntity entity to copy from
|
||||
* @param targetEntity entity to copy to
|
||||
*/
|
||||
public void addMobFlags(@NotNull LivingEntity sourceEntity, @NotNull LivingEntity targetEntity) {
|
||||
if (!hasMobFlags(sourceEntity))
|
||||
return;
|
||||
|
||||
if (isUsingPersistentData) {
|
||||
for (MobMetaFlagType flag : MobMetaFlagType.values()) {
|
||||
if (hasMobFlag(flag, sourceEntity)) {
|
||||
flagMetadata(flag, targetEntity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HashSet<MobMetaFlagType> flags = new HashSet<>(mobRegistry.get(sourceEntity));
|
||||
mobRegistry.put(targetEntity, flags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mob flag to a {@link LivingEntity} which effectively acts a true/false boolean
|
||||
* Existence of the flag can be considered a true value, non-existence can be considered false for all intents and purposes
|
||||
*
|
||||
* @param flag the desired flag to assign
|
||||
* @param livingEntity the target living entity
|
||||
*/
|
||||
public void flagMetadata(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
if (!hasMobFlag(flag, livingEntity)) {
|
||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||
persistentDataContainer.set(mobFlagKeyMap.get(flag), PersistentDataType.BYTE, MetadataConstants.SIMPLE_FLAG_VALUE);
|
||||
}
|
||||
} else {
|
||||
HashSet<MobMetaFlagType> flags = mobRegistry.getOrDefault(livingEntity, new HashSet<>());
|
||||
flags.add(flag); // add the new flag
|
||||
mobRegistry.put(livingEntity, flags); //update registry
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a specific mob flag from target {@link LivingEntity}
|
||||
*
|
||||
* @param flag desired flag to remove
|
||||
* @param livingEntity the target living entity
|
||||
*/
|
||||
public void removeMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
if (hasMobFlag(flag, livingEntity)) {
|
||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||
persistentDataContainer.remove(mobFlagKeyMap.get(flag));
|
||||
}
|
||||
} else {
|
||||
if (mobRegistry.containsKey(livingEntity)) {
|
||||
mobRegistry.get(livingEntity).remove(flag);
|
||||
|
||||
if (mobRegistry.get(livingEntity).size() == 0)
|
||||
mobRegistry.remove(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all mcMMO related mob flags from the target {@link LivingEntity}
|
||||
*
|
||||
* @param livingEntity target entity
|
||||
*/
|
||||
public void removeMobFlags(@NotNull LivingEntity livingEntity) {
|
||||
if (isUsingPersistentData) {
|
||||
for (MobMetaFlagType flag : MobMetaFlagType.values()) {
|
||||
removeMobFlag(flag, livingEntity);
|
||||
}
|
||||
} else {
|
||||
mobRegistry.remove(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@@ -28,6 +29,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class PartyManager {
|
||||
private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||
@@ -347,10 +349,20 @@ public final class PartyManager {
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param party The party to remove
|
||||
* @deprecated Use {@link #disbandParty(McMMOPlayer, Party)}
|
||||
*/
|
||||
public static void disbandParty(Party party) {
|
||||
disbandParty(null, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param party The party to remove
|
||||
*/
|
||||
public static void disbandParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||
//TODO: Potential issues with unloaded profile?
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
for (final Player member : party.getOnlineMembers()) {
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(member) == null)
|
||||
{
|
||||
@@ -366,6 +378,9 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
parties.remove(party);
|
||||
if (mcMMOPlayer != null) {
|
||||
handlePartyChangeEvent(mcMMOPlayer.getPlayer(), party.getName(), null, EventReason.DISBANDED_PARTY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,6 +403,7 @@ public final class PartyManager {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
||||
addToParty(mcMMOPlayer, party);
|
||||
handlePartyChangeEvent(player, null, partyName, EventReason.CREATED_PARTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,37 +611,41 @@ public final class PartyManager {
|
||||
ArrayList<Party> hasAlly = new ArrayList<>();
|
||||
|
||||
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
Party party = new Party(partyName);
|
||||
try {
|
||||
Party party = new Party(partyName);
|
||||
|
||||
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
|
||||
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
|
||||
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
|
||||
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
|
||||
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
|
||||
if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
hasAlly.add(party);
|
||||
if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
hasAlly.add(party);
|
||||
}
|
||||
|
||||
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
|
||||
for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
}
|
||||
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
|
||||
for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) {
|
||||
String[] memberSplit = memberEntry.split("[|]");
|
||||
members.put(UUID.fromString(memberSplit[0]), memberSplit[1]);
|
||||
}
|
||||
|
||||
parties.add(party);
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "An exception occurred while loading a party with name '" + partyName + "'. Skipped loading party.", e);
|
||||
}
|
||||
|
||||
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
|
||||
for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
}
|
||||
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
|
||||
for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) {
|
||||
String[] memberSplit = memberEntry.split("[|]");
|
||||
members.put(UUID.fromString(memberSplit[0]), memberSplit[1]);
|
||||
}
|
||||
|
||||
parties.add(party);
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loaded (" + parties.size() + ") Parties...");
|
||||
|
||||
for (Party party : hasAlly) {
|
||||
party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
|
||||
@@ -641,7 +661,7 @@ public final class PartyManager {
|
||||
* Save party file.
|
||||
*/
|
||||
public static void saveParties() {
|
||||
mcMMO.p.debug("[Party Data] Saving...");
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[Party Data] Saving...");
|
||||
|
||||
if (partyFile.exists()) {
|
||||
if (!partyFile.delete()) {
|
||||
@@ -749,7 +769,7 @@ public final class PartyManager {
|
||||
// parties.add(party);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");
|
||||
// LogUtils.debug(mcMMO.p.getLogger(), "Loaded (" + parties.size() + ") Parties...");
|
||||
//
|
||||
// for (Party party : hasAlly) {
|
||||
// party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
|
||||
|
||||
230
src/main/java/com/gmail/nossr50/placeholders/PapiExpansion.java
Normal file
230
src/main/java/com/gmail/nossr50/placeholders/PapiExpansion.java
Normal file
@@ -0,0 +1,230 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import com.gmail.nossr50.api.ExperienceAPI;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class PapiExpansion extends PlaceholderExpansion {
|
||||
private final Map<String, Placeholder> placeholders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
public PapiExpansion() {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "mcmmo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "mcMMO Dev Team";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
//grab version from pom.xml
|
||||
return "1.0,0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredPlugin() {
|
||||
return "mcMMO";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String onPlaceholderRequest(final Player player, @NotNull final String params) {
|
||||
String token;
|
||||
String data = null;
|
||||
int dataPosition = params.indexOf(":");
|
||||
|
||||
if (dataPosition != -1) {
|
||||
token = params.substring(0, dataPosition);
|
||||
data = params.substring(dataPosition + 1);
|
||||
} else {
|
||||
token = params;
|
||||
}
|
||||
|
||||
Placeholder placeholder = placeholders.get(token);
|
||||
|
||||
if (placeholder != null) {
|
||||
return placeholder.process(player, data);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getSkillLevel(PrimarySkillType skill, Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
return user.getSkillLevel(skill);
|
||||
}
|
||||
|
||||
public Integer getExpNeeded(PrimarySkillType skill, Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
return user.getXpToLevel(skill);
|
||||
}
|
||||
|
||||
public Integer getExp(PrimarySkillType skill, Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
|
||||
return user.getSkillXpLevel(skill);
|
||||
}
|
||||
|
||||
|
||||
public Integer getExpRemaining(PrimarySkillType skill, Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
int current = user.getSkillXpLevel(skill);
|
||||
int needed = user.getXpToLevel(skill);
|
||||
|
||||
return needed - current;
|
||||
}
|
||||
|
||||
public Integer getRank(PrimarySkillType skill, Player player) {
|
||||
try {
|
||||
return ExperienceAPI.getPlayerRankSkill(player.getUniqueId(), StringUtils.getCapitalized(skill.toString()));
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getPowerLevel(Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
return user.getPowerLevel();
|
||||
}
|
||||
|
||||
public Integer getPowerCap(Player player) {
|
||||
return mcMMO.p.getGeneralConfig().getPowerLevelCap();
|
||||
}
|
||||
|
||||
public String getPartyName(Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
final Party party = user.getParty();
|
||||
|
||||
return (party == null) ? null : party.getName();
|
||||
}
|
||||
|
||||
public String getPartyLeader(Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
final Party party = user.getParty();
|
||||
return (party == null) ? null : party.getLeader().getPlayerName();
|
||||
}
|
||||
|
||||
public Integer getPartySize(Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
final Party party = user.getParty();
|
||||
return (party == null) ? null : party.getMembers().size();
|
||||
}
|
||||
|
||||
public String getXpRate(Player player) {
|
||||
return String.valueOf(ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
}
|
||||
|
||||
public String getSkillXpRate(PrimarySkillType skill, Player player) {
|
||||
final McMMOPlayer user = UserManager.getPlayer(player);
|
||||
if (user == null) return null;
|
||||
|
||||
double modifier = 1.0F;
|
||||
|
||||
if (Permissions.customXpBoost(player, skill))
|
||||
modifier = ExperienceConfig.getInstance().getCustomXpPerkBoost();
|
||||
else if (Permissions.quadrupleXp(player, skill))
|
||||
modifier = 4;
|
||||
else if (Permissions.tripleXp(player, skill))
|
||||
modifier = 3;
|
||||
else if (Permissions.doubleAndOneHalfXp(player, skill))
|
||||
modifier = 2.5;
|
||||
else if (Permissions.doubleXp(player, skill))
|
||||
modifier = 2;
|
||||
else if (Permissions.oneAndOneHalfXp(player, skill))
|
||||
modifier = 1.5;
|
||||
else if (Permissions.oneAndOneTenthXp(player, skill))
|
||||
modifier = 1.1;
|
||||
|
||||
return String.valueOf(modifier);
|
||||
}
|
||||
|
||||
public String isExpEventActive(Player player) {
|
||||
return mcMMO.p.isXPEventEnabled() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
}
|
||||
|
||||
public void registerPlaceholder(Placeholder placeholder) {
|
||||
final Placeholder registered = placeholders.get(placeholder.getName());
|
||||
if (registered != null)
|
||||
throw new IllegalStateException("Placeholder " + placeholder.getName() + " is already registered!");
|
||||
|
||||
placeholders.put(placeholder.getName(), placeholder);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
|
||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||
// %mcmmo_level_<skillname>%
|
||||
registerPlaceholder(new SkillLevelPlaceholder(this, skill));
|
||||
|
||||
//%mcmmo_xp_needed_<skillname>%
|
||||
registerPlaceholder(new SkillExpNeededPlaceholder(this, skill));
|
||||
|
||||
//%mcmmo_xp_<skillname>%
|
||||
registerPlaceholder(new SkillExpPlaceholder(this, skill));
|
||||
|
||||
//%mcmmo_xp_remaining_<skillname>%
|
||||
registerPlaceholder(new SkillExpRemainingPlaceholder(this, skill));
|
||||
|
||||
//%mcmmo_rank_<skillname>%
|
||||
registerPlaceholder(new SkillRankPlaceholder(this, skill));
|
||||
|
||||
//%mcmmo_xprate_<skillname>%
|
||||
registerPlaceholder(new SkillXpRatePlaceholder(this, skill));
|
||||
}
|
||||
|
||||
|
||||
//%mcmmo_power_level%
|
||||
registerPlaceholder(new PowerLevelPlaceholder(this));
|
||||
|
||||
// %mcmmo_power_level_cap%
|
||||
registerPlaceholder(new PowerLevelCapPlaceholder(this));
|
||||
|
||||
// %mcmmo_in_party%
|
||||
registerPlaceholder(new PartyIsMemberPlaceholder(this));
|
||||
|
||||
/// %mcmmo_party_name%
|
||||
registerPlaceholder(new PartyNamePlaceholder(this));
|
||||
|
||||
// %mcmmo_is_party_leader%
|
||||
registerPlaceholder(new PartyIsLeaderPlaceholder(this));
|
||||
|
||||
// %mcmmo_party_leader%
|
||||
registerPlaceholder(new PartyLeaderPlaceholder(this));
|
||||
|
||||
// %mcmmo_party_size%
|
||||
registerPlaceholder(new PartySizePlaceholder(this));
|
||||
|
||||
// %mcmmo_is_xp_event_active%
|
||||
registerPlaceholder(new XpEventActivePlaceholder(this));
|
||||
// %mcmmo_xprate%
|
||||
registerPlaceholder(new XpRatePlaceholder(this));
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartyIsLeaderPlaceholder implements Placeholder {
|
||||
|
||||
private final PapiExpansion papiExpansion;
|
||||
|
||||
public PartyIsLeaderPlaceholder(PapiExpansion papiExpansion) {
|
||||
this.papiExpansion = papiExpansion;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String process(Player player, String params) {
|
||||
String leader = papiExpansion.getPartyLeader(player);
|
||||
return (leader.equals(player.getName())) ? "true" : "false";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "is_party_leader";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartyIsMemberPlaceholder implements Placeholder {
|
||||
|
||||
private final PapiExpansion papiExpansion;
|
||||
public PartyIsMemberPlaceholder(PapiExpansion papiExpansion) {
|
||||
this.papiExpansion = papiExpansion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String process(Player player, String params) {
|
||||
return (papiExpansion.getPartyName(player) == null) ? "false" : "true";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "in_party";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartyLeaderPlaceholder implements Placeholder {
|
||||
private final PapiExpansion papiExpansion;
|
||||
|
||||
public PartyLeaderPlaceholder(PapiExpansion papiExpansion) {
|
||||
this.papiExpansion = papiExpansion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String process(Player player, String params) {
|
||||
return StringUtils.stripToEmpty(papiExpansion.getPartyLeader(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "party_leader";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartyNamePlaceholder implements Placeholder {
|
||||
private final PapiExpansion papiExpansion;
|
||||
|
||||
public PartyNamePlaceholder(PapiExpansion papiExpansion) {
|
||||
this.papiExpansion = papiExpansion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String process(Player player, String params) {
|
||||
return StringUtils.stripToEmpty(papiExpansion.getPartyName(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "party_name";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartySizePlaceholder implements Placeholder {
|
||||
private final PapiExpansion papiExpansion;
|
||||
|
||||
public PartySizePlaceholder(PapiExpansion papiExpansion) {
|
||||
this.papiExpansion = papiExpansion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String process(Player player, String params) {
|
||||
Integer partySize = papiExpansion.getPartySize(player);
|
||||
return (partySize == null) ? "" : partySize.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "party_size";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.gmail.nossr50.placeholders;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Placeholder {
|
||||
|
||||
/**
|
||||
* @param player the player to process the placeholder for
|
||||
* @param params the paramaters to be passed to the placeholder
|
||||
* @return the value of the placeholder
|
||||
*/
|
||||
String process(Player player, String params);
|
||||
|
||||
/**
|
||||
* @return the name of the placeholder
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user