1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-18 17:53:00 +01:00

Compare commits

...

230 Commits

Author SHA1 Message Date
nossr50
3e7c889f8f mcMMO 2.2.000-RC1 candidate for release 2024-03-30 06:03:25 -07:00
nossr50
e8a46d6ac8 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO into endgame 2024-03-30 05:59:37 -07:00
nossr50
39503b7038 Fix missing verdant bounty stat in herbalism command 2024-03-30 05:44:02 -07:00
nossr50
6d0fbfd02e updating changelog 2024-03-30 05:39:25 -07:00
nossr50
84cb6e3f7b add metadata cleanup for trick shot 2024-03-30 05:35:02 -07:00
gecko10000
bead5feb14 Make PAPI expansion persist (#4986) 2024-03-30 05:31:47 -07:00
nossr50
e9407246d7 update note about WIP status on tridents/xbows 2024-03-30 05:22:28 -07:00
nossr50
221175d2d3 locale changes 2024-03-30 05:08:55 -07:00
nossr50
bf901a0a34 remove unimplemented features, fix tests again, and optimize imports 2024-03-30 05:05:28 -07:00
nossr50
ef3887a720 fix unit tests 2024-03-30 04:44:10 -07:00
nossr50
fba6e8a961 merge master 2024-03-19 16:17:41 -07:00
Lorenzo Cardinali
04ed2a47d4 Fixed import errors related to Alchemy data in AdvancedConfig (#4983) 2024-03-10 18:59:15 -07:00
nossr50
7da8c8c83a 2.1.231 2024-03-09 21:16:59 -08:00
Mangchi__
4d060b192b Update locale_ko.properties (#4977)
* Update locale_ko.properties

* Update locale_ko.properties fixed-1
2024-03-09 20:17:14 -08:00
Momshroom
2117c67084 Fixed NPE when party creation doesn't use password. Solves bug reported here: https://discord.com/channels/526933440214597677/526938425161416727/1213131451235827753 (#4981)
Signed-off-by: Momshroom <Momshroom@gmail.com>
2024-03-09 20:16:14 -08:00
nossr50
4d85f24d98 2.1.230 2024-02-22 18:04:57 -08:00
nossr50
416c5383c9 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2024-02-22 17:57:17 -08:00
IAISI
7f9ed94d23 Fix exceptions on EntityCombustByEntityEvent, EntityDamageByEntityEvent, PartyAutoKickTask if parties are disabled (#4976)
* Only run EntityListener#checkParties on EntityCombustByEntityEvent if Parties are enabled

* Only run PartyAutoKickTask Task if Parties are enabled

* Only run EntityListener#checkParties on EntityDamageByEntityEvent if Parties are enabled

* Check if Parties are enabled before running inSameParty in CombatUtils#processCombatXP

---------

Co-authored-by: Dieu <info@l4b.org>
2024-02-22 17:57:05 -08:00
nossr50
b0d0030d60 2.1.230 2024-02-22 17:54:42 -08:00
IAISI
cdc187b211 Fix PartySaving related NPEs (only save parties if they're enabled) (#4973)
Co-authored-by: Dieu <info@l4b.org>
2024-02-20 09:20:08 -08:00
nossr50
3361d28887 Party system can now be disabled via config
Closes #4873
2024-02-19 17:55:57 -08:00
nossr50
c358c8ce0b Add missing getHandlerList() to McMMOEntityDamageByRuptureEvent fixes #4972 2024-02-19 16:12:39 -08:00
nossr50
aa65be0e1b dev mode 2024-02-17 16:30:47 -08:00
nossr50
70383b7250 merge master 2024-02-17 16:00:51 -08:00
nossr50
85f27fdbdb 2.1.228 2024-02-14 13:17:46 -08:00
nossr50
5bfca3c218 Fix spigot api break for entity damage events 2024-02-13 18:04:00 -08:00
nossr50
2271bd5236 wip super shotgun 2024-02-03 16:05:53 -08:00
nossr50
b0c42f8e44 enable super shotgun permission 2024-02-03 14:55:42 -08:00
nossr50
66a4886ee4 Crossbow multi-shot arrows that bounce are no longer pickup-able 2024-01-28 15:00:53 -08:00
nossr50
b3b8a12b6d Crossbow Fixes 2024-01-22 13:55:55 -08:00
nossr50
f051edd03d Tree Feller non-wood drop rate reduced by 90% 2024-01-22 13:51:15 -08:00
nossr50
377bf1be4d Tree Feller non-wood drop rate reduced by 90% 2024-01-16 12:49:42 -08:00
nossr50
dda5b45bb1 improve SQL exceptions to be more easily debuggable 2024-01-15 10:21:30 -08:00
nossr50
009d809d76 Fix bug with Excavation drop rate and misc mysql changes 2024-01-15 10:19:03 -08:00
nossr50
33cad7c2f1 typos 2024-01-14 09:45:40 -08:00
nossr50
efabaf1466 more work on end game update 2024-01-14 09:43:30 -08:00
nossr50
9cbe10827f Buff end game skills 2024-01-14 09:27:04 -08:00
nossr50
fdc308762c Hack to disable supers that aren't ready yet 2024-01-14 08:51:23 -08:00
nossr50
826d16d916 More work on Crossbows & Tridents 2024-01-04 12:39:26 -08:00
nossr50
4ba0f76eb9 Bouncing 2024-01-03 01:51:59 -08:00
nossr50
04c9db88ab more h2 compatibility stuff 2024-01-03 01:29:37 -08:00
nossr50
3fbb4827ca Update SQL schema when missing columns 2024-01-03 00:19:57 -08:00
nossr50
94754b150c Dev mode 2024-01-02 23:31:48 -08:00
nossr50
8cc4798752 Merge master 2024-01-02 23:00:23 -08:00
nossr50
415e3df226 2.1.227 2024-01-02 22:45:38 -08:00
nossr50
a941a1cc7f kill child.yml and more work on sql unit tests 2023-12-27 22:52:51 -08:00
nossr50
b0efd46584 starting work on sql unit tests 2023-12-27 21:14:14 -08:00
nossr50
dadc295431 Trickshot boiler plate stuff 2023-12-27 19:20:41 -08:00
nossr50
76d4b50554 Refactor ricochet code, don't reflect shallow angles 2023-12-27 19:20:32 -08:00
nossr50
afff3b4c50 Move projectile stuff to util 2023-12-23 17:04:19 -08:00
nossr50
1799d455b7 Deflect arrows off surfaces 2023-12-23 16:28:18 -08:00
Robert Alan Chapton
b5608ccb01 Update README.md 2023-12-23 15:53:30 -08:00
Robert Alan Chapton
d57e225576 Update README.md 2023-12-23 15:53:08 -08:00
Robert Alan Chapton
2f166507ca Update README.md 2023-12-23 15:50:49 -08:00
nossr50
9360e147ac Fun with arrows 2023-12-22 13:07:34 -08:00
nossr50
967ffd6442 update Changelog.txt 2023-12-22 11:39:13 -08:00
nossr50
5f63faf65d Unit test refactor 2023-12-22 11:37:17 -08:00
nossr50
7973ccc848 Update FlatFile for new skill cds 2023-12-22 11:05:26 -08:00
MithicSpirit
347e6112fb Make mcMMO anvil sounds categorized (#4954)
Default anvil sound is way too loud, and being in the master category
makes it hard to manage player-side without making the entire game too
soft.
2023-12-21 17:54:29 -08:00
Min Sa-Hun
65dfcb492d Renewed and completed the Korean locale (#4956)
Co-authored-by: Pindang2 <workspace@pindang2.com>
2023-12-21 17:53:38 -08:00
YuanYuanOwO
23a549a6d3 Update locale_zh_CN.properties (#4953)
Update language file to fix a typo error
2023-12-21 17:52:51 -08:00
nossr50
7e3826a4d6 WIP starting work on supers for archery/crossbow 2023-12-20 19:26:22 -08:00
nossr50
3e11b7da2c Add Explosive Shot definition 2023-12-20 19:11:08 -08:00
nossr50
23b8e0a28c Add BowType metadata 2023-12-20 16:53:20 -08:00
nossr50
25952154e3 Add in trident command 2023-12-19 11:17:22 -08:00
nossr50
c8dedfc980 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into endgame 2023-12-17 16:07:52 -08:00
nossr50
a522ab7b2f updata todo note 2023-12-16 17:59:40 -08:00
nossr50
a0923ad786 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2023-12-16 17:46:37 -08:00
nossr50
dd04ee48b9 2.1.226 2023-12-16 17:45:17 -08:00
PikaMug
89b895af81 Update pom.xml with WorldEdit (#4951) 2023-10-27 11:19:38 -07:00
nossr50
9e1f5b44a6 dev mode 2023-10-15 12:29:27 -07:00
nossr50
a54590576f 2.1.225 2023-10-15 12:18:12 -07:00
Spongecade
06160c6d04 Update Minecraft wiki link to new domain (#4944) 2023-10-15 10:47:21 -07:00
nossr50
12e5a7f054 Bamboo is now treated like a cactus/sugar cane 2023-10-08 16:51:59 -07:00
nossr50
1f20e6344b 2.1.224 2023-10-02 18:16:02 -07:00
nossr50
13ba51cdf1 Fixed some mistakes in shake config 2023-09-30 15:46:20 -07:00
nossr50
4f22391465 Spelling/Grammar 2023-09-30 15:44:56 -07:00
nossr50
5f1a545437 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2023-09-30 15:43:30 -07:00
nossr50
bad7023129 Shake has 8 ranks again 2023-09-30 15:43:19 -07:00
Huynh Tien
785f18c13a update FoliaLib (#4935)
- fix an issue with 0 ticks setting
- disable scheduler warning
2023-09-03 16:41:35 -07:00
nossr50
357995ecb0 2.1.223 Folia Support Added 2023-08-26 16:21:09 -07:00
nossr50
3e26eca48e Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2023-08-26 16:17:39 -07:00
nossr50
dd339c20ea Updated API 2023-08-26 16:17:31 -07:00
Yomamaeatstoes
c34230a82e mcMMO-Folia-PR (#4925)
Folia Support

---------

Co-authored-by: Rockyers <ethan@yocom.org>
Co-authored-by: TechnicallyCoded <technicallycoded@gmail.com>
Co-authored-by: HSGamer <huynhqtienvtag@gmail.com>
2023-08-26 16:16:18 -07:00
Greymagic27
192626f4da Fix packaging error on windows #4911 (#4919) 2023-08-19 14:23:05 -07:00
nossr50
24a57fab3d 2.1.222 2023-07-09 14:43:38 -07:00
nossr50
78596dc00e Glow Lichen nerf 2023-06-25 13:51:00 -07:00
nossr50
0b1b753d4c Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2023-06-25 13:47:25 -07:00
nossr50
3cbdcddcc1 Crossbows do not count as unarmed item with unarmed items setting 2023-06-25 13:47:04 -07:00
dependabot[bot]
25ecb6e1de Bump guava from 31.1-jre to 32.0.0-jre (#4903)
Bumps [guava](https://github.com/google/guava) from 31.1-jre to 32.0.0-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

---
updated-dependencies:
- dependency-name: com.google.guava:guava
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-19 18:46:30 -07:00
nossr50
019d22d92a Make mcMMO quieter by moving most log messages to debug only 2023-06-19 16:26:30 -07:00
nossr50
e39022cc64 2.1.221 2023-06-19 14:11:53 -07:00
nossr50
a41106ee30 Update changelog 2023-06-17 20:34:18 -07:00
nossr50
b2110d4e1c PAPI Support pt 2 2023-06-17 20:32:51 -07:00
nossr50
f22043ebb5 PAPI Support WIP 2023-06-17 20:22:49 -07:00
nossr50
cc1b511c02 Don't look up offline players by name 2023-06-17 15:56:36 -07:00
nossr50
cbcddbf528 Merge master 2023-05-29 14:41:43 -07:00
nossr50
e9a020565f Added fail safes against bonus drop meta not being cleaned up 2023-05-29 14:34:47 -07:00
nossr50
44ab8d93ab Dev mode 2023-05-29 14:15:04 -07:00
Warrior
78922ea337 Fix blast mining bonus drops option not working (#4895) 2023-05-29 13:58:24 -07:00
nossr50
75ace0cfa0 Merge master 2023-05-13 15:02:04 -07:00
nossr50
db01b61371 2.1.220 2023-05-13 14:42:14 -07:00
nossr50
d30b2f7bf6 Fixed divide by zero bug impacting tridents XP when missing from config 2023-04-23 13:23:18 -07:00
Warrior
133a60c4bf Fix child skills counting towards power level in /inspect (#4889) 2023-04-23 11:08:06 -07:00
nossr50
72957c3d31 Add XP test for Woodcutting 2023-04-19 14:13:17 -07:00
nossr50
4f79f7881c Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO into endgame 2023-04-17 12:17:45 -07:00
nossr50
684e96ff6b Fix RankConfig 2023-04-17 12:17:28 -07:00
nossr50
f88dfe479e Pull master 2023-04-17 12:16:06 -07:00
nossr50
f40f68bdf0 Fix RankConfig not using the new updating config system 2023-04-17 12:07:59 -07:00
nossr50
640f4b0a9b Fix mcMMO attempting to copy out custom repair/salvage configs 2023-04-17 12:07:41 -07:00
nossr50
978ee4a9a3 Optimize the imports 2023-04-11 15:49:37 -07:00
nossr50
0ab93586fd Config files will update automatically again 2023-04-11 15:48:14 -07:00
nossr50
7af0bc468a Config files will update automatically again 2023-04-11 15:39:01 -07:00
nossr50
dc1d2540db Fixed UnarmedManager being used for Tridents 2023-04-11 04:24:48 -07:00
nossr50
aaa47d3b67 Add some combat processing logic for Tridents/Xbows 2023-04-11 04:17:29 -07:00
nossr50
63e7c09ed4 Added missing locale strings for Xbows/Tridents 2023-04-11 03:43:16 -07:00
nossr50
5b9ab65c78 Add Xbows/Tridents to combat skills list 2023-04-11 03:34:02 -07:00
nossr50
fc9287622d Add missing skill command definitions to plugin.yml 2023-04-11 03:28:15 -07:00
nossr50
534b22233d More work on Xbows/Tridents 2023-04-11 03:16:24 -07:00
nossr50
0db1d846bc Add missing parent definitions for Xbows/Tridents 2023-04-08 16:36:59 -07:00
nossr50
2c49f8ffeb Fixed failing tests + improved support for Xbows/Tridents 2023-04-08 16:30:32 -07:00
nossr50
921a0228db Merge remote-tracking branch 'origin/master' 2023-04-07 17:00:13 -07:00
nossr50
ac68c4ebe6 2.1.219 2023-04-07 17:00:01 -07:00
nossr50
8bb50fb53c Add Tridents/Xbows (WIP) 2023-04-03 17:57:33 -07:00
Smudge
4553310bb9 Fixed fishing exploiting compatibility (#4859)
* Fixed fishing exploiting compatibility

* Moved same target to class variable
2023-04-03 17:52:00 -07:00
Warrior
9b0632d63c Make party loading more resilient (#4881) 2023-04-03 17:49:35 -07:00
Warrior
69ef484b86 Fix dots not being replaced when renaming party (#4882) 2023-04-03 17:48:53 -07:00
Warrior
606a92f1ef Fix /party teleport NPE (#4885) 2023-04-03 17:48:01 -07:00
nossr50
02c5aa4628 Remove unused config values 2023-04-03 16:53:57 -07:00
nossr50
576b3c476c Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO into endgame 2023-04-03 16:50:05 -07:00
nossr50
79730383ab Fixed wiki url being incorrect in various commands 2023-04-03 16:47:58 -07:00
nossr50
68d4a179f1 merge master 2023-04-03 12:12:17 -07:00
nossr50
7264e1a8d6 Small tweaks 2023-04-03 12:07:34 -07:00
nossr50
e011f545a7 Added smithing_table to tool readiness blacklist 2023-04-02 20:44:00 -07:00
nossr50
283fa14380 Add Camel, Sniffer, and Snifflet to taming XP 2023-04-02 20:42:06 -07:00
nossr50
5f388a9906 Add support for torchflower replanting to herbalism 2023-04-02 20:38:05 -07:00
nossr50
cd96bc79d8 Change isHerbalismDrop to use strings.. this method still needs more work 2023-04-02 20:24:04 -07:00
nossr50
ae961caeab Added Torchflower to herbalism experience and bonus drops 2023-04-02 20:11:10 -07:00
nossr50
0b4d87aebc Add Sniffer and Snifflet to combat experience in experience.yml 2023-04-02 20:07:50 -07:00
nossr50
6106f70c24 Added Pitcher_Plants to bonus drops and herbalism experience 2023-04-02 20:05:52 -07:00
nossr50
100a7f8a8f Added pink_petals, cherry_wood, and cherry_log to bonus drops in config.yml 2023-04-02 20:02:32 -07:00
nossr50
4c792c4f2c Added Pink_Petals to experience.yml 2023-04-02 20:00:58 -07:00
nossr50
db4b820f80 Add new hanging signs to tool readiness blacklist 2023-04-02 19:58:16 -07:00
nossr50
ca710b4302 Add chiseled_bookshelf to tool readiness blacklist 2023-04-02 19:55:30 -07:00
nossr50
668cc0e4a3 Add support for upcoming Cherry trees 2023-04-02 19:53:13 -07:00
nossr50
6845fb4c44 Fix some bugs with new Probability type and unit tests 2023-03-26 13:41:31 -07:00
nossr50
6d0542b524 Merge remote-tracking branch 'origin/master' 2023-03-26 13:22:41 -07:00
nossr50
d84a5b37b7 Update kyori dependencies 2023-03-26 13:22:31 -07:00
optimizing-ci-builds
c072ae4990 disable xml report (#4880) 2023-03-21 22:05:40 -07:00
nossr50
2d78eaa495 Fixed Beetroots double drop issue #4667 2023-03-19 21:21:54 -07:00
nossr50
36adde7b3d Added some unit tests for double drops, fixed bug with bonus drops 2023-03-19 20:18:17 -07:00
Warrior
6bdc51be76 Fix missing return in notify command (#4870) 2023-02-25 15:20:45 -08:00
nossr50
af15617196 Add config toggle for Blast Mining bonus drops to advanced.yml 2023-02-19 13:40:14 -08:00
nossr50
e4470fd061 More work on end game skills 2023-02-18 23:44:01 -08:00
CuteLittleSky
643dff7915 Update locale_zh_CN.properties (#4858) 2023-02-09 18:16:26 -08:00
Justin
01fbfccc0d feat: Make power level display for offline players (#4861)
Fixes #4599
2023-02-09 18:12:46 -08:00
Jok
2362fe994a Don't call EntityDamageByEntityEvent with null damager (#4863)
Co-authored-by: Elioby <elioby@users.noreply.github.com>
2023-02-09 18:11:30 -08:00
nopeless
08b08b1285 Fix: player is no longer immune to projectiles shot by themselves (#4856) 2023-01-28 11:57:31 -08:00
nossr50
12fb4a3679 Refactor probability tests a little bit 2022-12-18 17:08:36 -08:00
nossr50
4a5e3542ef Add static chance skills to probability unit tests 2022-12-18 16:49:30 -08:00
nossr50
59f711834b Refactor Probability API a bit 2022-12-18 16:02:43 -08:00
nossr50
7f66d27141 Rename test 2022-12-18 15:06:44 -08:00
nossr50
11cf882830 Probability factory should live within the interface 2022-12-18 15:04:59 -08:00
nossr50
05c86f1125 Add some unit tests for new RNG dice rolls 2022-12-11 15:38:04 -08:00
nossr50
b077d9e0fb Fix compilation errors 2022-12-04 17:50:43 -08:00
nossr50
bb44e56bdb Merge master into endgame branch to prepare merge for beta 2.2.000 update 2022-12-04 15:58:23 -08:00
nossr50
965540dfaf 2.1.218 2022-12-04 14:32:34 -08:00
destro174
75822472fc Add item in mainhand when spawning in lumber bonus blocks. (#4826) 2022-12-04 14:22:37 -08:00
Daniil Z
59aecb79a1 Update Russian locale (#4832)
Added/updated some lines
Fixed new-line characters
2022-12-04 14:21:44 -08:00
DarkKnights22
c865c2d2e3 Fix bug where players could know staff are invis (#4833)
* Fix bug where players could know staff are invis

* remove whitespace
2022-12-04 14:21:22 -08:00
MrPowerGamerBR
93c64a8770 Fix pt_BR ability on typo (#4837) 2022-12-04 14:19:48 -08:00
Greymagic27
30ac82181e Updated plugins to latest version (#4817) 2022-08-09 07:35:12 -07:00
nossr50
2b219f48ec Dev mode 2022-08-07 16:13:18 -07:00
nossr50
fed0483d40 2.1.217 2022-08-07 16:03:55 -07:00
nossr50
101c43a4bc Tree Feller now partially destroys trees if the whole tree is too big
Fixes #4811
2022-08-07 15:55:19 -07:00
nossr50
fb738d85f6 Mangrove trees are now properly marked natural from growth
Fixes #4810
2022-08-07 15:54:22 -07:00
nossr50
032a407c8a Update changelog and version 2022-08-07 14:27:42 -07:00
Greymagic27
33e615f0f1 Updated dependencies to fix hovering over subskills for 1.19.2 (#4814)
* Updated dependencies that should fix the issue

* Updated spigotmc version

* Updated rest of dependencies

* Updated dependencies that fix the issue. Investigating what dependency update breaks compiling.

* Found the dependency that caused the compile issue, so have not updated that one
2022-08-07 14:19:46 -07:00
dod0lp
8feba60e2c Update config.yml (#4809) 2022-08-03 07:43:03 -07:00
nossr50
8a4fe8ae5d 2.1.216 2022-07-24 10:09:48 -07:00
nossr50
45f96793a5 Revert "Players who used unarmed combat are still considered using unarmed while not holding weapons for a brief time period"
This reverts commit 993b418fbc.
2022-07-24 10:05:56 -07:00
nossr50
df0362bcba Allow mining benefits while using Hoe 2022-07-23 17:04:43 -07:00
nossr50
25d558a5fa Added Sculk blocks to Mining 2022-07-23 16:57:42 -07:00
nossr50
c0e4d7a43d 2.1.215 - Unarmed change + Bug Fixes 2022-07-23 16:22:02 -07:00
nossr50
993b418fbc Players who used unarmed combat are still considered using unarmed while not holding weapons for a brief time period 2022-07-23 16:13:49 -07:00
nossr50
9cf856221d update changelog 2022-07-23 14:47:32 -07:00
nossr50
4db6e03517 Hacky workaround for Spigot API bug not showing burntime to the client when burntime was too high 2022-07-23 14:43:24 -07:00
nossr50
eb1393c02c Fix burnTime debug prints on mmodebug players 2022-07-23 14:24:31 -07:00
nossr50
e1a54b72a9 update changelog 2022-07-23 13:34:38 -07:00
Greymagic27
b266c7ce5b Updated Dependencies (#4798)
* Updated Dependencies

* Fix spelling mistake in dependencies

* Fixed dependency error that would prevent the plugin from loading.

Turned out I put in the wrong acf-bukkit, preventing the plugin from working. Oops!
2022-07-17 14:59:19 -07:00
nossr50
38f937fa01 revert potential furnace animation bug fix 2022-07-17 14:56:44 -07:00
nossr50
6d7982c0cf Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2022-07-17 14:03:10 -07:00
nossr50
89fa26d0eb Potential fix for #3005 2022-07-17 14:00:03 -07:00
Greymagic27
edd85c2f19 Updated kyori adventure-platform dependencies (#4797) 2022-07-17 13:38:44 -07:00
Greymagic27
88b6517f88 Added Dripstone Block to experience.yml (#4796) 2022-07-15 15:07:19 -07:00
PikaMug
2c09a0fdb6 Switch to new sk89q repo (#4791) 2022-07-02 19:25:27 -07:00
nossr50
90721ee859 Add missing Mangrove_Log to experience.yml 2022-06-26 18:43:09 -07:00
destro174
aa4011a226 Use item in mainhand to get drops when using treefeller (#4781) 2022-06-11 16:41:27 -07:00
nossr50
fa82fe8e67 Level up broadcasts should be visible to the player of origin 2022-06-09 22:50:36 -07:00
nossr50
444e1532f2 2.1.214 2022-06-09 22:39:11 -07:00
Smudge
1a34d2f647 Added 25% xp boost permission (#4773) 2022-06-09 14:31:06 -07:00
abridgedcarp
d543843235 Fix Maven build failure (#4779) 2022-06-09 14:26:50 -07:00
nossr50
c40af913f4 mcMMO 2.1.213 2022-06-07 18:07:14 -07:00
nossr50
f6268fe291 Add in new 1.19 stuff and tweak treasures.yml 2022-06-07 18:00:32 -07:00
nossr50
27854720f0 Add some exploit prevention to fishing 2022-05-15 15:24:25 -07:00
nossr50
d19cf1e260 2.1.212 - Fixed herbalism exploit and added damage limit for XP
calculations used in combat
2022-04-28 18:31:10 -07:00
Warrior
4a8630262e Fix hanging plants searching up instead of down. (#4766) 2022-04-28 08:33:45 -07:00
Werner
c41d2d1f39 Bump shade-plugin to 3.3.1 (#4762)
fixes building
2022-04-10 13:09:03 -07:00
nossr50
8821fb0b2f 2.1.211 2022-03-18 15:07:02 -07:00
nossr50
5ab55c1653 mcMMO will no longer use the DamageModifier API (potentially fix immortal player bug) 2022-03-17 19:58:42 -07:00
nossr50
8066f7f7f2 Tweak damage debug info to show modifier values 2022-03-17 16:08:50 -07:00
nossr50
5ea18e8ba7 Add combat debug info for player versus player combat /mmodebug 2022-03-17 15:03:42 -07:00
nossr50
0bf3f98d95 2.1.210 2022-03-17 13:59:17 -07:00
nossr50
fa33fa3d32 Revert 3 commits (work will be continued in branch)
Revert "Disabling mcMMO when the config breaks is dumb"

This reverts commit 86e7bfbf89.

Revert "Config validation rewrite part 1"

This reverts commit 16e90da8fd.

Revert "Update changelog"

This reverts commit 0ccd89fad4.
2022-03-17 13:49:46 -07:00
nossr50
3e937c183f Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO into endgame 2021-03-02 15:23:30 -08:00
nossr50
1a180c4cdf Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO into endgame 2021-02-26 16:22:11 -08:00
nossr50
f039b4cbfa Fix display values for RNG 2021-02-23 19:22:39 -08:00
nossr50
6a3671a190 RandomChanceUtil refactor part 4 2021-02-18 16:41:57 -08:00
nossr50
e30c7110eb RandomChanceUtil refactor part 3 2021-02-18 12:48:16 -08:00
nossr50
fe889cf1c5 RandomChanceUtil Refactor part 2 2021-02-17 16:32:40 -08:00
nossr50
f7640938df RandomChanceUtil refactor part 1 2021-02-17 15:28:27 -08:00
nossr50
1bde79cd6f add toggle for sending chat messages to console
Fixes #4415
2021-02-10 10:05:42 -08:00
nossr50
addf9b0431 Add Clean Cuts to Woodcutting 2021-02-08 14:54:16 -08:00
nossr50
32b41b3fd3 Update references to mastery in en_us for Mining to Mother Lode 2021-02-08 12:13:53 -08:00
nossr50
73e36b11b3 rename references to mining mastery -> mother lode 2021-02-08 12:02:27 -08:00
nossr50
1ff2c0dcfc Add Mother Lode mastery subskill to Mining 2021-02-08 11:57:43 -08:00
nossr50
39a6c31894 Add permission nodes for mastery subskills 2021-02-08 11:02:12 -08:00
nossr50
9303d441b1 Change condition on power level command 2021-02-05 16:35:12 -08:00
nossr50
ce09a8bcdc get mmopower working 2021-02-05 16:26:46 -08:00
nossr50
eda227006f endgame progression WIP 2021-02-04 14:56:06 -08:00
305 changed files with 8290 additions and 5441 deletions

View File

@@ -49,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
View File

@@ -55,3 +55,4 @@
# Atlassian Stuff
/atlassian-ide-plugin.xml
/nulllocale_override.properties

View File

@@ -1,9 +1,265 @@
Version 2.1.210
Fixed a memory leak involving mob metadata
mcMMO doesn't disable itself when configs are invalid anymore
mcMMO will fix bad config values when loading (WIP)
Version 2.2.000
General
Added Crossbows Skill, this skill is a WIP and feedback on discord is appreciated
Added Tridents Skill, this skill is a WIP and feedback on discord is appreciated
Added the "endgame" triple drop subskill 'Mother Lode' to Mining
Added the "endgame" triple drop subskill 'Clean Cuts' to Woodcutting
Added the "endgame" triple drop subskill 'Verdant Bounty' to Herbalism
Added /mmopower command which simply shows your power level (aliases /mmopowerlevel /powerlevel)
Config
Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console
Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs
child.yml config is gone now, feel free to delete it
Tweaks
Tree Feller now drops 90% less non-wood block rewards (leaves/etc) on average from Knock on Wood.
Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk
Updated advanced.yml with entries for the new skills
Permission nodes
Added 'mcmmo.commands.mmopower' permission node for the new /mmopower command
Added 'mcmmo.commands.crossbows' permission node
Added 'mcmmo.ability.crossbows.crossbowslimitbreak' permission node
Added 'mcmmo.ability.crossbows.trickshot' permission node
Added 'mcmmo.ability.herbalism.verdantbounty' permission node
Added 'mcmmo.ability.mining.motherlode' permission node
Added 'mcmmo.ability.woodcutting.cleancuts' permission node
Locale
Added locale entries for motherlode, cleancuts, and verdant bounty
Codebase
Major rewrite for how random chance was handled in the code
Many skills with RNG elements now send out a SubSkillEvent (which can be used to modify probability or cancel the results), some skills without RNG still send out this event when activated, this event is cancellable so it can be used to make a skill fail
A lot of new unit tests were added to help keep mcMMO stable as part of this update, of course, more could always be added.
NOTES:
One feature of this update is to provide a endgame benefits to some skills that you can grind for a long time, ideally for a long while. I will likely expand upon this idea in future updates.
A few skills have these endgame oriented subskills, these new subskills provide a small benefit at first that grows and scales up to level 10,000 (or 1,000 for Standard mode which no one uses) and does not have ranks (other than the initial rank to unlock it).
These endgame sub skills unlock at level 1000 for users with default mcMMO settings, or 100 for those using the optional Standard scaling.
You can tweak the benefits of these skills in advanced.yml, the default settings are meant to be a good starting point.
Crossbows and Tridents are WIP skills, I would like feedback on discord about them.
More info on the new Triple Drop skills (Mother Lode, Clean Cuts, Verdant Bounty):
Currently these start at about 5% chance and can reach a maximum 50% chance if a player acquired 10,000 skill, you can adjust this in advanced.yml
These skills respect double drop settings from config.yml just like the corresponding Double Drop skills do, if a double drop is disabled for an item, then its disabled for triple drops too.
I added a new Power Level Command, for now this just shows you your current power level. If I ever add features based on power level, this command will likely display output related to those features.
Regarding Maces, I will likely add that as a WIP skill when the next Minecraft update drops.
Version 2.1.231
Fixed a bug preventing parties from being made without passwords (Thanks Momshroom)
Updated korean locale (thanks mangchi57)
Added some unit tests for party creation
Version 2.1.230
Fixed an error that could happen when mcMMO was saving when parties were disabled by party.yml (thanks IAISI & L4BORG)
Fixed several exceptions when checking PVP damage when parties were disabled by party.yml (thanks IAISI & L4BORG)
Version 2.1.229
Added new party.yml config, which lets admins disable the party system entirely without having to use permissions
Fixed error caused by missing API in McMMOEntityDamageByRuptureEvent
(API) Major API changes to PartyManager
(API) PartyManager is no longer a static singleton class, use mcMMO.getPartyManager() to get the PartyManager
(API) Added com.gmail.nossr50.mcMMO.isPartySystemEnabled to check if the party system is enabled
(API) Added com.gmail.nossr50.api.PartyAPI.isPartySystemEnabled as an alternative, to check if the party system is enabled
(API) Added missing com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent.getHandlerList
NOTES:
Admins can now enable/disable the whole party system with a setting in the new party.yml config
You'll have to start your server one time to generate the config, then change the setting and reboot your server.
Version 2.1.228
Fixed a stack trace due to Spigot API break on EntityDamageEvent and EntityDamageByEntity event
(API) - Removed FakeEntityDamageEvent and FakeEntityDamageByEntityEvent
(API) - Reworked McMMOEntityDamageByRuptureEvent, this no longer extends EntityDamageByEntityEvent, instead it extends EntityEvent
Notes:
Some care went into keeping mcMMO compatible with older versions despite a big API break from Spigot, this may introduce some new bugs, so please report them if you run into any.
Version 2.1.227
Fixed bug where some text would not be displayed to players (Adventure dependency update)
Repair sound effect from mcMMO can now be adjusted in Minecraft sound options (Thanks MithicSpirit)
Korean locale updated (Thanks Pindang2)
Simplified Chinese locale updated (Thanks YuanYuanOwO)
NOTES:
For those curious, mcMMO uses Adventure to do a lot of the message sending to players.
It typically needs updating when new versions of MC come out, sorry for the delay on my part.
Version 2.1.226
Added Short_Grass to experience.yml for Herbalism
Updated Hylian Treasures "Bushes" alias to use short_grass when playing on new Minecraft versions
Fixed dirt_path and grass_block not being correctly whitelisted for herbalism abilities
Version 2.1.225
Fixed text from mcMMO not being sent or displayed to the player
Updated Adventure dependencies
Added new API McMMOPlayerNotificationEvent.getPlayer
Version 2.1.224
Updated to a new build of ACF to fix NoSuchFieldException locale
Improved Folia Support (Thanks HSGamer)
Fishing Shake has 8 ranks again
NOTES:
At some point Shake got reduced to 1 rank, this didn't really make sense as it was meant to be a skill that ranked up and got better over time.
It now has 8 ranks again, you may need to update advanced.yml and skillranks.yml to get the new ranks.
Version 2.1.223
Folia Support added (Thanks to HSGamer, TechnicallyCoded, Rockyers, and Yomamaeatstoes)
NOTES: This update brings mcMMO to Folia, not all features are guaranteed to work but from limited testing it appears to be working well.
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
@@ -1126,7 +1382,7 @@ Version 2.1.128
Fixed a bug where certain types of ore did not receive bonuses from Blast Mining
Fixed a few locale errors with commands
(API) Added ExperienceAPI::addCombatXP for adding combat XP to players, signature may change so its deprecated for now
mcMMO now logs whether or not its using FlatFile or SQL database on load
mcMMO now logs whether its using FlatFile or SQL database on load
(1.16) Strider added to combat experience with a value of 1.2
NOTES: A more thorough look at Unarmed balance will happen in the future, the intention of this nerf is to make Unarmed less rewarding until it is leveled quite a bit.
@@ -1146,7 +1402,7 @@ Version 2.1.127
Version 2.1.126
mcMMO now relies on NMS for some of its features, if NMS cannot properly be wired up when initializing mcMMO behaviours relying on NMS will either be partially supported or disabled
mcMMO now has a compatibility mode, any features that require specific versions of Minecraft for full functionality will be disabled if your server is not running a compatible version, mcMMO will still function in compatibility mode, but either the feature will be modified or disabled depending on the version of the server software
New command /mmocompat - Shows information about whether or not mcMMO is fully functional or if some features are disabled due to the server software not being fully supported. Can be used by players or console.
New command /mmocompat - Shows information about whether mcMMO is fully functional or if some features are disabled due to the server software not being fully supported. Can be used by players or console.
New command /mmoxpbar (alias /xpbarsettings) - Players can choose to always show XP bars or to never show XP bars on a per skill basis
XPBars now last for 3 seconds before hiding instead of 2 seconds
Fixed an exploit involving fishing rods
@@ -1782,7 +2038,7 @@ Version 2.1.68
Fixed a bug where consuming food in the off hand did not trigger the Diet abilities
Version 2.1.67
The XP bar now reflects whether or not the player is receiving the early game boost
The XP bar now reflects whether the player is receiving the early game boost
Players who are receiving an early game boost will be shown "Learning a skill..." as the title of the XP bar while gaining XP
New locale string 'XPBar.Template.EarlyGameBoost'
@@ -1831,7 +2087,7 @@ Version 2.1.63
Version 2.1.62
Added a new admin notification system, sensitive commands will print chat messages to "admins" (players with either Operator status or admin chat permission)
Added a setting to disable the new admin notifications to config.yml 'General.AdminNotifications' (this will be more configurable in 2.2)
OPs and players with the admin chat permission will now see details about XP rate event commands regardless of whether or not the XP rate event messages are enabled
OPs and players with the admin chat permission will now see details about XP rate event commands regardless of whether the XP rate event messages are enabled
Updated hu_HU locale (thanks andris155)
Added XP for mining Magma_Block (default 30 XP - Update your config, see notes)
Diamond tools & armor in the repair config now have a minimum level of 0 (Update your config, temporary hotfix, 2.2 addresses this issue, see notes)
@@ -1839,9 +2095,9 @@ Version 2.1.62
New locale string - 'Server.ConsoleName' the name of the server console, this will be used in place of player names when sending admin notifications out if the command was used from console
New locale string - 'Notifications.Admin.Format.Others' style formatting + prefix for admin notifications used in the other new strings below
New locale string - 'Notifications.Admin.Format.Self' style formatting + prefix for admin command confirmations sent to the user who executed the command
New locale string - 'Notifications.Admin.XPRate.Start.Self' sent to the user who modifies the XP rate regardless of whether or not messages for the event are enabled
New locale string - 'Notifications.Admin.XPRate.Start.Self' sent to the user who modifies the XP rate regardless of whether messages for the event are enabled
New locale string - 'Notifications.Admin.XPRate.Start.Others' details of who started an XP rate event are sent to players who have Operator status or admin chat permission when the command to start or modify XP of an event has been issued
New locale string - 'Notifications.Admin.XPRate.End.Self' sent to the user who ended the XP rate event regardless of whether or not messages for the event are enabled
New locale string - 'Notifications.Admin.XPRate.End.Self' sent to the user who ended the XP rate event regardless of whether messages for the event are enabled
New locale string - 'Notifications.Admin.XPRate.End.Others' details of who ended an XP rate event are sent to players who have Operator status or admin chat permission when the command to end the event has been issued
NOTES:
@@ -2112,7 +2368,7 @@ Version 2.1.26
Notes:
The new Limit Break subskills are intended to make Prot IV players less tanky and for you to feel more powerful for having high skill level.
Limit Break has 10 ranks, each rank gives 1 extra RAW damage, this is damage before reductions from armor and enchantments. The net result is you deal about 50% more damage with an end game skill compared to before.
Limit Break has 10 ranks, each rank gives 1 extra RAW damage, this is damage before reductions from armor and enchantments. The net result is you deal about 50% more damage with an endgame skill compared to before.
With these new changes, most skills can 2 shot normal diamond armor, and it takes about 5 hits to kill someone in Prot IV Diamond Armor.
I'm not sure everyone will like these changes, the net result is players are a lot easier to kill now, whereas before you could take quite a beating before getting killed.
I collected several sets of data before making these changes, including damage to player with and without prot 4 diamond armor, damage to those players with and without enchanted weapons, damage with and without leveling your skills, and combinations of the previously mentioned things.
@@ -3813,7 +4069,7 @@ Removed performance debugging
Removed some useless settings from the config file
Version 1.0.34
Fixed the PVP setting determining whether or not you would hurt yourself from AoE Abilities
Fixed the PVP setting determining whether you would hurt yourself from AoE Abilities
Added Dutch (nl) language support
Super Breaker now gives the correct XP as determined by config.yml
Sand Stone XP is now configurable and no longer shares the 'stone' node
@@ -3823,7 +4079,7 @@ Version 1.0.33
Fixed the toggle for the Excavation drop 'Cocoa Beans'
Fixed bug where Unarmed users could disarm without being bare handed
Cocoa Beans now have an XP modifier in config.yml
You can now toggle whether or not Mobspawners will give XP (in config.yml)
You can now toggle whether Mobspawners will give XP (in config.yml)
MySQL version now makes requests to the MySQL server less frequently (should help performance)
Fixed bug with Skull Splitter hitting the user

View File

@@ -11,7 +11,12 @@ Spigot Resource: https://spigot.mcmmo.org
I plan to post links to our new wiki (its still under development), downloads, and dev blogs there.
### Builds
Currently, you can obtain our builds via the Spigot resource page: http://spigot.mcmmo.org
Currently, you can obtain our builds via the Spigot or Polymart:
http://spigot.mcmmo.org
https://polymart.org/resource/mcmmo.727
### Brief Description
The goal of mcMMO is to take core Minecraft game mechanics and expand them into an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
@@ -21,20 +26,14 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
#### Project Lead & Founder
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50)
#### mcMMO Devs
#### Current mcMMO Devs
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50)
[![kashike](https://secure.gravatar.com/avatar/b5e86d6d443b957fd5cdee55501f3799.png)](https://github.com/kashike)
[![electronicboy](https://secure.gravatar.com/avatar/44759c38d311ce09596de6a2d5b88036.png)](https://github.com/electronicboy)
#### Classic Maintainer
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
## Former Team Members
### Former Lead & Awesome guy
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)](https://github.com/gmcferrin)
### Former team members
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)](https://github.com/gmcferrin)
[![kashike](https://secure.gravatar.com/avatar/b5e86d6d443b957fd5cdee55501f3799.png)](https://github.com/kashike)
[![electronicboy](https://secure.gravatar.com/avatar/44759c38d311ce09596de6a2d5b88036.png)](https://github.com/electronicboy)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)](https://github.com/bm01)
[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)](https://github.com/Glitchfinder)
[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)](https://github.com/NuclearW)
@@ -43,20 +42,23 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)](https://github.com/riking)
[![TheYeti](https://i.imgur.com/tzFrxdo.png)](https://github.com/TheYeti)
#### Folia Contributors
[<img src="https://github.com/HSGamer.png" width=80 alt="HSGamer">](https://github.com/HSGamer)
[<img src="https://github.com/TechnicallyCoded.png" width=80 alt="TechnicallyCoded">](https://github.com/TechnicallyCoded)
[<img src="https://github.com/Yomamaeatstoes.png" width=80 alt="Yomamaeatstoes">](https://github.com/Yomamaeatstoes)
[<img src="https://github.com/Rockyers.png" width=80 alt="Rockyers">](https://github.com/Rockyers)
## Compiling
mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
mcMMO uses Maven to manage dependencies, packaging, and shading of necessary classes; Maven is required to compile mcMMO. It is recommended to always use the latest version of maven.
The typical command used to build mcMMO is: `mvn clean package install`
Required Libraries:
* Spigot
* JUnit
* WorldGuard 7
* bStats Bukkit
The typical command used to build mcMMO is: `mvn clean install`
https://spigot.mcmmo.org for more up to date information.
Resource Page
Downloads:
https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/
https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/
https://polymart.org/resource/mcmmo.727

171
pom.xml Executable file → Normal file
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.210-SNAPSHOT</version>
<version>2.2.000-RC1</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>
@@ -14,9 +14,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<java.version>16</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>
</properties>
<issueManagement>
@@ -75,7 +75,7 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.0.0-M7</version>
<configuration>
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
@@ -84,7 +84,7 @@
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.0.0-M7</version>
<configuration>
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
@@ -95,12 +95,12 @@
<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>
@@ -130,7 +130,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.0</version>
<configuration>
<artifactSet>
<includes>
@@ -150,20 +150,21 @@
<include>net.kyori:examination-api</include>
<include>net.kyori:examination-string</include>
<include>net.kyori:adventure-text-serializer-legacy</include>
<include>net.kyori:adventure-text-serializer-gson</include>
<include>net.kyori:adventure-text-serializer-json</include>
<include>net.kyori:adventure-text-serializer-bungeecord</include>
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
<include>net.kyori:adventure-text-serializer-json-legacy-impl</include>
<include>net.kyori:option</include>
<include>co.aikar:acf-bukkit</include>
<include>com.tcoded:FoliaLib</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>net.kyori.examination</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.examination</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori.adventure</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.adventure</shadedPattern>
<pattern>net.kyori</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
@@ -189,6 +190,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>
@@ -205,7 +210,7 @@
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>2.2</version>
<version>3.5.2</version>
</extension>
</extensions>
</build>
@@ -226,8 +231,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>
@@ -237,72 +242,132 @@
<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>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<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>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-bungeecord</artifactId>
<version>4.3.2</version>
</dependency>
<!-- adventure-api, adventure-text-serializer-gson, adventure-platform-bukkit-->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-key</artifactId>
<version>4.9.3</version>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.9.3</version>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.1</version>
<artifactId>adventure-text-serializer-json</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-json-legacy-impl</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-key</artifactId>
<version>4.15.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-api</artifactId>
<version>4.0.1</version>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-facet</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-viaversion</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>option</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.12.0</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.18.1-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.4</version>
<version>7.0.7</version>
<exclusions>
<exclusion>
<!-- We use jetbrains instead. Excluding this -->
@@ -326,36 +391,42 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.2.0</version>
<version>4.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.2.0</version>
<version>4.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>10.0.14</version>
<version>10.1.0-M17</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
<version>32.1.1-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.3.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillTools;
@@ -20,7 +19,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
public final class ExperienceAPI {
@@ -35,13 +33,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 +54,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
@@ -706,7 +704,7 @@ public final class ExperienceAPI {
PrimarySkillType skill = getSkillType(skillType);
if (SkillTools.isChildSkill(skill)) {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
var parentSkills = mcMMO.p.getSkillTools().getChildSkillParents(skill);
for (PrimarySkillType parentSkill : parentSkills) {
profile.addLevels(parentSkill, (levels / parentSkills.size()));
@@ -737,7 +735,7 @@ public final class ExperienceAPI {
PrimarySkillType skill = getSkillType(skillType);
if (SkillTools.isChildSkill(skill)) {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
var parentSkills = mcMMO.p.getSkillTools().getChildSkillParents(skill);
for (PrimarySkillType parentSkill : parentSkills) {
profile.addLevels(parentSkill, (levels / parentSkills.size()));

View File

@@ -0,0 +1,6 @@
package com.gmail.nossr50.api;
public enum FakeBlockBreakEventType {
FAKE,
TREE_FELLER
}

View File

@@ -3,12 +3,13 @@ package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -24,13 +25,22 @@ public final class PartyAPI {
* @return the name of the player's party, or null if not in a party
*/
public static String getPartyName(Player player) {
if (!inParty(player)) {
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || !inParty(player)) {
return null;
}
return UserManager.getPlayer(player).getParty().getName();
}
/**
* Check if the party system is enabled.
*
* @return true if the party system is enabled, false otherwise
*/
public static boolean isPartySystemEnabled() {
return mcMMO.p.getPartyConfig().isPartyEnabled();
}
/**
* Checks if a player is in a party.
* </br>
@@ -40,7 +50,7 @@ public final class PartyAPI {
* @return true if the player is in a party, false otherwise
*/
public static boolean inParty(Player player) {
if(UserManager.getPlayer(player) == null)
if(!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
return false;
return UserManager.getPlayer(player).inParty();
@@ -51,12 +61,15 @@ public final class PartyAPI {
* </br>
* This function is designed for API usage.
*
* @param playera The first player to check
* @param playerb The second player to check
* @param playerA The first player to check
* @param playerB The second player to check
* @return true if the two players are in the same party, false otherwise
*/
public static boolean inSameParty(Player playera, Player playerb) {
return PartyManager.inSameParty(playera, playerb);
public static boolean inSameParty(Player playerA, Player playerB) {
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
return false;
return mcMMO.p.getPartyManager().inSameParty(playerA, playerB);
}
/**
@@ -67,7 +80,7 @@ public final class PartyAPI {
* @return the list of parties.
*/
public static List<Party> getParties() {
return PartyManager.getParties();
return mcMMO.p.getPartyManager().getParties();
}
/**
@@ -81,23 +94,29 @@ public final class PartyAPI {
*/
@Deprecated
public static void addToParty(Player player, String partyName) {
if(!mcMMO.p.getPartyConfig().isPartyEnabled()) {
return;
}
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if(mmoPlayer == null)
return;
Party party = PartyManager.getParty(partyName);
Party party = mcMMO.p.getPartyManager().getParty(partyName);
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else {
if(PartyManager.isPartyFull(player, party))
if(mcMMO.p.getPartyManager().isPartyFull(player, party))
{
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
return;
}
}
PartyManager.addToParty(UserManager.getPlayer(player), party);
mcMMO.p.getPartyManager().addToParty(mmoPlayer, party);
}
/**
@@ -119,19 +138,18 @@ public final class PartyAPI {
* @param partyName The party to add the player to
* @param bypassLimit if true bypasses party size limits
*/
//TODO: bypasslimit not used?
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
if(!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
return;
Party party = PartyManager.getParty(partyName);
Party party = mcMMO.p.getPartyManager().getParty(partyName);
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
}
PartyManager.addToParty(UserManager.getPlayer(player), party);
mcMMO.p.getPartyManager().addToParty(UserManager.getPlayer(player), party);
}
/**
@@ -143,10 +161,10 @@ public final class PartyAPI {
*/
public static void removeFromParty(Player player) {
//Check if player profile is loaded
if(UserManager.getPlayer(player) == null)
if(!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
return;
PartyManager.removeFromParty(UserManager.getPlayer(player));
mcMMO.p.getPartyManager().removeFromParty(UserManager.getPlayer(player));
}
/**
@@ -157,8 +175,11 @@ public final class PartyAPI {
* @param partyName The party name
* @return the leader of the party
*/
public static String getPartyLeader(String partyName) {
return PartyManager.getPartyLeaderName(partyName);
public static @Nullable String getPartyLeader(String partyName) {
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
return null;
return mcMMO.p.getPartyManager().getPartyLeaderName(partyName);
}
/**
@@ -171,7 +192,10 @@ public final class PartyAPI {
*/
@Deprecated
public static void setPartyLeader(String partyName, String playerName) {
PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName));
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
return;
mcMMO.p.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.p.getPartyManager().getParty(partyName));
}
/**
@@ -184,9 +208,12 @@ public final class PartyAPI {
*/
@Deprecated
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
List<OfflinePlayer> members = new ArrayList<>();
if(!mcMMO.p.getPartyConfig().isPartyEnabled()) {
return null;
}
for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
List<OfflinePlayer> members = new ArrayList<>();
for (UUID memberUniqueId : mcMMO.p.getPartyManager().getAllMembers(player).keySet()) {
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
members.add(member);
}
@@ -203,7 +230,10 @@ public final class PartyAPI {
*/
@Deprecated
public static LinkedHashSet<String> getMembers(Player player) {
return (LinkedHashSet<String>) PartyManager.getAllMembers(player).values();
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
return null;
return (LinkedHashSet<String>) mcMMO.p.getPartyManager().getAllMembers(player).values();
}
/**
@@ -215,7 +245,10 @@ public final class PartyAPI {
* @return all the player names and uuids in the player's party
*/
public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
return PartyManager.getAllMembers(player);
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
return null;
return mcMMO.p.getPartyManager().getAllMembers(player);
}
/**
@@ -227,7 +260,10 @@ public final class PartyAPI {
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(String partyName) {
return PartyManager.getOnlineMembers(partyName);
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
return null;
return mcMMO.p.getPartyManager().getOnlineMembers(partyName);
}
/**
@@ -239,7 +275,7 @@ public final class PartyAPI {
* @return all online players in the player's party
*/
public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getOnlineMembers(player);
return mcMMO.p.getPartyManager().getOnlineMembers(player);
}
public static boolean hasAlly(String partyName) {
@@ -247,7 +283,7 @@ public final class PartyAPI {
}
public static String getAllyName(String partyName) {
Party ally = PartyManager.getParty(partyName).getAlly();
Party ally = mcMMO.p.getPartyManager().getParty(partyName).getAlly();
if (ally != null) {
return ally.getName();
}

View File

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

View File

@@ -0,0 +1,9 @@
package com.gmail.nossr50.api.exceptions;
import org.jetbrains.annotations.NotNull;
public class ValueOutOfBoundsException extends RuntimeException {
public ValueOutOfBoundsException(@NotNull String message) {
super(message);
}
}

View File

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

View File

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

View File

@@ -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) {

View File

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

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.chat.mailer;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.chat.message.AdminChatMessage;
import com.gmail.nossr50.chat.message.ChatMessage;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
@@ -44,7 +45,7 @@ public class AdminChatMailer extends AbstractChatMailer {
public @NotNull Predicate<CommandSender> predicate() {
return (commandSender) -> commandSender.isOp()
|| commandSender.hasPermission(MCMMO_CHAT_ADMINCHAT_PERMISSION)
|| commandSender instanceof ConsoleCommandSender;
|| (ChatConfig.getInstance().isConsoleIncludedInAudience(ChatChannel.ADMIN) && commandSender instanceof ConsoleCommandSender);
}
/**
@@ -73,8 +74,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));

View File

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

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -51,7 +52,8 @@ public class PartyChatMessage extends AbstractChatMessage {
messagePartyChatSpies(spyMessage);
//Console message
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
if(ChatConfig.getInstance().isConsoleIncludedInAudience(ChatChannel.PARTY))
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
}
/**

View File

@@ -5,6 +5,7 @@ import co.aikar.commands.BukkitCommandManager;
import co.aikar.commands.ConditionFailedException;
import com.gmail.nossr50.commands.chat.AdminChatCommand;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.skills.PowerLevelCommand;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -20,9 +21,14 @@ import org.jetbrains.annotations.NotNull;
* For now this class will only handle ACF converted commands, all other commands will be handled elsewhere
*/
public class CommandManager {
public static final @NotNull String MMO_DATA_LOADED = "mmoDataLoaded";
//CHAT
public static final @NotNull String ADMIN_CONDITION = "adminCondition";
public static final @NotNull String PARTY_CONDITION = "partyCondition";
public static final @NotNull String MMO_DATA_LOADED = "mmoDataLoaded";
//SKILLS
public static final @NotNull String POWER_LEVEL_CONDITION = "powerLevelCondition";
private final @NotNull mcMMO pluginRef;
private final @NotNull BukkitCommandManager bukkitCommandManager;
@@ -36,9 +42,16 @@ public class CommandManager {
}
private void registerCommands() {
registerSkillCommands(); //TODO: Implement other skills not just power level
registerChatCommands();
}
private void registerSkillCommands() {
if(mcMMO.p.getGeneralConfig().isMasterySystemEnabled()) {
bukkitCommandManager.registerCommand(new PowerLevelCommand(pluginRef));
}
}
/**
* Registers chat commands if the chat system is enabled
*/
@@ -47,13 +60,30 @@ public class CommandManager {
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.ADMIN)) {
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef));
}
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
if(pluginRef.getPartyConfig().isPartyEnabled() && ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef));
}
}
}
public void registerConditions() {
registerChatCommandConditions(); //Chat Commands
registerSkillConditions();
}
private void registerSkillConditions() {
bukkitCommandManager.getCommandConditions().addCondition(POWER_LEVEL_CONDITION, (context) -> {
BukkitCommandIssuer issuer = context.getIssuer();
if(issuer.getIssuer() instanceof Player) {
validateLoadedData(issuer.getPlayer());
} else {
throw new ConditionFailedException(LocaleLoader.getString("Commands.NoConsole"));
}
});
}
private void registerChatCommandConditions() {
// Method or Class based - Can only be used on methods
bukkitCommandManager.getCommandConditions().addCondition(ADMIN_CONDITION, (context) -> {
BukkitCommandIssuer issuer = context.getIssuer();
@@ -78,6 +108,7 @@ public class CommandManager {
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
validateLoadedData(bukkitCommandIssuer.getPlayer());
validatePlayerParty(bukkitCommandIssuer.getPlayer());
//TODO: Is there even a point in validating permission? look into this later
validatePermission("mcmmo.chat.partychat", bukkitCommandIssuer.getPlayer());
}
});
@@ -105,7 +136,7 @@ public class CommandManager {
public void validatePlayerParty(@NotNull Player player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if(mmoPlayer.getParty() == null) {
if(!pluginRef.getPartyConfig().isPartyEnabled() || mmoPlayer.getParty() == null) {
throw new ConditionFailedException(LocaleLoader.getString("Commands.Party.None"));
}
}

View File

@@ -204,7 +204,7 @@ public class McImportCommand implements CommandExecutor {
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
skillName = "Woodcutting";
}
else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
else if (materialName.contains("GRASS") || materialName.contains("SHORT_GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
skillName = "Herbalism";
}
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {

View File

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

View File

@@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.entity.Player;
@@ -78,7 +77,7 @@ public class PartyChatCommand extends BaseCommand {
mcMMO.p.getLogger().severe("You need to specify a party name and then write a message afterwards.");
} else {
//Grab party
Party targetParty = PartyManager.getParty(args[0]);
Party targetParty = mcMMO.p.getPartyManager().getParty(args[0]);
if(targetParty != null) {
pluginRef.getChatManager().processConsoleMessage(StringUtils.buildStringAfterNthElement(args, 1), targetParty);

View File

@@ -64,10 +64,10 @@ public class ConvertDatabaseCommand implements CommandExecutor {
mcMMO.getDatabaseManager().saveUser(profile);
}
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()));
return true;
}
return false;

View File

@@ -36,10 +36,10 @@ public class ConvertExperienceCommand implements CommandExecutor {
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
mcMMO.p.getFoliaLib().getImpl().runLater(new FormulaConversionTask(sender, newType), 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new PlayerProfileLoadingTask(player), 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
return true;

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -31,11 +31,11 @@ public class PartyAcceptCommand implements CommandExecutor {
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true;
}
PartyManager.joinInvitedParty(mcMMOPlayer);
mcMMO.p.getPartyManager().joinInvitedParty(mcMMOPlayer);
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));

View File

@@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
@@ -31,7 +30,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
return true;
}
PartyManager.setPartyLeader(target.getUniqueId(), playerParty);
mcMMO.p.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty);
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));

View File

@@ -23,11 +23,45 @@ import java.util.Collections;
import java.util.List;
public class PartyCommand implements TabExecutor {
private static final List<String> PARTY_SUBCOMMANDS;
private static final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
private final List<String> PARTY_SUBCOMMANDS;
private final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
private final CommandExecutor partyJoinCommand;
private final CommandExecutor partyAcceptCommand;
private final CommandExecutor partyCreateCommand;
private final CommandExecutor partyQuitCommand;
private final CommandExecutor partyXpShareCommand;
private final CommandExecutor partyItemShareCommand;
private final CommandExecutor partyInviteCommand;
private final CommandExecutor partyKickCommand;
private final CommandExecutor partyDisbandCommand;
private final CommandExecutor partyChangeOwnerCommand;
private final CommandExecutor partyLockCommand;
private final CommandExecutor partyChangePasswordCommand;
private final CommandExecutor partyRenameCommand;
private final CommandExecutor partyInfoCommand;
private final CommandExecutor partyHelpCommand;
private final CommandExecutor partyTeleportCommand;
private final CommandExecutor partyAllianceCommand;
public PartyCommand() {
partyJoinCommand = new PartyJoinCommand();
partyAcceptCommand = new PartyAcceptCommand();
partyCreateCommand = new PartyCreateCommand();
partyQuitCommand = new PartyQuitCommand();
partyXpShareCommand = new PartyXpShareCommand();
partyItemShareCommand = new PartyItemShareCommand();
partyInviteCommand = new PartyInviteCommand();
partyKickCommand = new PartyKickCommand();
partyDisbandCommand = new PartyDisbandCommand();
partyChangeOwnerCommand = new PartyChangeOwnerCommand();
partyLockCommand = new PartyLockCommand();
partyChangePasswordCommand = new PartyChangePasswordCommand();
partyRenameCommand = new PartyRenameCommand();
partyInfoCommand = new PartyInfoCommand();
partyHelpCommand = new PartyHelpCommand();
partyTeleportCommand = new PtpCommand();
partyAllianceCommand = new PartyAllianceCommand();
static {
ArrayList<String> subcommands = new ArrayList<>();
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
@@ -38,24 +72,6 @@ public class PartyCommand implements TabExecutor {
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
}
private final CommandExecutor partyJoinCommand = new PartyJoinCommand();
private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private final CommandExecutor partyCreateCommand = new PartyCreateCommand();
private final CommandExecutor partyQuitCommand = new PartyQuitCommand();
private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
private final CommandExecutor partyInviteCommand = new PartyInviteCommand();
private final CommandExecutor partyKickCommand = new PartyKickCommand();
private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private final CommandExecutor partyLockCommand = new PartyLockCommand();
private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
private final CommandExecutor partyRenameCommand = new PartyRenameCommand();
private final CommandExecutor partyInfoCommand = new PartyInfoCommand();
private final CommandExecutor partyHelpCommand = new PartyHelpCommand();
private final CommandExecutor partyTeleportCommand = new PtpCommand();
private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
@@ -73,13 +89,13 @@ public class PartyCommand implements TabExecutor {
return true;
}
if(UserManager.getPlayer(player) == null)
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(mcMMOPlayer == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
@@ -140,31 +156,18 @@ public class PartyCommand implements TabExecutor {
return true;
}
switch (subcommand) {
case XPSHARE:
return partyXpShareCommand.onCommand(sender, command, label, args);
case ITEMSHARE:
return partyItemShareCommand.onCommand(sender, command, label, args);
case KICK:
return partyKickCommand.onCommand(sender, command, label, args);
case DISBAND:
return partyDisbandCommand.onCommand(sender, command, label, args);
case OWNER:
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
case LOCK:
case UNLOCK:
return partyLockCommand.onCommand(sender, command, label, args);
case PASSWORD:
return partyChangePasswordCommand.onCommand(sender, command, label, args);
case RENAME:
return partyRenameCommand.onCommand(sender, command, label, args);
case ALLIANCE:
return partyAllianceCommand.onCommand(sender, command, label, args);
default:
break;
}
return true;
return switch (subcommand) {
case XPSHARE -> partyXpShareCommand.onCommand(sender, command, label, args);
case ITEMSHARE -> partyItemShareCommand.onCommand(sender, command, label, args);
case KICK -> partyKickCommand.onCommand(sender, command, label, args);
case DISBAND -> partyDisbandCommand.onCommand(sender, command, label, args);
case OWNER -> partyChangeOwnerCommand.onCommand(sender, command, label, args);
case LOCK, UNLOCK -> partyLockCommand.onCommand(sender, command, label, args);
case PASSWORD -> partyChangePasswordCommand.onCommand(sender, command, label, args);
case RENAME -> partyRenameCommand.onCommand(sender, command, label, args);
case ALLIANCE -> partyAllianceCommand.onCommand(sender, command, label, args);
default -> true;
};
}
@Override
@@ -179,12 +182,13 @@ public class PartyCommand implements TabExecutor {
return ImmutableList.of();
}
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
switch (subcommand) {
case JOIN:
case INVITE:
case KICK:
case OWNER:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
case XPSHARE:
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size()));
@@ -198,17 +202,21 @@ public class PartyCommand implements TabExecutor {
case TELEPORT:
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
if (matches.isEmpty()) {
Player player = (Player) sender;
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Not Loaded
if(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()));

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -26,16 +26,16 @@ public class PartyCreateCommand implements CommandExecutor {
}
// Check to see if the party exists, and if it does cancel creating a new party
if (PartyManager.checkPartyExistence(player, args[1])) {
if (mcMMO.p.getPartyManager().checkPartyExistence(player, args[1])) {
return true;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
return true;
}
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
mcMMO.p.getPartyManager().createParty(mcMMOPlayer, args[1], getPassword(args));
return true;
default:

View File

@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -26,14 +26,14 @@ public class PartyDisbandCommand implements CommandExecutor {
final String partyName = playerParty.getName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
member.sendMessage(LocaleLoader.getString("Party.Disband"));
}
PartyManager.disbandParty(mcMMOPlayer, playerParty);
mcMMO.p.getPartyManager().disbandParty(mcMMOPlayer, playerParty);
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));

View File

@@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -125,7 +124,7 @@ public class PartyInfoCommand implements CommandExecutor {
* Only show members of the party that this member can see
*/
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearVisibleMembers(mcMMOPlayer);
int membersOnline = party.getVisibleMembers(player).size();
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));

View File

@@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
@@ -40,19 +39,19 @@ public class PartyInviteCommand implements CommandExecutor {
return true;
}
if (PartyManager.inSameParty(player, target)) {
if (mcMMO.p.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!PartyManager.canInvite(mcMMOPlayer)) {
if (!mcMMO.p.getPartyManager().canInvite(mcMMOPlayer)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (PartyManager.isPartyFull(target, playerParty)) {
if (mcMMO.p.getPartyManager().isPartyFull(target, playerParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), mcMMO.p.getGeneralConfig().getPartyMaxSize()));
return true;
}

View File

@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
@@ -51,25 +51,25 @@ public class PartyJoinCommand implements CommandExecutor {
String password = getPassword(args);
// Make sure party passwords match
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
if (!mcMMO.p.getPartyManager().checkPartyPassword(player, targetParty, password)) {
return true;
}
String partyName = targetParty.getName();
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, partyName)) {
return true;
}
if(PartyManager.isPartyFull(player, targetParty))
if(mcMMO.p.getPartyManager().isPartyFull(player, targetParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);
mcMMO.p.getPartyManager().addToParty(mcMMOPlayer, targetParty);
return true;
default:

View File

@@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
@@ -37,15 +36,15 @@ public class PartyKickCommand implements CommandExecutor {
Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName();
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
mcMMO.p.getPartyManager().processPartyLeaving(UserManager.getPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(target, playerParty);
mcMMO.p.getPartyManager().removeFromParty(target, playerParty);
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));

View File

@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -26,11 +26,11 @@ public class PartyQuitCommand implements CommandExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true;
}
PartyManager.removeFromParty(mcMMOPlayer);
mcMMO.p.getPartyManager().removeFromParty(mcMMOPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;
}

View File

@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -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)) {
@@ -36,14 +36,14 @@ public class PartyRenameCommand implements CommandExecutor {
Player player = mcMMOPlayer.getPlayer();
// Check to see if the party exists, and if it does cancel renaming the party
if (PartyManager.checkPartyExistence(player, newPartyName)) {
if (mcMMO.p.getPartyManager().checkPartyExistence(player, newPartyName)) {
return true;
}
String leaderName = playerParty.getLeader().getPlayerName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true;
}

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -31,7 +31,7 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
return true;
}
PartyManager.acceptAllianceInvite(mcMMOPlayer);
mcMMO.p.getPartyManager().acceptAllianceInvite(mcMMOPlayer);
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));

View File

@@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
@@ -129,7 +128,7 @@ public class PartyAllianceCommand implements TabExecutor {
}
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearMembers(mcMMOPlayer);
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(playerParty.createMembersList(player));
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");

View File

@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -28,7 +28,7 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
return true;
}
PartyManager.disbandAlliance(player, party, party.getAlly());
mcMMO.p.getPartyManager().disbandAlliance(player, party, party.getAlly());
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));

View File

@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
@@ -44,7 +44,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
return true;
}
if (PartyManager.inSameParty(player, target)) {
if (mcMMO.p.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}

View File

@@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
@@ -210,7 +209,7 @@ public class PtpCommand implements TabExecutor {
return false;
}
if (!PartyManager.inSameParty(player, target)) {
if (!mcMMO.p.getPartyManager().inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
@@ -250,7 +249,7 @@ public class PtpCommand implements TabExecutor {
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(teleportingPlayer, new TeleportationWarmup(mcMMOPlayer, mcMMOTarget), 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);

View File

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

View File

@@ -111,7 +111,7 @@ public class McrankCommand implements TabExecutor {
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new McrankCommandAsyncTask(playerName, sender, useBoard, useChat));
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {

View File

@@ -115,7 +115,7 @@ public class MctopCommand implements TabExecutor {
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
mcMMO.p.getFoliaLib().getImpl().runAsync(new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat));
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {

View File

@@ -5,9 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -30,7 +29,7 @@ public class AcrobaticsCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// ACROBATICS_DODGE
if (canDodge) {
String[] dodgeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_DODGE);
String[] dodgeStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ACROBATICS_DODGE);
dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1];
}
@@ -38,8 +37,8 @@ public class AcrobaticsCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE);
canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL);
canDodge = Permissions.canUseSubSkill(player, SubSkillType.ACROBATICS_DODGE);
canRoll = Permissions.canUseSubSkill(player, SubSkillType.ACROBATICS_ROLL);
}
@Override
@@ -57,25 +56,7 @@ public class AcrobaticsCommand extends SkillCommand {
if(abstractSubSkill != null)
{
double rollChance, graceChance;
//Chance to roll at half
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
//Chance to graceful roll
RandomChanceSkill grace_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
//Chance Stat Calculations
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = mcMMO.p.getAdvancedConfig().getRollDamageThreshold();
String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
//Format
double rollChanceLucky = rollChance * 1.333D;
double graceChanceLucky = graceChance * 1.333D;
String[] rollStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollStrings[1]) : ""));

View File

@@ -68,8 +68,8 @@ public class AlchemyCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS);
canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
canCatalysis = Permissions.canUseSubSkill(player, SubSkillType.ALCHEMY_CATALYSIS);
canConcoctions = Permissions.canUseSubSkill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
}
@Override

View File

@@ -4,8 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -32,14 +33,14 @@ public class ArcheryCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// ARCHERY_ARROW_RETRIEVAL
if (canRetrieve) {
String[] retrieveStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
String[] retrieveStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
// ARCHERY_DAZE
if (canDaze) {
String[] dazeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_DAZE);
String[] dazeStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ARCHERY_DAZE);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
}
@@ -52,9 +53,9 @@ public class ArcheryCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canSkillShot = canUseSubskill(player, SubSkillType.ARCHERY_SKILL_SHOT);
canDaze = canUseSubskill(player, SubSkillType.ARCHERY_DAZE);
canRetrieve = canUseSubskill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
canSkillShot = Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_SKILL_SHOT);
canDaze = Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_DAZE);
canRetrieve = Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
}
@Override
@@ -75,7 +76,7 @@ public class ArcheryCommand extends SkillCommand {
messages.add(getStatMessage(SubSkillType.ARCHERY_SKILL_SHOT, skillShotBonus));
}
if(canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
if(Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, 1000))));
}

View File

@@ -6,9 +6,9 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -48,7 +48,7 @@ public class AxesCommand extends SkillCommand {
// CRITICAL HIT
if (canCritical) {
String[] criticalHitStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.AXES_CRITICAL_STRIKES);
String[] criticalHitStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.AXES_CRITICAL_STRIKES);
critChance = criticalHitStrings[0];
critChanceLucky = criticalHitStrings[1];
}
@@ -64,10 +64,10 @@ public class AxesCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES);
canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY);
canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT);
canGreaterImpact = canUseSubskill(player, SubSkillType.AXES_GREATER_IMPACT);
canCritical = Permissions.canUseSubSkill(player, SubSkillType.AXES_CRITICAL_STRIKES);
canAxeMastery = Permissions.canUseSubSkill(player, SubSkillType.AXES_AXE_MASTERY);
canImpact = Permissions.canUseSubSkill(player, SubSkillType.AXES_ARMOR_IMPACT);
canGreaterImpact = Permissions.canUseSubSkill(player, SubSkillType.AXES_GREATER_IMPACT);
}
@Override
@@ -96,7 +96,7 @@ public class AxesCommand extends SkillCommand {
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
}
if(canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
if(Permissions.canUseSubSkill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.AXES_AXES_LIMIT_BREAK, 1000))));
}

View File

@@ -0,0 +1,77 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import static com.gmail.nossr50.datatypes.skills.SubSkillType.*;
public class CrossbowsCommand extends SkillCommand {
private boolean canTrickShot;
private boolean canPoweredShot;
public CrossbowsCommand() {
super(PrimarySkillType.CROSSBOWS);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// TODO: Implement data calculations
}
@Override
protected void permissionsCheck(Player player) {
canTrickShot = RankUtils.hasUnlockedSubskill(player, CROSSBOWS_TRICK_SHOT)
&& Permissions.trickShot(player);
canPoweredShot = RankUtils.hasUnlockedSubskill(player, CROSSBOWS_POWERED_SHOT)
&& Permissions.poweredShot(player);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if (mmoPlayer == null) {
return messages;
}
if (canPoweredShot) {
messages.add(getStatMessage(ARCHERY_SKILL_SHOT, percent.format(mmoPlayer.getCrossbowsManager().getDamageBonusPercent(player))));
}
if (canTrickShot) {
messages.add(getStatMessage(CROSSBOWS_TRICK_SHOT,
String.valueOf(mmoPlayer.getCrossbowsManager().getTrickShotMaxBounceCount())));
}
if(Permissions.canUseSubSkill(player, CROSSBOWS_CROSSBOWS_LIMIT_BREAK)) {
messages.add(getStatMessage(CROSSBOWS_CROSSBOWS_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, CROSSBOWS_CROSSBOWS_LIMIT_BREAK, 1000))));
}
messages.add(ChatColor.GRAY + "The Crossbows skill is a work in progress and is still being developed, feedback would be appreciated in the mcMMO discord server.");
return messages;
}
@Override
protected List<Component> getTextComponents(Player player) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.CROSSBOWS);
return textComponents;
}
}

View File

@@ -38,7 +38,7 @@ public class ExcavationCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
canTreasureHunt = Permissions.canUseSubSkill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
}
@Override
@@ -54,7 +54,7 @@ public class ExcavationCommand extends SkillCommand {
//messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
}
if(canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
if(Permissions.canUseSubSkill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
messages.add(getStatMessage(false, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
percent.format(excavationManager.getArchaelogyExperienceOrbChance() / 100.0D)));
messages.add(getStatMessage(true, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,

View File

@@ -7,8 +7,10 @@ import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.random.Probability;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.StringUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@@ -79,7 +81,8 @@ public class FishingCommand extends SkillCommand {
// FISHING_SHAKE
if (canShake) {
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
Probability shakeProbability = Probability.ofPercent(fishingManager.getShakeChance());
String[] shakeStrings = ProbabilityUtil.getRNGDisplayValues(shakeProbability);
shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1];
}
@@ -98,12 +101,12 @@ public class FishingCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canTreasureHunt = canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
canTreasureHunt = Permissions.canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canMagicHunt = Permissions.canUseSubSkill(player, SubSkillType.FISHING_MAGIC_HUNTER) && Permissions.canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canShake = Permissions.canUseSubSkill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = Permissions.canUseSubSkill(player, SubSkillType.FISHING_FISHERMANS_DIET);
canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && Permissions.canUseSubSkill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = Permissions.canUseSubSkill(player, SubSkillType.FISHING_ICE_FISHING);
}
@Override

View File

@@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
@@ -24,6 +24,8 @@ public class HerbalismCommand extends SkillCommand {
private int farmersDietRank;
private String doubleDropChance;
private String doubleDropChanceLucky;
private String tripleDropChance;
private String tripleDropChanceLucky;
private String hylianLuckChance;
private String hylianLuckChanceLucky;
private String shroomThumbChance;
@@ -35,6 +37,7 @@ public class HerbalismCommand extends SkillCommand {
private boolean canGreenThumbBlocks;
private boolean canFarmersDiet;
private boolean canDoubleDrop;
private boolean canTripleDrop;
private boolean canShroomThumb;
public HerbalismCommand() {
@@ -46,10 +49,16 @@ public class HerbalismCommand extends SkillCommand {
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
if (canTripleDrop) {
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_VERDANT_BOUNTY);
tripleDropChance = tripleDropStrings[0];
tripleDropChanceLucky = tripleDropStrings[1];
}
// FARMERS DIET
if (canFarmersDiet) {
@@ -67,21 +76,21 @@ public class HerbalismCommand extends SkillCommand {
if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB);
greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1];
}
// HYLIAN LUCK
if (hasHylianLuck) {
String[] hylianLuckStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_HYLIAN_LUCK);
String[] hylianLuckStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1];
}
// SHROOM THUMB
if (canShroomThumb) {
String[] shroomThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_SHROOM_THUMB);
String[] shroomThumbStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_SHROOM_THUMB);
shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1];
}
@@ -89,13 +98,14 @@ public class HerbalismCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
hasHylianLuck = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOTS) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS));
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB);
canFarmersDiet = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
canTripleDrop = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_VERDANT_BOUNTY) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
canShroomThumb = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_SHROOM_THUMB);
}
@Override
@@ -106,11 +116,16 @@ public class HerbalismCommand extends SkillCommand {
messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canTripleDrop) {
messages.add(getStatMessage(SubSkillType.HERBALISM_VERDANT_BOUNTY, tripleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", tripleDropChanceLucky) : ""));
}
if (canFarmersDiet) {
messages.add(getStatMessage(false, true, SubSkillType.HERBALISM_FARMERS_DIET, String.valueOf(farmersDietRank)));
}
if (canGreenTerra) {
messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_TERRA, greenTerraLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));

View File

@@ -6,8 +6,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -18,6 +18,8 @@ import java.util.List;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
private String doubleDropChanceLucky;
private String tripleDropChance;
private String tripleDropChanceLucky;
private String superBreakerLength;
private String superBreakerLengthEndurance;
@@ -30,6 +32,7 @@ public class MiningCommand extends SkillCommand {
private boolean canSuperBreaker;
private boolean canDoubleDrop;
private boolean canTripleDrop;
private boolean canBlast;
private boolean canBiggerBombs;
private boolean canDemoExpert;
@@ -51,10 +54,17 @@ public class MiningCommand extends SkillCommand {
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
}
// Mastery TRIPLE DROPS
if (canTripleDrop) {
String[] masteryTripleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.MINING_MOTHER_LODE);
tripleDropChance = masteryTripleDropStrings[0];
tripleDropChanceLucky = masteryTripleDropStrings[1];
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.MINING_DOUBLE_DROPS);
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.MINING_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
@@ -72,7 +82,8 @@ public class MiningCommand extends SkillCommand {
canBiggerBombs = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player);
canBlast = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player);
canDemoExpert = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS);
canDoubleDrop = Permissions.canUseSubSkill(player, SubSkillType.MINING_DOUBLE_DROPS);
canTripleDrop = Permissions.canUseSubSkill(player, SubSkillType.MINING_MOTHER_LODE);
canSuperBreaker = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player);
}
@@ -94,13 +105,18 @@ public class MiningCommand extends SkillCommand {
messages.add(getStatMessage(SubSkillType.MINING_DEMOLITIONS_EXPERTISE, blastDamageDecrease));
//messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
}
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.MINING_DOUBLE_DROPS, doubleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if(canTripleDrop) {
messages.add(getStatMessage(SubSkillType.MINING_MOTHER_LODE, tripleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", tripleDropChanceLucky) : ""));
}
if (canSuperBreaker) {
messages.add(getStatMessage(SubSkillType.MINING_SUPER_BREAKER, superBreakerLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));

View File

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

View File

@@ -0,0 +1,40 @@
package com.gmail.nossr50.commands.skills;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Default;
import com.gmail.nossr50.commands.CommandManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@CommandPermission("mcmmo.commands.mmopower")
@CommandAlias("mmopower|mmopowerlevel|powerlevel")
public class PowerLevelCommand extends BaseCommand {
private final @NotNull mcMMO pluginRef;
public PowerLevelCommand(@NotNull mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Default
@Conditions(CommandManager.POWER_LEVEL_CONDITION)
public void processCommand(String[] args) {
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
Player player = bukkitCommandIssuer.getPlayer();
McMMOPlayer mmoPlayer = UserManager.getPlayer(player); //Should never be null at this point because its caught in an ACF validation
if (mmoPlayer == null) {
return;
}
int powerLevel = mmoPlayer.getPowerLevel();
mmoPlayer.getPlayer().sendMessage(ChatColor.DARK_AQUA + "Your " + ChatColor.GOLD + "[mcMMO]" + ChatColor.DARK_AQUA + " power level is: " + ChatColor.GREEN + powerLevel);
}
}

View File

@@ -11,8 +11,8 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
@@ -68,7 +68,7 @@ public class RepairCommand extends SkillCommand {
// SUPER REPAIR
if (canSuperRepair) {
String[] superRepairStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.REPAIR_SUPER_REPAIR);
String[] superRepairStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.REPAIR_SUPER_REPAIR);
superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1];
}
@@ -76,9 +76,9 @@ public class RepairCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canSuperRepair = canUseSubskill(player, SubSkillType.REPAIR_SUPER_REPAIR);
canMasterRepair = canUseSubskill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
canArcaneForge = canUseSubskill(player, SubSkillType.REPAIR_ARCANE_FORGING);
canSuperRepair = Permissions.canUseSubSkill(player, SubSkillType.REPAIR_SUPER_REPAIR);
canMasterRepair = Permissions.canUseSubSkill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
canArcaneForge = Permissions.canUseSubSkill(player, SubSkillType.REPAIR_ARCANE_FORGING);
canRepairDiamond = Permissions.repairMaterialType(player, MaterialType.DIAMOND);
canRepairGold = Permissions.repairMaterialType(player, MaterialType.GOLD);
canRepairIron = Permissions.repairMaterialType(player, MaterialType.IRON);

View File

@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@@ -30,8 +31,8 @@ public class SalvageCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canScrapCollector = canUseSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
canArcaneSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
canScrapCollector = Permissions.canUseSubSkill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
canArcaneSalvage = Permissions.canUseSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
}
@Override

View File

@@ -5,16 +5,12 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillTools;
import com.gmail.nossr50.util.text.StringUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@@ -32,7 +28,6 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
public abstract class SkillCommand implements TabExecutor {
protected PrimarySkillType skill;
@@ -173,7 +168,7 @@ public abstract class SkillCommand implements TabExecutor {
*/
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
var parents = mcMMO.p.getSkillTools().getChildSkillParents(skill);
//TODO: Add JSON here
/*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/
@@ -232,9 +227,9 @@ public abstract class SkillCommand implements TabExecutor {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
}
protected String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
}
// protected String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
// return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
// }
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = mcMMO.p.getSkillTools().getSuperAbilityMaxLength(mcMMO.p.getSkillTools().getSuperAbility(skill));
@@ -297,14 +292,4 @@ public abstract class SkillCommand implements TabExecutor {
protected abstract List<Component> getTextComponents(Player player);
/**
* Checks if a player can use a skill
* @param player target player
* @param subSkillType target subskill
* @return true if the player has permission and has the skill unlocked
*/
protected boolean canUseSubskill(Player player, SubSkillType subSkillType)
{
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType);
}
}

View File

@@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -39,14 +39,14 @@ public class SmeltingCommand extends SkillCommand {
// FLUX MINING
/*if (canFluxMine) {
String[] fluxMiningStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_FLUX_MINING);
String[] fluxMiningStrings = getRNGDisplayValues(player, SubSkillType.SMELTING_FLUX_MINING);
str_fluxMiningChance = fluxMiningStrings[0];
str_fluxMiningChanceLucky = fluxMiningStrings[1];
}*/
// SECOND SMELT
if (canSecondSmelt) {
String[] secondSmeltStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_SECOND_SMELT);
String[] secondSmeltStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.SMELTING_SECOND_SMELT);
str_secondSmeltChance = secondSmeltStrings[0];
str_secondSmeltChanceLucky = secondSmeltStrings[1];
}
@@ -54,8 +54,8 @@ public class SmeltingCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT);
canFuelEfficiency = Permissions.canUseSubSkill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
canSecondSmelt = Permissions.canUseSubSkill(player, SubSkillType.SMELTING_SECOND_SMELT);
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
}

View File

@@ -6,9 +6,10 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -38,7 +39,7 @@ public class SwordsCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// SWORDS_COUNTER_ATTACK
if (canCounter) {
String[] counterStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_COUNTER_ATTACK);
String[] counterStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.SWORDS_COUNTER_ATTACK);
counterChance = counterStrings[0];
counterChanceLucky = counterStrings[1];
}
@@ -69,8 +70,8 @@ public class SwordsCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canRupture = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canRupture = SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canSerratedStrike = RankUtils.hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
}
@@ -101,13 +102,13 @@ public class SwordsCommand extends SkillCommand {
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
if(canUseSubskill(player, SubSkillType.SWORDS_STAB))
if(SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_STAB))
{
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage())));
}
if(canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
if(SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, 1000))));
}

View File

@@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.EntityType;
@@ -35,7 +35,7 @@ public class TamingCommand extends SkillCommand {
@Override
protected void dataCalculations(Player player, float skillValue) {
if (canGore) {
String[] goreStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.TAMING_GORE);
String[] goreStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.TAMING_GORE);
goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1];
}
@@ -43,15 +43,15 @@ public class TamingCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE);
canBeastLore = Permissions.canUseSubSkill(player, SubSkillType.TAMING_BEAST_LORE);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
canFastFood = canUseSubskill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
canGore = canUseSubskill(player, SubSkillType.TAMING_GORE);
canSharpenedClaws = canUseSubskill(player, SubSkillType.TAMING_SHARPENED_CLAWS);
canShockProof = canUseSubskill(player, SubSkillType.TAMING_SHOCK_PROOF);
canThickFur = canUseSubskill(player, SubSkillType.TAMING_THICK_FUR);
canHolyHound = canUseSubskill(player, SubSkillType.TAMING_HOLY_HOUND);
canEnvironmentallyAware = Permissions.canUseSubSkill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
canFastFood = Permissions.canUseSubSkill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
canGore = Permissions.canUseSubSkill(player, SubSkillType.TAMING_GORE);
canSharpenedClaws = Permissions.canUseSubSkill(player, SubSkillType.TAMING_SHARPENED_CLAWS);
canShockProof = Permissions.canUseSubSkill(player, SubSkillType.TAMING_SHOCK_PROOF);
canThickFur = Permissions.canUseSubSkill(player, SubSkillType.TAMING_THICK_FUR);
canHolyHound = Permissions.canUseSubSkill(player, SubSkillType.TAMING_HOLY_HOUND);
}
@Override

View File

@@ -0,0 +1,62 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import static com.gmail.nossr50.datatypes.skills.SubSkillType.TRIDENTS_IMPALE;
import static com.gmail.nossr50.datatypes.skills.SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK;
public class TridentsCommand extends SkillCommand {
public TridentsCommand() {
super(PrimarySkillType.TRIDENTS);
}
@Override
protected void dataCalculations(Player player, float skillValue) {}
@Override
protected void permissionsCheck(Player player) {}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if (mmoPlayer == null) {
return messages;
}
if(SkillUtils.canUseSubskill(player, TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
messages.add(getStatMessage(TRIDENTS_TRIDENTS_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, TRIDENTS_TRIDENTS_LIMIT_BREAK, 1000))));
}
if(SkillUtils.canUseSubskill(player, TRIDENTS_IMPALE)) {
messages.add(getStatMessage(TRIDENTS_IMPALE,
String.valueOf(mmoPlayer.getTridentsManager().impaleDamageBonus())));
}
messages.add(ChatColor.GRAY + "The Tridents skill is a work in progress and is still being developed, feedback would be appreciated in the mcMMO discord server.");
return messages;
}
@Override
protected List<Component> getTextComponents(Player player) {
List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.TRIDENTS);
return textComponents;
}
}

View File

@@ -5,9 +5,9 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -40,7 +40,7 @@ public class UnarmedCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// UNARMED_ARROW_DEFLECT
if (canDeflect) {
String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);
String[] deflectStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.UNARMED_ARROW_DEFLECT);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
}
@@ -54,7 +54,7 @@ public class UnarmedCommand extends SkillCommand {
// UNARMED_DISARM
if (canDisarm) {
String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);
String[] disarmStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.UNARMED_DISARM);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
}
@@ -66,7 +66,7 @@ public class UnarmedCommand extends SkillCommand {
// IRON GRIP
if (canIronGrip) {
String[] ironGripStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_IRON_GRIP);
String[] ironGripStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.UNARMED_IRON_GRIP);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}
@@ -75,10 +75,10 @@ public class UnarmedCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canBerserk = RankUtils.hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_STEEL_ARM_STYLE);
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);
canIronGrip = canUseSubskill(player, SubSkillType.UNARMED_IRON_GRIP);
canIronArm = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_STEEL_ARM_STYLE);
canDeflect = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
canDisarm = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_DISARM);
canIronGrip = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_IRON_GRIP);
// TODO: Apparently we forgot about block cracker?
}
@@ -114,7 +114,7 @@ public class UnarmedCommand extends SkillCommand {
//messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
}
if(canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
if(Permissions.canUseSubSkill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK,
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, 1000))));
}

View File

@@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@@ -18,15 +18,15 @@ public class WoodcuttingCommand extends SkillCommand {
private String treeFellerLength;
private String treeFellerLengthEndurance;
private String doubleDropChance;
private String tripleDropChance;
private String doubleDropChanceLucky;
private String tripleDropChanceLucky;
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
private boolean canTripleDrop;
private boolean canKnockOnWood;
private boolean canSplinter;
private boolean canBarkSurgeon;
private boolean canNaturesBounty;
public WoodcuttingCommand() {
super(PrimarySkillType.WOODCUTTING);
@@ -38,7 +38,14 @@ public class WoodcuttingCommand extends SkillCommand {
if (canDoubleDrop) {
setDoubleDropClassicChanceStrings(player);
}
//Clean Cuts
if(canTripleDrop) {
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.WOODCUTTING_CLEAN_CUTS);
tripleDropChance = tripleDropStrings[0];
tripleDropChanceLucky = tripleDropStrings[1];
}
// TREE FELLER
if (canTreeFell) {
String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
@@ -48,7 +55,7 @@ public class WoodcuttingCommand extends SkillCommand {
}
private void setDoubleDropClassicChanceStrings(Player player) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
@@ -56,14 +63,12 @@ public class WoodcuttingCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill)
canDoubleDrop = !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill)
&& Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
canKnockOnWood = canTreeFell && canUseSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD);
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);
canNaturesBounty = canUseSubskill(player, SubSkillType.WOODCUTTING_NATURES_BOUNTY);*/
canTripleDrop = !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill) && Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_CLEAN_CUTS);
canLeafBlow = Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
canKnockOnWood = canTreeFell && Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD);
}
@Override
@@ -75,6 +80,12 @@ public class WoodcuttingCommand extends SkillCommand {
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if(canTripleDrop) {
messages.add(getStatMessage(SubSkillType.WOODCUTTING_CLEAN_CUTS, tripleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", tripleDropChanceLucky) : ""));
}
if (canKnockOnWood) {
String lootNote;

View File

@@ -14,133 +14,129 @@ public class AdvancedConfig extends BukkitConfig {
public AdvancedConfig(File dataFolder) {
super("advanced.yml", dataFolder);
validate();
}
@Override
public void initDefaults() {
config.addDefault("Skills.General.StartingLevel", 0);
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<>();
/* GENERAL */
if (getAbilityLength() < 1) {
mcMMO.p.getLogger().warning("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
reason.add("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
}
if (getEnchantBuff() < 1) {
mcMMO.p.getLogger().warning("Skills.General.Ability.EnchantBuff should be at least 1!");
reason.add("Skills.General.Ability.EnchantBuff should be at least 1!");
}
/* ACROBATICS */
if (getMaximumProbability(SubSkillType.ACROBATICS_DODGE) < 1) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
reason.add("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ACROBATICS_DODGE) < 1) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
reason.add("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
}
if (getDodgeDamageModifier() <= 1) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
reason.add("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
}
if (getMaximumProbability(SubSkillType.ACROBATICS_ROLL) < 1) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
reason.add("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL) < 1) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
reason.add("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
}
if (getRollDamageThreshold() < 0) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
reason.add("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
}
if (getGracefulRollDamageThreshold() < 0) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
reason.add("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
}
if (getCatalysisMinSpeed() <= 0) {
mcMMO.p.getLogger().warning("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
reason.add("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
}
if (getCatalysisMaxSpeed() < getCatalysisMinSpeed()) {
mcMMO.p.getLogger().warning("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
reason.add("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
}
/* ARCHERY */
if (getSkillShotRankDamageMultiplier() <= 0) {
mcMMO.p.getLogger().warning("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
reason.add("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
}
if (getMaximumProbability(SubSkillType.ARCHERY_DAZE) < 1) {
mcMMO.p.getLogger().warning("Skills.Archery.Daze.ChanceMax should be at least 1!");
reason.add("Skills.Archery.Daze.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ARCHERY_DAZE) < 1) {
mcMMO.p.getLogger().warning("Skills.Archery.Daze.MaxBonusLevel should be at least 1!");
reason.add("Skills.Archery.Daze.MaxBonusLevel should be at least 1!");
}
if (getDazeBonusDamage() < 0) {
mcMMO.p.getLogger().warning("Skills.Archery.Daze.BonusDamage should be at least 0!");
reason.add("Skills.Archery.Daze.BonusDamage should be at least 0!");
}
if (getMaximumProbability(SubSkillType.ARCHERY_ARROW_RETRIEVAL) < 1) {
mcMMO.p.getLogger().warning("Skills.Archery.Retrieve.ChanceMax should be at least 1!");
reason.add("Skills.Archery.Retrieve.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ARCHERY_ARROW_RETRIEVAL) < 1) {
mcMMO.p.getLogger().warning("Skills.Archery.Retrieve.MaxBonusLevel should be at least 1!");
reason.add("Skills.Archery.Retrieve.MaxBonusLevel should be at least 1!");
}
if (getForceMultiplier() < 0) {
mcMMO.p.getLogger().warning("Skills.Archery.ForceMultiplier should be at least 0!");
reason.add("Skills.Archery.ForceMultiplier should be at least 0!");
}
/* AXES */
if (getAxeMasteryRankDamageMultiplier() < 0) {
mcMMO.p.getLogger().warning("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
reason.add("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
}
if (getMaximumProbability(SubSkillType.AXES_CRITICAL_STRIKES) < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
reason.add("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.AXES_CRITICAL_STRIKES) < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
reason.add("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
}
if (getCriticalStrikesPVPModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.CriticalStrikes.PVP_Modifier should be at least 1!");
reason.add("Skills.Axes.CriticalStrikes.PVP_Modifier should be at least 1!");
}
if (getCriticalStrikesPVPModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.CriticalStrikes.PVE_Modifier should be at least 1!");
reason.add("Skills.Axes.CriticalStrikes.PVE_Modifier should be at least 1!");
}
if (getGreaterImpactChance() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.Chance should be at least 1!");
reason.add("Skills.Axes.GreaterImpact.Chance should be at least 1!");
}
if (getGreaterImpactModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
reason.add("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
}
if (getGreaterImpactBonusDamage() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
reason.add("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
}
if (getImpactChance() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.ArmorImpact.Chance should be at least 1!");
reason.add("Skills.Axes.ArmorImpact.Chance should be at least 1!");
}
if (getSkullSplitterModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!");
reason.add("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!");
}
/* FISHING */
@@ -148,261 +144,262 @@ public class AdvancedConfig extends BukkitConfig {
for (int rank : fishingTierList) {
if (getFishingTierLevel(tier) < 0) {
mcMMO.p.getLogger().warning("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be at least 0!");
reason.add("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be at least 0!");
}
if (getShakeChance(tier) < 0) {
mcMMO.p.getLogger().warning("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be at least 0!");
reason.add("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be at least 0!");
}
if (getFishingVanillaXPModifier(tier) < 0) {
mcMMO.p.getLogger().warning("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be at least 0!");
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be at least 0!");
}
if (tier != Fishing.Tier.EIGHT) {
Fishing.Tier nextTier = fishingTierList.get(fishingTierList.indexOf(tier) - 1);
if (getFishingTierLevel(tier) > getFishingTierLevel(nextTier)) {
mcMMO.p.getLogger().warning("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Fishing.Rank_Levels.Rank_" + nextrank + "!");
reason.add("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Fishing.Rank_Levels.Rank_" + nextrank + "!");
}
if (getShakeChance(tier) > getShakeChance(nextTier)) {
mcMMO.p.getLogger().warning("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextrank + "!");
reason.add("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextrank + "!");
}
if (getFishingVanillaXPModifier(tier) > getFishingVanillaXPModifier(nextTier)) {
mcMMO.p.getLogger().warning("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextrank + "!");
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextrank + "!");
}
}
}*/
if (getFishermanDietRankChange() < 1) {
mcMMO.p.getLogger().warning("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
reason.add("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
}
/*if (getIceFishingUnlockLevel() < 0) {
mcMMO.p.getLogger().warning("Skills.Fishing.IceFishing.UnlockLevel should be at least 0!");
reason.add("Skills.Fishing.IceFishing.UnlockLevel should be at least 0!");
}
if (getMasterAnglerUnlockLevel() < 0) {
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.UnlockLevel should be at least 0!");
reason.add("Skills.Fishing.MasterAngler.UnlockLevel should be at least 0!");
}*/
if (getMasterAnglerBoatModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
reason.add("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
}
if (getMasterAnglerBiomeModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
reason.add("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
}
/* HERBALISM */
if (getFarmerDietRankChange() < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
reason.add("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
}
if (getGreenThumbStageChange() < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
reason.add("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_GREEN_THUMB) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
reason.add("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_GREEN_THUMB) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
reason.add("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_DOUBLE_DROPS) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
reason.add("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_DOUBLE_DROPS) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
reason.add("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_HYLIAN_LUCK) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
reason.add("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_HYLIAN_LUCK) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
reason.add("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_SHROOM_THUMB) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
reason.add("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_SHROOM_THUMB) < 1) {
mcMMO.p.getLogger().warning("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
reason.add("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
}
/* MINING */
if (getMaximumProbability(SubSkillType.MINING_DOUBLE_DROPS) < 1) {
mcMMO.p.getLogger().warning("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
reason.add("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.MINING_DOUBLE_DROPS) < 1) {
mcMMO.p.getLogger().warning("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
reason.add("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
}
/* REPAIR */
if (getRepairMasteryMaxBonus() < 1) {
mcMMO.p.getLogger().warning("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
reason.add("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
}
if (getRepairMasteryMaxLevel() < 1) {
mcMMO.p.getLogger().warning("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
reason.add("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.REPAIR_SUPER_REPAIR) < 1) {
mcMMO.p.getLogger().warning("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
reason.add("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.REPAIR_SUPER_REPAIR) < 1) {
mcMMO.p.getLogger().warning("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
}
/* SMELTING */
if (getBurnModifierMaxLevel() < 1) {
mcMMO.p.getLogger().warning("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.SMELTING_SECOND_SMELT) < 1) {
mcMMO.p.getLogger().warning("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
reason.add("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.SMELTING_SECOND_SMELT) < 1) {
mcMMO.p.getLogger().warning("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
reason.add("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
}
if (getFluxMiningChance() < 1) {
mcMMO.p.getLogger().warning("Skills.Smelting.FluxMining.Chance should be at least 1!");
reason.add("Skills.Smelting.FluxMining.Chance should be at least 1!");
}
/* SWORDS */
if (getMaximumProbability(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
reason.add("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.MaxBonusLevel should be at least 1!");
reason.add("Skills.Swords.CounterAttack.MaxBonusLevel should be at least 1!");
}
if (getCounterModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.DamageModifier should be at least 1!");
reason.add("Skills.Swords.CounterAttack.DamageModifier should be at least 1!");
}
if (getSerratedStrikesModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
reason.add("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
}
if (getSerratedStrikesTicks() < 1) {
mcMMO.p.getLogger().warning("Skills.Swords.SerratedStrikes.RuptureTicks should be at least 1!");
reason.add("Skills.Swords.SerratedStrikes.RuptureTicks should be at least 1!");
}
/* TAMING */
if (getMaximumProbability(SubSkillType.TAMING_GORE) < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.Gore.ChanceMax should be at least 1!");
reason.add("Skills.Taming.Gore.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.TAMING_GORE) < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
reason.add("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
}
/*if (getGoreRuptureTicks() < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.Gore.RuptureTicks should be at least 1!");
reason.add("Skills.Taming.Gore.RuptureTicks should be at least 1!");
}*/
if (getGoreModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.Gore.Modifier should be at least 1!");
reason.add("Skills.Taming.Gore.Modifier should be at least 1!");
}
/*if (getFastFoodUnlock() < 0) {
mcMMO.p.getLogger().warning("Skills.Taming.FastFood.UnlockLevel should be at least 0!");
reason.add("Skills.Taming.FastFood.UnlockLevel should be at least 0!");
}*/
if (getFastFoodChance() < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.FastFood.Chance should be at least 1!");
reason.add("Skills.Taming.FastFood.Chance should be at least 1!");
}
/*if (getEnviromentallyAwareUnlock() < 0) {
mcMMO.p.getLogger().warning("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 0!");
reason.add("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 0!");
}*/
/*if (getThickFurUnlock() < 0) {
mcMMO.p.getLogger().warning("Skills.Taming.ThickFur.UnlockLevel should be at least 0!");
reason.add("Skills.Taming.ThickFur.UnlockLevel should be at least 0!");
}*/
if (getThickFurModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.ThickFur.Modifier should be at least 1!");
reason.add("Skills.Taming.ThickFur.Modifier should be at least 1!");
}
/*if (getHolyHoundUnlock() < 0) {
mcMMO.p.getLogger().warning("Skills.Taming.HolyHound.UnlockLevel should be at least 0!");
reason.add("Skills.Taming.HolyHound.UnlockLevel should be at least 0!");
}
if (getShockProofUnlock() < 0) {
mcMMO.p.getLogger().warning("Skills.Taming.ShockProof.UnlockLevel should be at least 0!");
reason.add("Skills.Taming.ShockProof.UnlockLevel should be at least 0!");
}*/
if (getShockProofModifier() < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.ShockProof.Modifier should be at least 1!");
reason.add("Skills.Taming.ShockProof.Modifier should be at least 1!");
}
/*if (getSharpenedClawsUnlock() < 0) {
mcMMO.p.getLogger().warning("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 0!");
reason.add("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 0!");
}*/
if (getSharpenedClawsBonus() < 1) {
mcMMO.p.getLogger().warning("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
}
if (getMaxHorseJumpStrength() < 0 || getMaxHorseJumpStrength() > 2) {
mcMMO.p.getLogger().warning("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
reason.add("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
}
/* UNARMED */
if (getMaximumProbability(SubSkillType.UNARMED_DISARM) < 1) {
mcMMO.p.getLogger().warning("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
reason.add("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.UNARMED_DISARM) < 1) {
mcMMO.p.getLogger().warning("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
reason.add("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.UNARMED_ARROW_DEFLECT) < 1) {
mcMMO.p.getLogger().warning("Skills.Unarmed.ArrowDeflect.ChanceMax should be at least 1!");
reason.add("Skills.Unarmed.ArrowDeflect.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.UNARMED_ARROW_DEFLECT) < 1) {
mcMMO.p.getLogger().warning("Skills.Unarmed.ArrowDeflect.MaxBonusLevel should be at least 1!");
reason.add("Skills.Unarmed.ArrowDeflect.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.UNARMED_IRON_GRIP) < 1) {
mcMMO.p.getLogger().warning("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
reason.add("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.UNARMED_IRON_GRIP) < 1) {
mcMMO.p.getLogger().warning("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
reason.add("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
}
/* WOODCUTTING */
/*if (getLeafBlowUnlockLevel() < 0) {
mcMMO.p.getLogger().warning("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
reason.add("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
}*/
if (getMaximumProbability(SubSkillType.WOODCUTTING_HARVEST_LUMBER) < 1) {
mcMMO.p.getLogger().warning("Skills.Woodcutting.HarvestLumber.ChanceMax should be at least 1!");
reason.add("Skills.Woodcutting.HarvestLumber.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.WOODCUTTING_HARVEST_LUMBER) < 1) {
mcMMO.p.getLogger().warning("Skills.Woodcutting.HarvestLumber.MaxBonusLevel should be at least 1!");
reason.add("Skills.Woodcutting.HarvestLumber.MaxBonusLevel should be at least 1!");
}
return noErrorsInConfig(reason);
}
@Override
@@ -425,7 +422,7 @@ public class AdvancedConfig extends BukkitConfig {
/**
* 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
*/
@@ -438,7 +435,7 @@ public class AdvancedConfig extends BukkitConfig {
/**
* 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
*/
@@ -630,7 +627,11 @@ public class AdvancedConfig extends BukkitConfig {
/* ALCHEMY */
public int getCatalysisMaxBonusLevel() {
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000);
if (mcMMO.isRetroModeEnabled()) {
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel.RetroMode", 1000);
} else {
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel.Standard", 100);
}
}
public double getCatalysisMinSpeed() {
@@ -696,6 +697,15 @@ public class AdvancedConfig extends BukkitConfig {
return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D);
}
/* CROSSBOWS */
public double getPoweredShotRankDamageMultiplier() {
return config.getDouble("Skills.Crossbows.PoweredShot.RankDamageMultiplier", 10.0D);
}
public double getPoweredShotDamageMax() {
return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D);
}
/* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml
@@ -775,6 +785,10 @@ public class AdvancedConfig extends BukkitConfig {
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);
}

View File

@@ -1,6 +1,7 @@
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;
@@ -10,28 +11,28 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName, File dataFolder) {
public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
public AutoUpdateLegacyConfigLoader(String relativePath, String fileName, File dataFolder) {
super(relativePath, fileName, dataFolder);
}
public AutoUpdateConfigLoader(String fileName, File dataFolder) {
public AutoUpdateLegacyConfigLoader(String fileName, File dataFolder) {
super(fileName, dataFolder);
}
@Deprecated
public AutoUpdateConfigLoader(String relativePath, String fileName) {
public AutoUpdateLegacyConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName);
}
@Deprecated
public AutoUpdateConfigLoader(String fileName) {
public AutoUpdateLegacyConfigLoader(String fileName) {
super(fileName);
}
protected void saveConfig() {
try {
mcMMO.p.getLogger().info("Saving changes to config file - " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Saving changes to config file - " + fileName);
config.options().indent(2);
config.save(configFile);
} catch (IOException e) {
@@ -58,9 +59,9 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
oldKeys.removeAll(internalConfigKeys);
if (!oldKeys.isEmpty()) {
mcMMO.p.debug("old key(s) in \"" + fileName + "\"");
LogUtils.debug(mcMMO.p.getLogger(), "old key(s) in \"" + fileName + "\"");
for (String key : oldKeys) {
mcMMO.p.debug(" old-key:" + key);
LogUtils.debug(mcMMO.p.getLogger(), " old-key:" + key);
}
}
@@ -73,7 +74,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
}
for (String key : newKeys) {
mcMMO.p.debug("Adding new key: " + key + " = " + internalConfig.get(key));
LogUtils.debug(mcMMO.p.getLogger(), "Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}

View File

@@ -1,47 +1,49 @@
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.*;
import java.util.HashSet;
import java.util.Set;
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 {
protected static final String CONFIG_PATCH_PREFIX = "ConfigPatchVersion:";
protected static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 2";
protected static final char COMMENT_PREFIX = '#';
boolean copyDefaults = true;
protected final String fileName;
protected final File configFile;
protected YamlConfiguration defaultYamlConfig;
protected YamlConfiguration config;
protected @NotNull
final File dataFolder;
protected boolean unmodifiedConfig = true; //Used to mark when we have made a fix that needs an immediate save
protected @NotNull final File dataFolder;
private boolean savedDefaults = false;
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
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);
purgeComments(true);
this.defaultYamlConfig = saveDefaultConfigToDisk();
this.config = initConfig();
initDefaults();
updateFile();
mcMMO.p.getLogger().info("[config] Config initialized: " + fileName);
validate();
LogUtils.debug(mcMMO.p.getLogger(), "Config initialized: " + fileName);
}
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
this(fileName, dataFolder, true);
}
@Deprecated
public BukkitConfig(@NotNull String fileName) {
this(fileName, mcMMO.p.getDataFolder());
}
/**
* Initialize default values for the config
*/
public void initDefaults() {}
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
@@ -49,18 +51,70 @@ public abstract class BukkitConfig {
public void updateFile() {
try {
config.save(configFile);
if(copyDefaults && !savedDefaults) {
copyMissingDefaultsFromResource();
savedDefaults = true;
}
} catch (IOException e) {
e.printStackTrace();
}
}
private YamlConfiguration initConfig() {
/**
* 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()) {
mcMMO.p.getLogger().info("[config] User config file not found, copying a default config to disk: " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "User config file not found, copying a default config to disk: " + fileName);
mcMMO.p.saveResource(fileName, false);
}
mcMMO.p.getLogger().info("[config] Loading config from disk: " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Loading config from disk: " + fileName);
YamlConfiguration config = new YamlConfiguration();
config.options().indent(4);
@@ -84,34 +138,31 @@ public abstract class BukkitConfig {
protected abstract void loadKeys();
protected abstract void validateConfigKeys();
protected void fixConfigKey(@NotNull String key, @NotNull String value, @NotNull String reason) {
mcMMO.p.getLogger().warning(reason);
config.set(key, value);
this.unmodifiedConfig = false; //flag to save config
protected boolean validateKeys() {
return true;
}
private void validate() {
//TODO: Rewrite legacy validation code
validateConfigKeys();
protected boolean noErrorsInConfig(List<String> issues) {
for (String issue : issues) {
mcMMO.p.getLogger().warning(issue);
}
if (unmodifiedConfig) {
mcMMO.p.debug("No errors found in " + fileName + "!");
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 + ", overwriting invalid values with defaults");
try {
config.save(configFile);
unmodifiedConfig = true;
} catch (IOException e) {
e.printStackTrace();
}
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() {
mcMMO.p.getLogger().severe("You are using an old version of the " + fileName + " file.");
mcMMO.p.getLogger().severe("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
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"));
@@ -127,98 +178,4 @@ public abstract class BukkitConfig {
public File getFile() {
return configFile;
}
/**
* Somewhere between December 2021-January 2022 Spigot updated their
* SnakeYAML dependency/API and due to our own crappy legacy code
* this introduced a very problematic bug where comments got duplicated
* <p>
* This method hotfixes the problem by just deleting any existing comments
* it's ugly, but it gets the job done
*
* @param silentFail when true mcMMO will report errors during the patch process or debug information
* the option to have it fail silently is because mcMMO wants to check files before they are parsed as a file with a zillion comments will fail to even load
*/
private void purgeComments(boolean silentFail) {
if(!configFile.exists())
return;
int dupedLines = 0, lineCount = 0, lineCountAfter = 0;
try (FileReader fileReader = new FileReader(configFile);
BufferedReader bufferedReader = new BufferedReader(fileReader)) {
StringBuilder stringBuilder = new StringBuilder();
String line;
Set<String> seenBefore = new HashSet<>();
stringBuilder.append(CURRENT_CONFIG_PATCH_VER).append(System.lineSeparator());
boolean noPatchNeeded = false;
// While not at the end of the file
while ((line = bufferedReader.readLine()) != null) {
lineCount++;
if(line.startsWith(CURRENT_CONFIG_PATCH_VER)) {
noPatchNeeded = true;
break;
}
//Older version, don't append this line
if(line.startsWith(CONFIG_PATCH_PREFIX))
continue;
if (isFirstCharAsciiCharacter(line, COMMENT_PREFIX)) {
if(seenBefore.contains(line))
dupedLines++;
else
seenBefore.add(line);
continue; //Delete the line by not appending it
}
stringBuilder
.append(line) //Convert existing files into two-spaced format
.append(System.lineSeparator());
lineCountAfter++;
}
if(noPatchNeeded)
return;
if(lineCount == 0 && !silentFail) {
mcMMO.p.getLogger().info("[config patcher] Config line count: " + lineCount);
throw new InvalidConfigurationException("[config patcher] Patching of config file resulted in an empty file, this will not be saved. Contact the mcMMO devs!");
}
if(dupedLines > 0 && !silentFail) {
mcMMO.p.getLogger().info("[config patcher] Found "+dupedLines+" duplicate comments in config file: " + configFile.getName());
mcMMO.p.getLogger().info("[config patcher] Purging the duplicate comments... (Nothing is broken, this is just info used for debugging)");
mcMMO.p.getLogger().info("[config patcher] Line count before: "+lineCount);
mcMMO.p.getLogger().info("[config patcher] Line count after: "+lineCountAfter);
}
// Write out the *patched* file
// AKA the file without any comments
try (FileWriter fileWriter = new FileWriter(configFile)) {
fileWriter.write(stringBuilder.toString());
}
} catch (IOException | InvalidConfigurationException ex) {
mcMMO.p.getLogger().severe("Failed to patch config file: " + configFile.getName());
ex.printStackTrace();
}
}
private boolean isFirstCharAsciiCharacter(String line, char character) {
if(line == null || line.isEmpty()) {
return true;
}
for(Character c : line.toCharArray()) {
if(c.equals(' '))
continue;
return c.equals(character);
}
return false;
}
}

View File

@@ -9,6 +9,7 @@ public class ChatConfig extends BukkitConfig {
private ChatConfig() {
super("chat.yml");
validate();
}
public static ChatConfig getInstance() {
@@ -25,8 +26,8 @@ public class ChatConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
return true;
}
public boolean isChatEnabled() {
@@ -39,7 +40,7 @@ public class ChatConfig extends BukkitConfig {
}
/**
* 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
*
@@ -50,6 +51,12 @@ public class ChatConfig extends BukkitConfig {
return config.getBoolean(key, true);
}
public boolean isConsoleIncludedInAudience(@NotNull ChatChannel chatChannel) {
String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Send_To_Console";
return config.getBoolean(key, true);
}
public boolean isSpyingAutomatic() {
return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
}

View File

@@ -9,6 +9,7 @@ public class CoreSkillsConfig extends BukkitConfig {
public CoreSkillsConfig() {
super("coreskills.yml");
validate();
}
public static CoreSkillsConfig getInstance() {
@@ -24,8 +25,9 @@ public class CoreSkillsConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
return true;
}
/*
@@ -33,7 +35,7 @@ public class CoreSkillsConfig extends BukkitConfig {
*/
/**
* Whether or not a skill is enabled
* Whether a skill is enabled
* Defaults true
*
* @param abstractSubSkill SubSkill definition to check
@@ -45,7 +47,7 @@ public class CoreSkillsConfig extends BukkitConfig {
}
/**
* Whether or not this primary skill is enabled
* Whether this primary skill is enabled
*
* @param primarySkillType target primary skill
*

View File

@@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@@ -23,6 +22,7 @@ public class GeneralConfig extends BukkitConfig {
public GeneralConfig(@NotNull File dataFolder) {
super("config.yml", dataFolder);
validate();
}
@Override
@@ -31,125 +31,127 @@ public class GeneralConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<>();
/* General Settings */
if (getSaveInterval() <= 0) {
mcMMO.p.getLogger().info("General.Save_Interval should be greater than 0!");
reason.add("General.Save_Interval should be greater than 0!");
}
/* MySQL Settings */
for (PoolIdentifier identifier : PoolIdentifier.values()) {
if (getMySQLMaxConnections(identifier) <= 0) {
mcMMO.p.getLogger().warning("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
reason.add("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
}
if (getMySQLMaxPoolSize(identifier) <= 0) {
mcMMO.p.getLogger().warning("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
reason.add("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
}
}
/* Mob Healthbar */
if (getMobHealthbarTime() == 0) {
mcMMO.p.getLogger().warning("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
}
/* Database Purging */
if (getPurgeInterval() < -1) {
mcMMO.p.getLogger().warning("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
}
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
mcMMO.p.getLogger().warning("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
mcMMO.p.getLogger().warning("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
mcMMO.p.getLogger().warning("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
}
/* Items */
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
}
if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 9!");
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 9!");
}
if (getChimaeraItem() == null) {
mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Item_Name is invalid!");
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
}
/* Particles */
if (getLevelUpEffectsTier() < 1) {
mcMMO.p.getLogger().warning("Particles.LevelUp_Tier should be at least 1!");
reason.add("Particles.LevelUp_Tier should be at least 1!");
}
/* PARTY SETTINGS */
if (getAutoPartyKickInterval() < -1) {
mcMMO.p.getLogger().warning("Party.AutoKick_Interval should be at least -1!");
reason.add("Party.AutoKick_Interval should be at least -1!");
}
if (getAutoPartyKickTime() < 0) {
mcMMO.p.getLogger().warning("Party.Old_Party_Member_Cutoff should be at least 0!");
reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
}
if (getPartyShareBonusBase() <= 0) {
mcMMO.p.getLogger().warning("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
}
if (getPartyShareBonusIncrease() < 0) {
mcMMO.p.getLogger().warning("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
}
if (getPartyShareBonusCap() <= 0) {
mcMMO.p.getLogger().warning("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
}
if (getPartyShareRange() <= 0) {
mcMMO.p.getLogger().warning("Party.Sharing.Range should be greater than 0!");
reason.add("Party.Sharing.Range should be greater than 0!");
}
if (getPartyXpCurveMultiplier() < 1) {
mcMMO.p.getLogger().warning("Party.Leveling.Xp_Curve_Modifier should be at least 1!");
reason.add("Party.Leveling.Xp_Curve_Modifier should be at least 1!");
}
for (PartyFeature partyFeature : PartyFeature.values()) {
if (getPartyFeatureUnlockLevel(partyFeature) < 0) {
mcMMO.p.getLogger().warning("Party.Leveling." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "") + "_UnlockLevel should be at least 0!");
reason.add("Party.Leveling." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "") + "_UnlockLevel should be at least 0!");
}
}
/* Inspect command distance */
if (getInspectDistance() <= 0) {
mcMMO.p.getLogger().warning("Commands.inspect.Max_Distance should be greater than 0!");
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
}
if (getTreeFellerThreshold() <= 0) {
mcMMO.p.getLogger().warning("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getFishingLureModifier() < 0) {
mcMMO.p.getLogger().warning("Abilities.Fishing.Lure_Modifier should be at least 0!");
reason.add("Abilities.Fishing.Lure_Modifier should be at least 0!");
}
if (getRepairAnvilMaterial() == null) {
mcMMO.p.getLogger().warning("Skills.Repair.Anvil_Type is invalid!!");
reason.add("Skills.Repair.Anvil_Type is invalid!!");
}
if (getSalvageAnvilMaterial() == null) {
mcMMO.p.getLogger().warning("Skills.Repair.Salvage_Anvil_Type is invalid!");
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
}
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
mcMMO.p.getLogger().warning("Cannot use the same item for Repair and Salvage anvils!");
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
return noErrorsInConfig(reason);
}
/*
@@ -1003,4 +1005,10 @@ public class GeneralConfig extends BukkitConfig {
public boolean isGreenThumbReplantableCrop(@NotNull Material material) {
return config.getBoolean("Green_Thumb_Replanting_Crops." + StringUtils.getCapitalized(material.toString()), true);
}
public boolean useVerboseLogging() {
return config.getBoolean("General.Verbose_Logging", false);
}
public boolean isMasterySystemEnabled() { return config.getBoolean( "General.PowerLevel.Skill_Mastery.Enabled"); }
}

View File

@@ -1,26 +1,28 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
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 {
@Deprecated
public abstract class LegacyConfigLoader {
protected final File configFile;
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);
@@ -28,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();
@@ -36,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();
@@ -45,7 +47,7 @@ public abstract class ConfigLoader {
protected void loadFile() {
if (!configFile.exists()) {
mcMMO.p.getLogger().info("Creating mcMMO " + fileName + " File...");
LogUtils.debug(mcMMO.p.getLogger(), "Creating mcMMO " + fileName + " File...");
try {
mcMMO.p.saveResource(fileName, false); // Normal files
@@ -53,7 +55,7 @@ public abstract class ConfigLoader {
mcMMO.p.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
} else {
mcMMO.p.getLogger().info("Loading mcMMO " + fileName + " File...");
LogUtils.debug(mcMMO.p.getLogger(), "Loading mcMMO " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
@@ -75,10 +77,11 @@ public abstract class ConfigLoader {
protected void validate() {
if (validateKeys()) {
mcMMO.p.debug("No errors found in " + fileName + "!");
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;
}
}

View File

@@ -7,6 +7,7 @@ public class PersistentDataConfig extends BukkitConfig {
private PersistentDataConfig() {
super("persistent_data.yml");
validate();
}
public static PersistentDataConfig getInstance() {
@@ -23,8 +24,8 @@ public class PersistentDataConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
return true;
}
//Persistent Data Toggles

View File

@@ -3,13 +3,14 @@ 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() {
@@ -66,7 +67,7 @@ public class RankConfig extends AutoUpdateConfigLoader {
*/
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));
}
/**
@@ -128,9 +129,9 @@ 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);
}
/**
@@ -147,10 +148,10 @@ public class RankConfig extends AutoUpdateConfigLoader {
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());
LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
fixBadEntries(subSkillType);
}
}
@@ -178,7 +179,7 @@ public class RankConfig extends AutoUpdateConfigLoader {
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 + " 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);
}
}
@@ -195,6 +196,6 @@ public class RankConfig extends AutoUpdateConfigLoader {
resetRankValue(subSkillType, index, false);
}
saveConfig();
updateFile();
}
}

View File

@@ -1,6 +1,7 @@
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 BukkitConfig {
@@ -8,6 +9,7 @@ public class SoundConfig extends BukkitConfig {
public SoundConfig() {
super("sounds.yml");
validate();
instance = this;
}
@@ -24,24 +26,22 @@ public class SoundConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
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);
//TODO: Rewrite legacy validation code
//return false;
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 + ".Pitch") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType);
//TODO: Rewrite legacy validation code
//return false;
LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound pitch cannot be below 0 for " + soundType);
return false;
}
}
}
return true;
}
public float getMasterVolume() {

View File

@@ -73,7 +73,8 @@ 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) {

View File

@@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -14,17 +13,16 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
public class ExperienceConfig extends BukkitConfig {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
@@ -35,18 +33,12 @@ public class ExperienceConfig extends BukkitConfig {
return instance;
}
@Override
public void initDefaults() {
super.initDefaults();
}
@Override
protected void loadKeys() {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
List<String> reason = new ArrayList<>();
/*
@@ -54,48 +46,41 @@ public class ExperienceConfig extends BukkitConfig {
*/
/* Curve values */
final BiConsumer<String, Object> consumer = (String str, Object obj) -> config.set(str, obj);
if (getMultiplier(FormulaType.LINEAR) <= 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
config.set("Experience_Formula." + StringUtils.getCapitalized(FormulaType.LINEAR.toString()) + "_Values.multiplier", 0.1);
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
config.set("Experience_Formula." + StringUtils.getCapitalized(FormulaType.EXPONENTIAL.toString()) + "_Values.multiplier", 0.1);
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
config.set("Experience_Formula." + StringUtils.getCapitalized(FormulaType.EXPONENTIAL.toString()) + "_Values.exponent", 1.80);
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Multiplier.Global should be at least 0!");
config.set("Experience_Formula.Multiplier.Global", 1.0);
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Multiplier.PVP should be at least 0!");
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Breeding.Multiplier should be at least 0!");
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
mcMMO.p.getLogger().warning("Conversion.Exp_Modifier should be greater than 0!");
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
@@ -105,52 +90,54 @@ public class ExperienceConfig extends BukkitConfig {
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
mcMMO.p.getLogger().warning("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
mcMMO.p.getLogger().warning("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
mcMMO.p.getLogger().warning("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
mcMMO.p.getLogger().warning("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
mcMMO.p.getLogger().warning("Experience_Values.Fishing.Shake should be greater than 0!");
reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
mcMMO.p.getLogger().warning("Experience_Values.Repair.Base should be greater than 0!");
reason.add("Experience_Values.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) {
mcMMO.p.getLogger().warning("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXP(EntityType.OCELOT) <= 0) {
mcMMO.p.getLogger().warning("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
return noErrorsInConfig(reason);
}
public boolean isEarlyGameBoostEnabled() {
@@ -269,7 +256,7 @@ public class ExperienceConfig extends BukkitConfig {
/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) {
return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()));
return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()), 1);
}
/* Custom XP perk */
@@ -309,6 +296,10 @@ public class ExperienceConfig extends BukkitConfig {
}
/* Combat XP Multipliers */
public double getCombatXP(String entity) {
return config.getDouble("Experience_Values.Combat.Multiplier." + entity);
}
public double getCombatXP(EntityType entity) {
return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
}
@@ -327,96 +318,73 @@ public class ExperienceConfig extends BukkitConfig {
/* Materials */
public int getXp(PrimarySkillType skill, Material material) {
//TODO: Temporary measure to fix an exploit caused by a yet to be fixed Spigot bug (as of 7/3/2020)
if (material.toString().equalsIgnoreCase("LILY_PAD"))
return 0;
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(material);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(material);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(material);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
return getXpHelper(skill, StringUtils.getExplicitConfigMaterialString(material),
StringUtils.getFriendlyConfigMaterialString(material),
StringUtils.getWildcardConfigMaterialString(material));
}
/* Materials */
public int getXp(PrimarySkillType skill, BlockState blockState) {
Material data = blockState.getType();
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
Material material = blockState.getType();
return getXp(skill, material);
}
/* Materials */
public int getXp(PrimarySkillType skill, Block block) {
Material data = block.getType();
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
Material material = block.getType();
return getXp(skill, material);
}
/* Materials */
public int getXp(PrimarySkillType skill, BlockData data) {
return getXpHelper(skill, StringUtils.getExplicitConfigBlockDataString(data),
StringUtils.getFriendlyConfigBlockDataString(data),
StringUtils.getWildcardConfigBlockDataString(data));
}
private int getXpHelper(PrimarySkillType skill, String explicitString, String friendlyString, String wildcardString) {
if (explicitString.equalsIgnoreCase("LILY_PAD")) {
return 0;
}
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
String[] configStrings = {explicitString, friendlyString, wildcardString};
for (String configString : configStrings) {
String fullPath = baseString + configString;
if (config.contains(fullPath)) {
return config.getInt(fullPath);
}
}
return 0;
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data) {
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
return config.contains(wildcardString);
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material material) {
return doesBlockGiveSkillXPHelper(skill, StringUtils.getExplicitConfigMaterialString(material),
StringUtils.getFriendlyConfigMaterialString(material),
StringUtils.getWildcardConfigMaterialString(material));
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data) {
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
return config.contains(wildcardString);
return doesBlockGiveSkillXPHelper(skill, StringUtils.getExplicitConfigBlockDataString(data),
StringUtils.getFriendlyConfigBlockDataString(data),
StringUtils.getWildcardConfigBlockDataString(data));
}
private boolean doesBlockGiveSkillXPHelper(PrimarySkillType skill, String explicitString, String friendlyString, String wildcardString) {
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String[] configStrings = {explicitString, friendlyString, wildcardString};
for (String configString : configStrings) {
String fullPath = baseString + configString;
if (config.contains(fullPath)) {
return true;
}
}
return false;
}
/*
* Experience Bar Stuff
*/
@@ -436,6 +404,13 @@ public class ExperienceConfig extends BukkitConfig {
public boolean getAddExtraDetails() {
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);
}
public boolean useCombatHPCeiling() {
return config.getBoolean("ExploitFix.Combat.XPCeiling.Enabled", true);
}
public int getCombatHPCeiling() {
return config.getInt("ExploitFix.Combat.XPCeiling.HP_Modifier_Limit", 100);
}
public boolean isExperienceBarsEnabled() {
return config.getBoolean("Experience_Bars.Enable", true);

View File

@@ -29,7 +29,7 @@ public class ArmorConfigManager {
continue;
}
modManager.registerCustomArmor(new CustomArmorConfig(fileName));
modManager.registerCustomArmor(new CustomArmorLegacyConfig(fileName));
}
}
}

View File

@@ -29,7 +29,7 @@ public class BlockConfigManager {
continue;
}
modManager.registerCustomBlocks(new CustomBlockConfig(fileName));
modManager.registerCustomBlocks(new CustomBlockLegacyConfig(fileName));
}
}
}

View File

@@ -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,7 +13,7 @@ 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<>();
@@ -21,7 +21,7 @@ public class CustomArmorConfig extends ConfigLoader {
public List<Repairable> repairables = new ArrayList<>();
private boolean needsUpdate = false;
protected CustomArmorConfig(String fileName) {
protected CustomArmorLegacyConfig(String fileName) {
super("mods", fileName);
loadKeys();
}

View File

@@ -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,7 +11,7 @@ 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<>();
@@ -22,7 +22,7 @@ public class CustomBlockConfig extends ConfigLoader {
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
private boolean needsUpdate = false;
protected CustomBlockConfig(String fileName) {
protected CustomBlockLegacyConfig(String fileName) {
super("mods", fileName);
loadKeys();
}

View File

@@ -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<>();
protected CustomEntityConfig(String fileName) {
protected CustomEntityLegacyConfig(String fileName) {
super("mods", fileName);
loadKeys();
}

View File

@@ -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,7 +15,7 @@ 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<>();
@@ -26,7 +26,7 @@ public class CustomToolConfig extends ConfigLoader {
public List<Repairable> repairables = new ArrayList<>();
private boolean needsUpdate = false;
protected CustomToolConfig(String fileName) {
protected CustomToolLegacyConfig(String fileName) {
super("mods", fileName);
loadKeys();
}

View File

@@ -29,7 +29,7 @@ public class EntityConfigManager {
continue;
}
modManager.registerCustomEntities(new CustomEntityConfig(fileName));
modManager.registerCustomEntities(new CustomEntityLegacyConfig(fileName));
}
}
}

View File

@@ -29,7 +29,7 @@ public class ToolConfigManager {
continue;
}
modManager.registerCustomTools(new CustomToolConfig(fileName));
modManager.registerCustomTools(new CustomToolLegacyConfig(fileName));
}
}
}

View File

@@ -22,11 +22,6 @@ public class ItemWeightConfig extends BukkitConfig {
return instance;
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
public int getItemWeight(Material material) {
return config.getInt("Item_Weights." + StringUtils.getPrettyItemString(material).replace(" ", "_"), config.getInt("Item_Weights.Default"));
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.config.party;
import com.gmail.nossr50.config.BukkitConfig;
import java.io.File;
public class PartyConfig extends BukkitConfig {
public PartyConfig(File dataFolder) {
super("party.yml", dataFolder);
validate();
}
@Override
protected void loadKeys() {
}
public boolean isPartyEnabled() {
return config.getBoolean("Party.Enabled", true);
}
}

View File

@@ -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<>();
@@ -100,7 +101,7 @@ public class PotionConfig extends ConfigLoader {
}
}
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
}
/**

View File

@@ -7,6 +7,7 @@ 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;
@@ -17,17 +18,12 @@ 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();
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override
protected void loadKeys() {
repairables = new ArrayList<>();
@@ -53,7 +49,7 @@ public class RepairConfig extends BukkitConfig {
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;
}
@@ -86,7 +82,7 @@ public class RepairConfig extends BukkitConfig {
try {
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
} catch (IllegalArgumentException ex) {
mcMMO.p.getLogger().warning(key + " has an invalid MaterialType of " + repairMaterialTypeString);
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
}
}
@@ -107,7 +103,7 @@ public class RepairConfig extends BukkitConfig {
}
if (maximumDurability <= 0) {
mcMMO.p.getLogger().warning("Maximum durability of " + key + " must be greater than 0!");
reason.add("Maximum durability of " + key + " must be greater than 0!");
}
// Item Type
@@ -126,7 +122,7 @@ public class RepairConfig extends BukkitConfig {
try {
repairItemType = ItemType.valueOf(repairItemTypeString);
} catch (IllegalArgumentException ex) {
mcMMO.p.getLogger().warning(key + " has an invalid ItemType of " + repairItemTypeString);
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
}
@@ -134,7 +130,7 @@ public class RepairConfig extends BukkitConfig {
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) {
mcMMO.p.getLogger().warning(key + " has an invalid MinimumLevel of " + minimumLevel);
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
}
// Minimum Quantity
@@ -165,8 +161,8 @@ public class RepairConfig extends BukkitConfig {
}
}
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.");
}
}

View File

@@ -16,7 +16,7 @@ public class RepairConfigManager {
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder();
RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML);
RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML, true);
repairables.addAll(mainRepairConfig.getLoadedRepairables());
for (String fileName : dataFolder.list()) {
@@ -33,7 +33,7 @@ public class RepairConfigManager {
continue;
}
RepairConfig rConfig = new RepairConfig(fileName);
RepairConfig rConfig = new RepairConfig(fileName, false);
repairables.addAll(rConfig.getLoadedRepairables());
}
}

View File

@@ -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,22 +16,18 @@ import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
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 validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override
protected void loadKeys() {
salvageables = new HashSet<>();
@@ -46,7 +43,7 @@ public class SalvageConfig extends BukkitConfig {
//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...");
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
}
@@ -54,9 +51,9 @@ public class SalvageConfig extends BukkitConfig {
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();
}
}
@@ -102,7 +99,7 @@ public class SalvageConfig extends BukkitConfig {
try {
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
mcMMO.p.getLogger().warning(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
}
}
@@ -134,7 +131,7 @@ public class SalvageConfig extends BukkitConfig {
try {
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
mcMMO.p.getLogger().warning(key + " has an invalid ItemType of " + salvageItemTypeString);
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
}
}
@@ -142,7 +139,7 @@ public class SalvageConfig extends BukkitConfig {
double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) {
mcMMO.p.getLogger().warning(key + " has an invalid MinimumLevel of " + minimumLevel);
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
}
// Maximum Quantity
@@ -159,7 +156,7 @@ public class SalvageConfig extends BukkitConfig {
}
if (maximumQuantity <= 0) {
mcMMO.p.getLogger().warning("Maximum quantity of " + key + " must be greater than 0!");
reason.add("Maximum quantity of " + key + " must be greater than 0!");
}
if (noErrorsInSalvageable(reason)) {
@@ -183,8 +180,8 @@ public class SalvageConfig extends BukkitConfig {
}
}
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.");
}
}

View File

@@ -17,7 +17,7 @@ public class SalvageConfigManager {
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder();
SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML);
SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML, true);
salvageables.addAll(mainSalvageConfig.getLoadedSalvageables());
for (String fileName : dataFolder.list()) {
@@ -34,7 +34,7 @@ public class SalvageConfigManager {
continue;
}
SalvageConfig salvageConfig = new SalvageConfig(fileName);
SalvageConfig salvageConfig = new SalvageConfig(fileName, false);
salvageables.addAll(salvageConfig.getLoadedSalvageables());
}
}

View File

@@ -4,6 +4,7 @@ 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;
@@ -28,8 +29,9 @@ public class FishingTreasureConfig extends BukkitConfig {
public @NotNull HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
private FishingTreasureConfig() {
super(FILENAME);
super(FILENAME, false);
loadKeys();
validate();
}
public static FishingTreasureConfig getInstance() {
@@ -41,8 +43,8 @@ public class FishingTreasureConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<>();
ConfigurationSection enchantment_drop_rates = config.getConfigurationSection("Enchantment_Drop_Rates");
@@ -56,11 +58,11 @@ public class FishingTreasureConfig extends BukkitConfig {
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity);
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) {
mcMMO.p.getLogger().warning("The enchant drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 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) {
mcMMO.p.getLogger().warning("The item drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
reason.add("The item drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
}
totalEnchantDropRate += enchantDropRate;
@@ -68,16 +70,18 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
mcMMO.p.getLogger().warning("The total enchant drop rate for " + tier + " should be between 0.0 and 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) {
mcMMO.p.getLogger().warning("The total item drop rate for " + tier + " should be between 0.0 and 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);
}
@Override
@@ -138,7 +142,7 @@ public class FishingTreasureConfig extends BukkitConfig {
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) {
mcMMO.p.getLogger().warning("Cannot find matching item type in this version of MC, skipping - " + materialName);
reason.add("Cannot find matching item type in this version of MC, skipping - " + materialName);
continue;
}
@@ -147,7 +151,7 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (material.isBlock() && (data > 127 || data < -128)) {
mcMMO.p.getLogger().warning("Data of " + treasureName + " is invalid! " + data);
reason.add("Data of " + treasureName + " is invalid! " + data);
}
/*
@@ -159,15 +163,15 @@ public class FishingTreasureConfig extends BukkitConfig {
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (xp < 0) {
mcMMO.p.getLogger().warning(treasureName + " has an invalid XP value: " + xp);
reason.add(treasureName + " has an invalid XP value: " + xp);
}
if (dropChance < 0.0D) {
mcMMO.p.getLogger().warning(treasureName + " has an invalid Drop_Chance: " + dropChance);
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
}
if (dropLevel < 0) {
mcMMO.p.getLogger().warning("Fishing Config: " + treasureName + " has an invalid Drop_Level: " + dropLevel);
reason.add("Fishing Config: " + treasureName + " has an invalid Drop_Level: " + dropLevel);
}
/*
@@ -202,7 +206,7 @@ public class FishingTreasureConfig extends BukkitConfig {
if (materialName.contains("POTION")) {
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
reason.add("Potion format for " + FILENAME + " has changed");
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
@@ -216,7 +220,7 @@ public class FishingTreasureConfig extends BukkitConfig {
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
mcMMO.p.getLogger().warning("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
@@ -279,15 +283,15 @@ public class FishingTreasureConfig extends BukkitConfig {
}
//TODO: Rewrite legacy validation code
// Look into what needs to change for this
if (isFishing) {
addFishingTreasure(rarity, new FishingTreasure(item, xp));
} else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
if (noErrorsInConfig(reason)) {
if (isFishing) {
addFishingTreasure(rarity, new FishingTreasure(item, xp));
} else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
EntityType entityType = EntityType.valueOf(type.substring(6));
addShakeTreasure(shakeTreasure, entityType);
EntityType entityType = EntityType.valueOf(type.substring(6));
addShakeTreasure(shakeTreasure, entityType);
}
}
}
}
@@ -329,7 +333,7 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (!foundMatch) {
mcMMO.p.getLogger().info("[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
LogUtils.debug(mcMMO.p.getLogger(), "[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
}
}
}

View File

@@ -4,6 +4,8 @@ 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.BlockUtils;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -35,8 +37,9 @@ public class TreasureConfig extends BukkitConfig {
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
private TreasureConfig() {
super(FILENAME);
super(FILENAME, false);
loadKeys();
validate();
}
public static TreasureConfig getInstance() {
@@ -48,8 +51,11 @@ public class TreasureConfig extends BukkitConfig {
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<>();
return noErrorsInConfig(reason);
}
@Override
@@ -91,7 +97,7 @@ public class TreasureConfig extends BukkitConfig {
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) {
mcMMO.p.getLogger().warning("Invalid material: " + materialName);
reason.add("Invalid material: " + materialName);
}
if (amount <= 0) {
@@ -99,7 +105,7 @@ public class TreasureConfig extends BukkitConfig {
}
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
mcMMO.p.getLogger().warning("Data of " + treasureName + " is invalid! " + data);
reason.add("Data of " + treasureName + " is invalid! " + data);
}
/*
@@ -143,11 +149,11 @@ public class TreasureConfig extends BukkitConfig {
}
if (xp < 0) {
mcMMO.p.getLogger().warning(treasureName + " has an invalid XP value: " + xp);
reason.add(treasureName + " has an invalid XP value: " + xp);
}
if (dropChance < 0.0D) {
mcMMO.p.getLogger().warning(treasureName + " has an invalid Drop_Chance: " + dropChance);
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
}
/*
@@ -158,7 +164,7 @@ public class TreasureConfig extends BukkitConfig {
if (materialName.contains("POTION")) {
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
reason.add("Potion format for " + FILENAME + " has changed");
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
@@ -167,7 +173,7 @@ public class TreasureConfig extends BukkitConfig {
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
mcMMO.p.getLogger().warning("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
@@ -206,49 +212,49 @@ public class TreasureConfig extends BukkitConfig {
}
}
//TODO: Rewrite legacy validation code
// Look into what needs to change for this
if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
if (noErrorsInConfig(reason)) {
if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
for (String blockType : dropList) {
if (!excavationMap.containsKey(blockType))
excavationMap.put(blockType, new ArrayList<>());
excavationMap.get(blockType).add(excavationTreasure);
}
} else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
for (String blockType : dropList) {
if (!excavationMap.containsKey(blockType))
excavationMap.put(blockType, new ArrayList<>());
excavationMap.get(blockType).add(excavationTreasure);
}
} else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
for (String dropper : dropList) {
if (dropper.equals("Bushes")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure);
for (Material species : Tag.SAPLINGS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
for (String dropper : dropList) {
if (dropper.equals("Bushes")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(BlockUtils.getShortGrass()), hylianTreasure);
for (Material species : Tag.SAPLINGS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
continue;
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
continue;
}
if (dropper.equals("Flowers")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.POPPY), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DANDELION), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.BLUE_ORCHID), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ALLIUM), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.AZURE_BLUET), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ORANGE_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.PINK_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.RED_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.WHITE_TULIP), hylianTreasure);
continue;
}
if (dropper.equals("Pots")) {
for (Material species : Tag.FLOWER_POTS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
continue;
}
AddHylianTreasure(dropper, hylianTreasure);
}
if (dropper.equals("Flowers")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.POPPY), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DANDELION), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.BLUE_ORCHID), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ALLIUM), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.AZURE_BLUET), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ORANGE_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.PINK_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.RED_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.WHITE_TULIP), hylianTreasure);
continue;
}
if (dropper.equals("Pots")) {
for (Material species : Tag.FLOWER_POTS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
continue;
}
AddHylianTreasure(dropper, hylianTreasure);
}
}
}
@@ -268,14 +274,14 @@ public class TreasureConfig extends BukkitConfig {
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
@@ -287,7 +293,7 @@ public class TreasureConfig extends BukkitConfig {
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

View File

@@ -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;
@@ -9,6 +10,7 @@ import java.util.logging.Logger;
public class DatabaseManagerFactory {
private static Class<? extends DatabaseManager> customManager = null;
public static final String MYSQL_DRIVER = "com.mysql.cj.jdbc.Driver";
public static DatabaseManager getDatabaseManager(@NotNull String userFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
if (customManager != null) {
@@ -16,17 +18,17 @@ 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);
return mcMMO.p.getGeneralConfig().getUseMySQL() ? new SQLDatabaseManager(logger, MYSQL_DRIVER) : new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
}
/**
@@ -62,16 +64,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");
return new SQLDatabaseManager();
LogUtils.debug(mcMMO.p.getLogger(), "Using SQL Database");
return new SQLDatabaseManager(logger, "com.mysql.cj.jdbc.Driver");
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) {

View File

@@ -276,6 +276,8 @@ public class FlatFileDataProcessor {
case SKILLS_TAMING:
case SKILLS_FISHING:
case SKILLS_ALCHEMY:
case SKILLS_CROSSBOWS:
case SKILLS_TRIDENTS:
case COOLDOWN_BERSERK:
case COOLDOWN_GIGA_DRILL_BREAKER:
case COOLDOWN_TREE_FELLER:
@@ -286,6 +288,9 @@ public class FlatFileDataProcessor {
case COOLDOWN_BLAST_MINING:
case SCOREBOARD_TIPS:
case COOLDOWN_CHIMAERA_WING:
case COOLDOWN_SUPER_SHOTGUN:
case COOLDOWN_TRIDENTS:
case COOLDOWN_ARCHERY:
return ExpectedType.INTEGER;
case EXP_MINING:
case EXP_WOODCUTTING:
@@ -300,6 +305,8 @@ public class FlatFileDataProcessor {
case EXP_TAMING:
case EXP_FISHING:
case EXP_ALCHEMY:
case EXP_CROSSBOWS:
case EXP_TRIDENTS:
return ExpectedType.FLOAT;
case UUID_INDEX:
return ExpectedType.UUID;

View File

@@ -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;
@@ -79,10 +80,17 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public static final int SCOREBOARD_TIPS = 42;
public static final int COOLDOWN_CHIMAERA_WING = 43;
public static final int OVERHAUL_LAST_LOGIN = 44;
public static final int EXP_CROSSBOWS = 45;
public static final int SKILLS_CROSSBOWS = 46;
public static final int EXP_TRIDENTS = 47;
public static final int SKILLS_TRIDENTS = 48;
public static final int COOLDOWN_SUPER_SHOTGUN = 49;
public static final int COOLDOWN_TRIDENTS = 50;
public static final int COOLDOWN_ARCHERY = 51;
//Update this everytime new data is added
public static final int DATA_ENTRY_COUNT = COOLDOWN_ARCHERY + 1;
public static final int DATA_ENTRY_COUNT = OVERHAUL_LAST_LOGIN + 1; //Update this everytime new data is added
protected FlatFileDatabaseManager(@NotNull File usersFile, @NotNull Logger logger, long purgeTime, int startingLevel, boolean testing) {
FlatFileDatabaseManager(@NotNull File usersFile, @NotNull Logger logger, long purgeTime, int startingLevel, boolean testing) {
this.usersFile = usersFile;
this.usersFilePath = usersFile.getPath();
this.logger = logger;
@@ -98,7 +106,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
List<FlatFileDataFlag> flatFileDataFlags = checkFileHealthAndStructure();
if(flatFileDataFlags != null) {
if(flatFileDataFlags.size() > 0) {
if(!flatFileDataFlags.isEmpty()) {
logger.info("Detected "+flatFileDataFlags.size() + " data entries which need correction.");
}
}
@@ -107,7 +115,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
protected FlatFileDatabaseManager(@NotNull String usersFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
FlatFileDatabaseManager(@NotNull String usersFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
this(new File(usersFilePath), logger, purgeTime, startingLevel, false);
}
@@ -115,7 +123,7 @@ 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;
@@ -183,7 +191,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;
@@ -197,7 +205,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;
@@ -208,7 +217,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();
@@ -216,7 +225,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) {
@@ -235,7 +244,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.write(writer.toString());
if(testing) {
System.out.println(writer.toString());
System.out.println(writer);
}
}
catch (IOException e) {
@@ -465,6 +474,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
appendable.append(String.valueOf(profile.getScoreboardTipsShown())).append(":");
appendable.append(String.valueOf(profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS))).append(":");
appendable.append(String.valueOf(profile.getLastLogin())).append(":"); //overhaul last login
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.CROSSBOWS))).append(":");
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.CROSSBOWS))).append(":");
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.TRIDENTS))).append(":");
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.TRIDENTS))).append(":");
appendable.append("\r\n");
}
@@ -563,16 +576,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
* @return a profile with the targets data or an unloaded profile if no data was found
*/
private @NotNull PlayerProfile processUserQuery(@NotNull UserQuery userQuery) throws RuntimeException {
switch(userQuery.getType()) {
case UUID_AND_NAME:
return queryByUUIDAndName((UserQueryFull) userQuery);
case UUID:
return queryByUUID((UserQueryUUID) userQuery);
case NAME:
return queryByName((UserQueryNameImpl) userQuery);
default:
throw new RuntimeException("No case for this UserQueryType!");
}
return switch (userQuery.getType()) {
case UUID_AND_NAME -> queryByUUIDAndName((UserQueryFull) userQuery);
case UUID -> queryByUUID((UserQueryUUID) userQuery);
case NAME -> queryByName((UserQueryNameImpl) userQuery);
};
}
private @NotNull PlayerProfile queryByName(@NotNull UserQueryName userQuery) {
@@ -601,8 +609,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
continue;
}
//If we couldn't find anyone
// we found the player
if(playerName.equalsIgnoreCase(rawSplitData[USERNAME_INDEX])) {
return loadFromLine(rawSplitData);
}
@@ -679,7 +686,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
* No match was found in the file
*/
return grabUnloadedProfile(uuid, "Player-Not-Found="+uuid.toString());
return grabUnloadedProfile(uuid, "Player-Not-Found="+ uuid);
}
private @NotNull PlayerProfile queryByUUIDAndName(@NotNull UserQueryFull userQuery) {
@@ -714,7 +721,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
+") 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;
@@ -839,7 +846,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();
@@ -897,7 +904,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();
@@ -978,6 +985,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
List<PlayerStat> taming = new ArrayList<>();
List<PlayerStat> fishing = new ArrayList<>();
List<PlayerStat> alchemy = new ArrayList<>();
List<PlayerStat> crossbows = new ArrayList<>();
List<PlayerStat> tridents = new ArrayList<>();
BufferedReader in = null;
String playerName = null;
@@ -1011,6 +1020,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
powerLevel += putStat(taming, playerName, skills.get(PrimarySkillType.TAMING));
powerLevel += putStat(unarmed, playerName, skills.get(PrimarySkillType.UNARMED));
powerLevel += putStat(woodcutting, playerName, skills.get(PrimarySkillType.WOODCUTTING));
powerLevel += putStat(crossbows, playerName, skills.get(PrimarySkillType.CROSSBOWS));
powerLevel += putStat(tridents, playerName, skills.get(PrimarySkillType.TRIDENTS));
putStat(powerLevels, playerName, powerLevel);
}
@@ -1046,6 +1057,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
taming.sort(c);
fishing.sort(c);
alchemy.sort(c);
crossbows.sort(c);
tridents.sort(c);
powerLevels.sort(c);
playerStatHash.put(PrimarySkillType.MINING, mining);
@@ -1061,6 +1074,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
playerStatHash.put(PrimarySkillType.TAMING, taming);
playerStatHash.put(PrimarySkillType.FISHING, fishing);
playerStatHash.put(PrimarySkillType.ALCHEMY, alchemy);
playerStatHash.put(PrimarySkillType.CROSSBOWS, crossbows);
playerStatHash.put(PrimarySkillType.TRIDENTS, tridents);
return LeaderboardStatus.UPDATED;
}
@@ -1091,8 +1106,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public @Nullable List<FlatFileDataFlag> checkFileHealthAndStructure() {
ArrayList<FlatFileDataFlag> flagsFound = null;
logger.info("(" + usersFile.getPath() + ") Validating database file..");
FlatFileDataProcessor dataProcessor = null;
LogUtils.debug(logger, "(" + usersFile.getPath() + ") Validating database file..");
FlatFileDataProcessor dataProcessor;
if (usersFile.exists()) {
BufferedReader bufferedReader = null;
@@ -1124,9 +1139,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
//Only update the file if needed
if(dataProcessor.getFlatFileDataFlags().size() > 0) {
if(!dataProcessor.getFlatFileDataFlags().isEmpty()) {
flagsFound = new ArrayList<>(dataProcessor.getFlatFileDataFlags());
logger.info("Saving the updated and or repaired FlatFile Database...");
logger.info("Updating FlatFile Database...");
fileWriter = new FileWriter(usersFilePath);
//Write data to file
if(dbCommentDate != null)
@@ -1142,7 +1157,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
}
if(flagsFound == null || flagsFound.size() == 0) {
if(flagsFound == null || flagsFound.isEmpty()) {
return null;
} else {
return flagsFound;
@@ -1222,6 +1237,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.ACROBATICS, EXP_ACROBATICS, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.FISHING, EXP_FISHING, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.ALCHEMY, EXP_ALCHEMY, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.CROSSBOWS, EXP_CROSSBOWS, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.TRIDENTS, EXP_TRIDENTS, username);
// Taming - Unused
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SUPER_BREAKER, COOLDOWN_SUPER_BREAKER, username);
@@ -1230,11 +1247,13 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.BERSERK, COOLDOWN_BERSERK, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.GREEN_TERRA, COOLDOWN_GREEN_TERRA, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.GIGA_DRILL_BREAKER, COOLDOWN_GIGA_DRILL_BREAKER, username);
// Archery - Unused
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.EXPLOSIVE_SHOT, COOLDOWN_ARCHERY, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SERRATED_STRIKES, COOLDOWN_SERRATED_STRIKES, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SKULL_SPLITTER, COOLDOWN_SKULL_SPLITTER, username);
// Acrobatics - Unused
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.BLAST_MINING, COOLDOWN_BLAST_MINING, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SUPER_SHOTGUN, COOLDOWN_SUPER_SHOTGUN, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.TRIDENTS_SUPER_ABILITY, COOLDOWN_TRIDENTS, username);
UUID uuid;
try {
@@ -1267,12 +1286,15 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
return new PlayerProfile(username, uuid, skills, skillsXp, skillsDATS, scoreboardTipsShown, uniquePlayerDataMap, lastLogin);
}
private void tryLoadSkillCooldownFromRawData(@NotNull Map<SuperAbilityType, Integer> cooldownMap, @NotNull String[] character, @NotNull SuperAbilityType superAbilityType, int cooldownSuperBreaker, @NotNull String userName) {
private void tryLoadSkillCooldownFromRawData(@NotNull Map<SuperAbilityType, Integer> cooldownMap, @NotNull String[] splitData, @NotNull SuperAbilityType superAbilityType, int index, @NotNull String userName) {
try {
cooldownMap.put(superAbilityType, Integer.valueOf(character[cooldownSuperBreaker]));
cooldownMap.put(superAbilityType, Integer.valueOf(splitData[index]));
} catch (IndexOutOfBoundsException e) {
// TODO: Add debug message
// set to 0 when data not found
cooldownMap.put(superAbilityType, 0);
} catch (NumberFormatException e) {
logger.severe("Data corruption when trying to load the value for skill "+superAbilityType+" for player named " + userName+ " setting value to zero");
e.printStackTrace();
throw new NumberFormatException("Data corruption when trying to load the cooldown for skill "+superAbilityType+" for player named " + userName);
}
}
@@ -1291,6 +1313,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
try {
int valueFromString = Integer.parseInt(character[index]);
skillMap.put(primarySkillType, valueFromString);
} catch (ArrayIndexOutOfBoundsException e ) {
// TODO: Add debug message
// set to 0 when data not found
skillMap.put(primarySkillType, 0);
} catch (NumberFormatException e) {
skillMap.put(primarySkillType, 0);
logger.severe("Data corruption when trying to load the value for skill "+primarySkillType+" for player named " + userName+ " setting value to zero");
@@ -1315,6 +1341,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.AXES, SKILLS_AXES, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.FISHING, SKILLS_FISHING, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ALCHEMY, SKILLS_ALCHEMY, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.CROSSBOWS, SKILLS_CROSSBOWS, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.TRIDENTS, SKILLS_TRIDENTS, username);
return skills;
}

View File

@@ -11,19 +11,20 @@ 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;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.*;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
public final class SQLDatabaseManager implements DatabaseManager {
private static final String ALL_QUERY_VERSION = "total";
@@ -32,6 +33,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
public static final String USER_VARCHAR = "VARCHAR(40)";
public static final int CHILD_SKILLS_SIZE = 2;
public static final String LEGACY_DRIVER_PATH = "com.mysql.jdbc.Driver";
public static final int MAGIC_NUMBER = 44;
private final String tablePrefix = mcMMO.p.getGeneralConfig().getMySQLTablePrefix();
private final Map<UUID, Integer> cachedUserIDs = new HashMap<>();
@@ -45,23 +47,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
private final ReentrantLock massUpdateLock = new ReentrantLock();
private final String CHARSET_SQL = "utf8mb4"; //This is compliant with UTF-8 while "utf8" is not, confusing but this is how it is.
private String driverPath = "com.mysql.cj.jdbc.Driver"; //modern driver
private final Logger logger;
private final boolean h2;
protected SQLDatabaseManager() {
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
SQLDatabaseManager(Logger logger, String driverPath) {
this(logger, driverPath, false);
}
if(!mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 17, 0) //Temporary hack for SQL and 1.17 support
&& mcMMO.p.getGeneralConfig().getMySQLSSL())
connectionString +=
"?verifyServerCertificate=false"+
"&useSSL=true"+
"&requireSSL=true";
else
connectionString+=
"?useSSL=false";
SQLDatabaseManager(Logger logger, String driverPath, boolean h2) {
this.logger = logger;
this.h2 = h2;
String connectionString = getConnectionString(h2);
if(mcMMO.p.getGeneralConfig().getMySQLPublicKeyRetrieval()) {
if(!h2 && mcMMO.p.getGeneralConfig().getMySQLPublicKeyRetrieval()) {
connectionString+=
"&allowPublicKeyRetrieval=true";
}
@@ -76,7 +74,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} catch (ClassNotFoundException ex) {
e.printStackTrace();
ex.printStackTrace();
mcMMO.p.getLogger().severe("Neither driver found");
logger.severe("Neither driver found");
return;
}
//throw e; // aborts onEnable() Riking if you want to do this, fully implement it.
@@ -133,9 +131,31 @@ public final class SQLDatabaseManager implements DatabaseManager {
checkStructure();
}
@NotNull
private static String getConnectionString(boolean h2) {
if (h2) {
return "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL";
}
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
if(!mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 17, 0) //Temporary hack for SQL and 1.17 support
&& mcMMO.p.getGeneralConfig().getMySQLSSL())
connectionString +=
"?verifyServerCertificate=false"+
"&useSSL=true"+
"&requireSSL=true";
else
connectionString+=
"?useSSL=false";
return connectionString;
}
// TODO: unit tests
public int purgePowerlessUsers() {
massUpdateLock.lock();
mcMMO.p.getLogger().info("Purging powerless users...");
logger.info("Purging powerless users...");
Connection connection = null;
Statement statement = null;
@@ -149,7 +169,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "taming = 0 AND mining = 0 AND woodcutting = 0 AND repair = 0 "
+ "AND unarmed = 0 AND herbalism = 0 AND excavation = 0 AND "
+ "archery = 0 AND swords = 0 AND axes = 0 AND acrobatics = 0 "
+ "AND fishing = 0 AND alchemy = 0;");
+ "AND fishing = 0 AND alchemy = 0 AND crossbows = 0 AND tridents = 0;");
statement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "experience`.`user_id` = `s`.`user_id`)");
statement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "huds`.`user_id` = `s`.`user_id`)");
@@ -165,13 +185,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
massUpdateLock.unlock();
}
mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
logger.info("Purged " + purged + " users from the database.");
return purged;
}
public void purgeOldUsers() {
massUpdateLock.lock();
mcMMO.p.getLogger().info("Purging inactive users older than " + (mcMMO.p.getPurgeTime() / 2630000000L) + " months...");
logger.info("Purging inactive users older than " + (mcMMO.p.getPurgeTime() / 2630000000L) + " months...");
Connection connection = null;
Statement statement = null;
@@ -196,7 +216,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
massUpdateLock.unlock();
}
mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
logger.info("Purged " + purged + " users from the database.");
}
public boolean removeUser(String playerName, UUID uuid) {
@@ -212,7 +232,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
"WHERE u.user = ?");
"WHERE u.`user` = ?");
statement.setString(1, playerName);
@@ -253,7 +273,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (id == -1) {
id = newUser(connection, profile.getPlayerName(), profile.getUniqueId());
if (id == -1) {
mcMMO.p.getLogger().severe("Failed to create new account for " + profile.getPlayerName());
logger.severe("Failed to create new account for " + profile.getPlayerName());
return false;
}
}
@@ -263,7 +283,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
success &= (statement.executeUpdate() != 0);
statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update last login for " + profile.getPlayerName());
logger.severe("Failed to update last login for " + profile.getPlayerName());
return false;
}
@@ -271,7 +291,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
+ ", fishing = ?, alchemy = ?, total = ? WHERE user_id = ?");
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ?, total = ? WHERE user_id = ?");
statement.setInt(1, profile.getSkillLevel(PrimarySkillType.TAMING));
statement.setInt(2, profile.getSkillLevel(PrimarySkillType.MINING));
statement.setInt(3, profile.getSkillLevel(PrimarySkillType.REPAIR));
@@ -285,15 +305,17 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(11, profile.getSkillLevel(PrimarySkillType.ACROBATICS));
statement.setInt(12, profile.getSkillLevel(PrimarySkillType.FISHING));
statement.setInt(13, profile.getSkillLevel(PrimarySkillType.ALCHEMY));
statement.setInt(14, profile.getSkillLevel(PrimarySkillType.CROSSBOWS));
statement.setInt(15, profile.getSkillLevel(PrimarySkillType.TRIDENTS));
int total = 0;
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS)
total += profile.getSkillLevel(primarySkillType);
statement.setInt(14, total);
statement.setInt(15, id);
statement.setInt(16, total);
statement.setInt(17, id);
success &= (statement.executeUpdate() != 0);
statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update skills for " + profile.getPlayerName());
logger.severe("Failed to update skills for " + profile.getPlayerName());
return false;
}
@@ -301,7 +323,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
+ ", fishing = ?, alchemy = ? WHERE user_id = ?");
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ? WHERE user_id = ?");
statement.setInt(1, profile.getSkillXpLevel(PrimarySkillType.TAMING));
statement.setInt(2, profile.getSkillXpLevel(PrimarySkillType.MINING));
statement.setInt(3, profile.getSkillXpLevel(PrimarySkillType.REPAIR));
@@ -315,18 +337,20 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(11, profile.getSkillXpLevel(PrimarySkillType.ACROBATICS));
statement.setInt(12, profile.getSkillXpLevel(PrimarySkillType.FISHING));
statement.setInt(13, profile.getSkillXpLevel(PrimarySkillType.ALCHEMY));
statement.setInt(14, id);
statement.setInt(14, profile.getSkillXpLevel(PrimarySkillType.CROSSBOWS));
statement.setInt(15, profile.getSkillXpLevel(PrimarySkillType.TRIDENTS));
statement.setInt(16, id);
success &= (statement.executeUpdate() != 0);
statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update experience for " + profile.getPlayerName());
logger.severe("Failed to update experience for " + profile.getPlayerName());
return false;
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?"
+ ", herbalism = ?, excavation = ?, swords = ?"
+ ", axes = ?, blast_mining = ?, chimaera_wing = ? WHERE user_id = ?");
+ ", axes = ?, blast_mining = ?, chimaera_wing = ?, crossbows = ?, tridents = ? WHERE user_id = ?");
statement.setLong(1, profile.getAbilityDATS(SuperAbilityType.SUPER_BREAKER));
statement.setLong(2, profile.getAbilityDATS(SuperAbilityType.TREE_FELLER));
statement.setLong(3, profile.getAbilityDATS(SuperAbilityType.BERSERK));
@@ -336,11 +360,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setLong(7, profile.getAbilityDATS(SuperAbilityType.SKULL_SPLITTER));
statement.setLong(8, profile.getAbilityDATS(SuperAbilityType.BLAST_MINING));
statement.setLong(9, profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS));
statement.setInt(10, id);
statement.setLong(10, profile.getAbilityDATS(SuperAbilityType.SUPER_SHOTGUN));
statement.setLong(11, profile.getAbilityDATS(SuperAbilityType.TRIDENTS_SUPER_ABILITY));
statement.setInt(12, id);
success = (statement.executeUpdate() != 0);
statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName());
logger.severe("Failed to update cooldowns for " + profile.getPlayerName());
return false;
}
@@ -351,7 +377,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
success = (statement.executeUpdate() != 0);
statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName());
logger.severe("Failed to update hud settings for " + profile.getPlayerName());
return false;
}
}
@@ -371,11 +397,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
//Fix for a plugin that people are using that is throwing SQL errors
if(skill != null && SkillTools.isChildSkill(skill)) {
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
logger.severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
}
String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(Locale.ENGLISH);
ResultSet resultSet = null;
PreparedStatement statement = null;
@@ -383,7 +408,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("SELECT " + query + ", user FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
statement = connection.prepareStatement("SELECT " + query + ", `user` FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT `user` = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, `user` LIMIT ?, ?");
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
statement.setInt(2, statsPerPage);
resultSet = statement.executeQuery();
@@ -424,7 +449,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Get count of all users with higher skill level than player
String sql = "SELECT COUNT(*) AS 'rank' FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
"WHERE user = ?)";
"WHERE `user` = ?)";
statement = connection.prepareStatement(sql);
statement.setString(1, playerName);
@@ -437,7 +462,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Ties are settled by alphabetical order
sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
"WHERE user = '" + playerName + "') ORDER BY user";
"WHERE `user` = '" + playerName + "') ORDER BY user";
resultSet.close();
statement.close();
@@ -460,7 +485,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"WHERE " + ALL_QUERY_VERSION + " > 0 " +
"AND " + ALL_QUERY_VERSION + " > " +
"(SELECT " + ALL_QUERY_VERSION + " " +
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?)";
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE `user` = ?)";
statement = connection.prepareStatement(sql);
statement.setString(1, playerName);
@@ -478,7 +503,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"WHERE " + ALL_QUERY_VERSION + " > 0 " +
"AND " + ALL_QUERY_VERSION + " = " +
"(SELECT " + ALL_QUERY_VERSION + " " +
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?) ORDER BY user";
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE `user` = ?) ORDER BY user";
statement = connection.prepareStatement(sql);
statement.setString(1, playerName);
@@ -546,21 +571,26 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` "
+ "SET user = ? "
+ "WHERE user = ?");
+ "SET `user` = ? "
+ "WHERE `user` = ?");
statement.setString(1, "_INVALID_OLD_USERNAME_");
statement.setString(2, playerName);
statement.executeUpdate();
statement.close();
statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "users (user, uuid, lastlogin) VALUES (?, ?, UNIX_TIMESTAMP())", Statement.RETURN_GENERATED_KEYS);
long currentTimeMillis = System.currentTimeMillis();
String sql = "INSERT INTO " + tablePrefix + "users (`user`, uuid, lastlogin) VALUES (?, ?, ?)";
statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
statement.setString(1, playerName);
statement.setString(2, uuid != null ? uuid.toString() : null);
statement.setLong(3, currentTimeMillis);
statement.executeUpdate();
resultSet = statement.getGeneratedKeys();
if (!resultSet.next()) {
mcMMO.p.getLogger().severe("Unable to create new user account in DB");
logger.severe("Unable to create new user account in DB");
return -1;
}
@@ -600,7 +630,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
return loadPlayerFromDB(uuid, null);
}
private PlayerProfile loadPlayerFromDB(@Nullable UUID uuid, @Nullable String playerName) throws RuntimeException {
if(uuid == null && playerName == null) {
throw new RuntimeException("Error looking up player, both UUID and playerName are null and one must not be.");
@@ -622,17 +651,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
writeMissingRows(connection, id);
statement = connection.prepareStatement(
"SELECT "
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, "
+ "h.mobhealthbar, h.scoreboardtips, u.uuid, u.user "
"SELECT " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, s.crossbows, s.tridents, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, e.crossbows, e.tridents, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, c.crossbows, c.tridents, " +
"h.mobhealthbar, h.scoreboardtips, u.uuid, u.`user` "
+ "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
+ "WHERE u.id = ?");
+ "WHERE u.id = ?"
);
statement.setInt(1, id);
resultSet = statement.executeQuery();
@@ -640,7 +670,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (resultSet.next()) {
try {
PlayerProfile profile = loadFromResult(playerName, resultSet);
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
String name = resultSet.getString(MAGIC_NUMBER); // TODO: Magic Number, make sure it stays updated
resultSet.close();
statement.close();
@@ -650,15 +680,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
&& uuid != null) {
statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` "
+ "SET user = ? "
+ "WHERE user = ?");
+ "SET `user` = ? "
+ "WHERE `user` = ?");
statement.setString(1, "_INVALID_OLD_USERNAME_");
statement.setString(2, name);
statement.executeUpdate();
statement.close();
statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` "
+ "SET user = ?, uuid = ? "
+ "SET `user` = ?, uuid = ? "
+ "WHERE id = ?");
statement.setString(1, playerName);
statement.setString(2, uuid.toString());
@@ -706,7 +736,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
+ "WHERE u.user = ?");
+ "WHERE u.`user` = ?");
List<String> usernames = getStoredUsers();
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
@@ -745,7 +775,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` SET "
+ " uuid = ? WHERE user = ?");
+ " uuid = ? WHERE `user` = ?");
statement.setString(1, uuid.toString());
statement.setString(2, userName);
statement.execute();
@@ -769,7 +799,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?");
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE `user` = ?");
for (Map.Entry<String, UUID> entry : fetchedUUIDs.entrySet()) {
statement.setString(1, entry.getValue().toString());
@@ -811,7 +841,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT user FROM " + tablePrefix + "users");
resultSet = statement.executeQuery("SELECT `user` FROM " + tablePrefix + "users");
while (resultSet.next()) {
users.add(resultSet.getString("user"));
}
@@ -832,7 +862,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Checks that the database structure is present and correct
*/
private void checkStructure() {
PreparedStatement statement = null;
Statement createStatement = null;
ResultSet resultSet = null;
@@ -840,27 +869,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("SELECT table_name FROM INFORMATION_SCHEMA.TABLES"
+ " WHERE table_schema = ?"
+ " AND table_name = ?");
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "users");
String schemaQuery = this.h2 ? "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name = ?"
: "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = ? AND table_name = ?";
statement = connection.prepareStatement(schemaQuery);
setStatementQuery(statement, "users");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
createStatement = connection.createStatement();
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "`user` varchar(40) NOT NULL,"
+ "`uuid` varchar(36) NULL DEFAULT NULL,"
+ "`lastlogin` int(32) unsigned NOT NULL,"
+ "PRIMARY KEY (`id`),"
+ "INDEX(`user`(20) ASC),"
+ "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=" + CHARSET_SQL + " AUTO_INCREMENT=1;");
String sql = "CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (" +
"`id` int AUTO_INCREMENT," +
"`user` varchar(40) NOT NULL," +
"`uuid` varchar(36)," +
"`lastlogin` bigint NOT NULL," +
"PRIMARY KEY (`id`)," +
"INDEX `user_index`(`user`)," +
"UNIQUE(`uuid`))";
createStatement.executeUpdate(sql);
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "huds");
setStatementQuery(statement, "huds");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
createStatement = connection.createStatement();
@@ -873,8 +905,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "cooldowns");
setStatementQuery(statement, "cooldowns");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
createStatement = connection.createStatement();
@@ -893,13 +924,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`chimaera_wing` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`crossbows` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`tridents` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "skills");
setStatementQuery(statement, "skills");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
String startingLevel = "'" + mcMMO.p.getAdvancedConfig().getStartingLevel() + "'";
@@ -920,14 +952,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`fishing` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`tridents` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`total` int(10) unsigned NOT NULL DEFAULT "+totalLevel+","
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
tryClose(createStatement);
}
tryClose(resultSet);
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "experience");
setStatementQuery(statement, "experience");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
createStatement = connection.createStatement();
@@ -946,6 +979,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`tridents` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
tryClose(createStatement);
@@ -968,7 +1003,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
mcMMO.p.getLogger().info("Killing orphans");
// TODO: refactor
LogUtils.debug(logger, "Killing orphans");
createStatement = connection.createStatement();
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "experience`.`user_id` = `u`.`id`)");
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "huds`.`user_id` = `u`.`id`)");
@@ -985,21 +1021,53 @@ public final class SQLDatabaseManager implements DatabaseManager {
tryClose(connection);
}
String skills = "skills";
String crossbows = "crossbows";
String tridents = "tridents";
String experience = "experience";
String cooldowns = "cooldowns";
updateStructure(skills, crossbows, String.valueOf(32));
updateStructure(skills, tridents, String.valueOf(32));
updateStructure(experience, crossbows, String.valueOf(10));
updateStructure(experience, tridents, String.valueOf(10));
updateStructure(cooldowns, crossbows, String.valueOf(10));
updateStructure(cooldowns, tridents, String.valueOf(10));
}
private Connection getConnection(PoolIdentifier identifier) throws SQLException {
Connection connection = null;
switch (identifier) {
case LOAD:
connection = loadPool.getConnection();
break;
case MISC:
connection = miscPool.getConnection();
break;
case SAVE:
connection = savePool.getConnection();
break;
private void updateStructure(String tableName, String columnName, String columnSize) {
try (Connection connection = getConnection(PoolIdentifier.MISC);
Statement createStatement = connection.createStatement()) {
String startingLevel = "'" + mcMMO.p.getAdvancedConfig().getStartingLevel() + "'";
createStatement.executeUpdate("ALTER TABLE `" + tablePrefix + tableName + "` "
+ "ADD COLUMN IF NOT EXISTS `" + columnName + "` int(" + columnSize + ") unsigned NOT NULL DEFAULT " + startingLevel);
} catch (SQLException e) {
e.printStackTrace(); // Consider more robust logging
throw new RuntimeException(e);
}
}
private void setStatementQuery(PreparedStatement statement, String tableName) throws SQLException {
if (!this.h2) {
// Set schema name for MySQL
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
statement.setString(2, tablePrefix + tableName);
} else {
// For H2, the schema parameter is not needed
statement.setString(1, tablePrefix + tableName);
}
}
Connection getConnection(PoolIdentifier identifier) throws SQLException {
Connection connection = switch (identifier) {
case LOAD -> loadPool.getConnection();
case MISC -> miscPool.getConnection();
case SAVE -> savePool.getConnection();
};
if (connection == null) {
throw new RuntimeException("getConnection() for " + identifier.name().toLowerCase(Locale.ENGLISH) + " pool timed out. Increase max connections settings.");
}
@@ -1012,8 +1080,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
* @param upgrade Upgrade to attempt to apply
*/
private void checkDatabaseStructure(Connection connection, UpgradeType upgrade) {
// TODO: Rewrite / Refactor
if (!mcMMO.getUpgradeManager().shouldUpgrade(upgrade)) {
mcMMO.p.debug("Skipping " + upgrade.name() + " upgrade (unneeded)");
LogUtils.debug(logger, "Skipping " + upgrade.name() + " upgrade (unneeded)");
return;
}
@@ -1122,8 +1191,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;
@@ -1132,9 +1201,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query
// changes (a new skill is added)
final int OFFSET_XP = 13;
final int OFFSET_DATS = 26;
final int OFFSET_OTHER = 39;
final int OFFSET_XP = 15;
final int OFFSET_DATS = 28;
final int OFFSET_OTHER = 41;
skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1));
skills.put(PrimarySkillType.MINING, result.getInt(OFFSET_SKILLS + 2));
@@ -1149,6 +1218,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
skills.put(PrimarySkillType.ACROBATICS, result.getInt(OFFSET_SKILLS + 11));
skills.put(PrimarySkillType.FISHING, result.getInt(OFFSET_SKILLS + 12));
skills.put(PrimarySkillType.ALCHEMY, result.getInt(OFFSET_SKILLS + 13));
skills.put(PrimarySkillType.CROSSBOWS, result.getInt(OFFSET_SKILLS + 14));
skills.put(PrimarySkillType.TRIDENTS, result.getInt(OFFSET_SKILLS + 15));
skillsXp.put(PrimarySkillType.TAMING, result.getFloat(OFFSET_XP + 1));
skillsXp.put(PrimarySkillType.MINING, result.getFloat(OFFSET_XP + 2));
@@ -1163,6 +1234,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
skillsXp.put(PrimarySkillType.ACROBATICS, result.getFloat(OFFSET_XP + 11));
skillsXp.put(PrimarySkillType.FISHING, result.getFloat(OFFSET_XP + 12));
skillsXp.put(PrimarySkillType.ALCHEMY, result.getFloat(OFFSET_XP + 13));
skillsXp.put(PrimarySkillType.CROSSBOWS, result.getFloat(OFFSET_XP + 14));
skillsXp.put(PrimarySkillType.TRIDENTS, result.getFloat(OFFSET_XP + 15));
// Taming - Unused - result.getInt(OFFSET_DATS + 1)
skillsDATS.put(SuperAbilityType.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2));
@@ -1177,6 +1250,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
skillsDATS.put(SuperAbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
uniqueData.put(UniqueDataType.CHIMAERA_WING_DATS, result.getInt(OFFSET_DATS + 13));
skillsDATS.put(SuperAbilityType.SUPER_SHOTGUN, result.getInt(OFFSET_DATS + 14));
skillsDATS.put(SuperAbilityType.TRIDENTS_SUPER_ABILITY, result.getInt(OFFSET_DATS + 15));
try {
scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);
@@ -1196,17 +1271,21 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
private void printErrors(SQLException ex) {
if (debug) {
ex.printStackTrace();
}
ex.printStackTrace();
StackTraceElement element = ex.getStackTrace()[0];
mcMMO.p.getLogger().severe("Location: " + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber());
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
// logger.severe("SQLException: " + ex.getMessage());
logger.severe("SQLState: " + ex.getSQLState());
logger.severe("VendorError: " + ex.getErrorCode());
// Handling SQLException chain
SQLException nextException = ex.getNextException();
while (nextException != null) {
logger.severe("Caused by: " + nextException.getMessage());
nextException = nextException.getNextException();
}
}
public DatabaseType getDatabaseType() {
return DatabaseType.SQL;
}
@@ -1222,7 +1301,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return;
}
resultSet.close();
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables to drop name uniqueness...");
logger.info("Updating mcMMO MySQL tables to drop name uniqueness...");
statement.execute("ALTER TABLE `" + tablePrefix + "users` "
+ "DROP INDEX `user`,"
+ "ADD INDEX `user` (`user`(20) ASC)");
@@ -1240,7 +1319,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_ALCHEMY);
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Alchemy...");
logger.info("Updating mcMMO MySQL tables for Alchemy...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `alchemy` int(10) NOT NULL DEFAULT '0'");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `alchemy` int(10) NOT NULL DEFAULT '0'");
}
@@ -1252,7 +1331,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_BLAST_MINING_COOLDOWN);
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
logger.info("Updating mcMMO MySQL tables for Blast Mining...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0'");
}
}
@@ -1263,7 +1342,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UNIQUE_PLAYER_DATA);
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Chimaera Wing...");
logger.info("Updating mcMMO MySQL tables for Chimaera Wing...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `chimaera_wing` int(32) NOT NULL DEFAULT '0'");
}
}
@@ -1274,7 +1353,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_FISHING);
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
logger.info("Updating mcMMO MySQL tables for Fishing...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0'");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0'");
}
@@ -1286,7 +1365,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_MOB_HEALTHBARS);
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars...");
logger.info("Updating mcMMO MySQL tables for mob healthbars...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.p.getGeneralConfig().getMobHealthbarDefault() + "'");
}
}
@@ -1297,7 +1376,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_SCOREBOARD_TIPS);
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for scoreboard tips...");
logger.info("Updating mcMMO MySQL tables for scoreboard tips...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `scoreboardtips` int(10) NOT NULL DEFAULT '0' ;");
}
}
@@ -1310,7 +1389,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
resultSet.last();
if (resultSet.getRow() != SkillTools.NON_CHILD_SKILLS.size()) {
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
logger.info("Indexing tables, this may take a while on larger databases");
for (PrimarySkillType skill : SkillTools.NON_CHILD_SKILLS) {
String skill_name = skill.name().toLowerCase(Locale.ENGLISH);
@@ -1351,11 +1430,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
if (!column_exists) {
mcMMO.p.getLogger().info("Adding UUIDs to mcMMO MySQL user table...");
logger.info("Adding UUIDs to mcMMO MySQL user table...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD `uuid` varchar(36) NULL DEFAULT NULL");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD UNIQUE INDEX `uuid` (`uuid`) USING BTREE");
new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge
mcMMO.p.getFoliaLib().getImpl().runLaterAsync(new GetUUIDUpdatesRequired(), 100); // wait until after first purge
}
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
@@ -1368,7 +1447,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private class GetUUIDUpdatesRequired extends BukkitRunnable {
private class GetUUIDUpdatesRequired implements Runnable {
public void run() {
massUpdateLock.lock();
List<String> names = new ArrayList<>();
@@ -1420,7 +1499,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
if (column_exists) {
mcMMO.p.getLogger().info("Removing party name from users table...");
logger.info("Removing party name from users table...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party`");
}
@@ -1454,7 +1533,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
if (!column_exists) {
mcMMO.p.getLogger().info("Adding skill total column to skills table...");
logger.info("Adding skill total column to skills table...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD COLUMN `total` int NOT NULL DEFAULT '0'");
statement.executeUpdate("UPDATE `" + tablePrefix + "skills` SET `total` = (taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy)");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_total` (`total`) USING BTREE");
@@ -1490,7 +1569,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
if (column_exists) {
mcMMO.p.getLogger().info("Removing Spout HUD type from huds table...");
logger.info("Removing Spout HUD type from huds table...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype`");
}
@@ -1515,7 +1594,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND user = ?)");
statement = connection.prepareStatement("SELECT id, `user` FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND `user` = ?)");
statement.setString(1, uuid.toString());
statement.setString(2, playerName);
resultSet = statement.executeQuery();
@@ -1544,7 +1623,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE user = ?");
statement = connection.prepareStatement("SELECT id, `user` FROM " + tablePrefix + "users WHERE `user` = ?");
statement.setString(1, playerName);
resultSet = statement.executeQuery();
@@ -1577,7 +1656,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
@Override
public void onDisable() {
mcMMO.p.debug("Releasing connection pool resource...");
LogUtils.debug(logger, "Releasing connection pool resource...");
miscPool.close();
loadPool.close();
savePool.close();
@@ -1619,19 +1698,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
*/
//Alter users table
mcMMO.p.getLogger().info("SQL Converting tables from latin1 to utf8mb4");
logger.info("SQL Converting tables from latin1 to utf8mb4");
//Update "user" column
try {
mcMMO.p.getLogger().info("Updating user column to new encoding");
logger.info("Updating user column to new encoding");
statement.executeUpdate(getUpdateUserInUsersTableSQLQuery());
//Update "uuid" column
mcMMO.p.getLogger().info("Updating user column to new encoding");
logger.info("Updating user column to new encoding");
statement.executeUpdate(getUpdateUUIDInUsersTableSQLQuery());
//Update "mobhealthbar" column
mcMMO.p.getLogger().info("Updating mobhealthbar column to new encoding");
logger.info("Updating mobhealthbar column to new encoding");
statement.executeUpdate(getUpdateMobHealthBarInHudsTableSQLQuery());
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.SQL_CHARSET_UTF8MB4);
@@ -1645,7 +1724,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
private String getUpdateUserInUsersTableSQLQuery() {
return "ALTER TABLE\n" +
" " + tablePrefix + "users\n" +
" CHANGE user user\n" +
" CHANGE `user` user\n" +
" " + USER_VARCHAR + "\n" +
" CHARACTER SET utf8mb4\n" +
" COLLATE utf8mb4_unicode_ci;";
@@ -1670,4 +1749,28 @@ public final class SQLDatabaseManager implements DatabaseManager {
" CHARACTER SET utf8mb4\n" +
" COLLATE utf8mb4_unicode_ci;";
}
public void printAllTablesWithColumns(Connection connection) {
try {
DatabaseMetaData metaData = connection.getMetaData();
String[] types = {"TABLE"};
ResultSet tables = metaData.getTables(null, null, "%", types);
while (tables.next()) {
String tableName = tables.getString("TABLE_NAME");
System.out.println("Table: " + tableName);
ResultSet columns = metaData.getColumns(null, null, tableName, "%");
while (columns.next()) {
String columnName = columns.getString("COLUMN_NAME");
String columnType = columns.getString("TYPE_NAME");
System.out.println(" Column: " + columnName + " Type: " + columnType);
}
columns.close();
}
tables.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

View File

@@ -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();
@@ -80,6 +79,8 @@ public class FlatFileDataUtil {
case SKILLS_TAMING:
case SKILLS_FISHING:
case SKILLS_ALCHEMY:
case SKILLS_CROSSBOWS:
case SKILLS_TRIDENTS:
return String.valueOf(startingLevel);
case OVERHAUL_LAST_LOGIN:
return String.valueOf(-1L);
@@ -91,6 +92,9 @@ public class FlatFileDataUtil {
case COOLDOWN_SKULL_SPLITTER:
case COOLDOWN_SUPER_BREAKER:
case COOLDOWN_BLAST_MINING:
case COOLDOWN_SUPER_SHOTGUN:
case COOLDOWN_TRIDENTS:
case COOLDOWN_ARCHERY:
case SCOREBOARD_TIPS:
case COOLDOWN_CHIMAERA_WING:
case EXP_MINING:
@@ -106,6 +110,8 @@ public class FlatFileDataUtil {
case EXP_TAMING:
case EXP_FISHING:
case EXP_ALCHEMY:
case EXP_CROSSBOWS:
case EXP_TRIDENTS:
return "0";
case UUID_INDEX:
throw new IndexOutOfBoundsException(); //TODO: Add UUID recovery? Might not even be worth it.

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
@@ -253,7 +252,7 @@ public class Party {
}
}
} else {
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
mcMMO.p.getPartyManager().informPartyMembersLevelUp(this, levelsGained, getLevel());
}
}
@@ -403,12 +402,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;
}

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