mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-20 02:33:15 +01:00
Compare commits
133 Commits
tridentsxb
...
config-val
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b6a4c1e5b | ||
|
|
0ccd89fad4 | ||
|
|
16e90da8fd | ||
|
|
86e7bfbf89 | ||
|
|
8f0fb76847 | ||
|
|
3be15d3f65 | ||
|
|
74ced18bd0 | ||
|
|
2e0a371ed8 | ||
|
|
68ffe31246 | ||
|
|
405de477d3 | ||
|
|
db0ae36fa7 | ||
|
|
5d2028b5dc | ||
|
|
3e645a022d | ||
|
|
c21a040ddb | ||
|
|
dd4a5a6b9a | ||
|
|
d5ce8fc6ff | ||
|
|
829aaea5d4 | ||
|
|
c92ae16c7f | ||
|
|
40160498ca | ||
|
|
9d08d88f2a | ||
|
|
2ca3544741 | ||
|
|
ef714f98c9 | ||
|
|
dd550feb65 | ||
|
|
ddc9a69f4b | ||
|
|
61388f46f1 | ||
|
|
341dc45202 | ||
|
|
13f7482b39 | ||
|
|
a78dcffde7 | ||
|
|
3671d0b565 | ||
|
|
1b11fd2369 | ||
|
|
c36ff85cbf | ||
|
|
77cefbdfab | ||
|
|
fbe0cd1471 | ||
|
|
728ba512c3 | ||
|
|
10470dde13 | ||
|
|
11245e87ef | ||
|
|
b88d752f61 | ||
|
|
09ce259288 | ||
|
|
519d469cb2 | ||
|
|
cf67e3502a | ||
|
|
9ab4584dfe | ||
|
|
8d27e8fccf | ||
|
|
ba1f15b655 | ||
|
|
5b1a69b3f7 | ||
|
|
d185c7538c | ||
|
|
2347fc294f | ||
|
|
7aaec5b707 | ||
|
|
20a713e04d | ||
|
|
81faf93f31 | ||
|
|
19c0f6757e | ||
|
|
ec0815043e | ||
|
|
182717eacf | ||
|
|
e287ad47d1 | ||
|
|
8eee39b88b | ||
|
|
4bf2ad46ea | ||
|
|
def676d8d7 | ||
|
|
f8433cdbcc | ||
|
|
a2e10dbd0c | ||
|
|
e55ce00d62 | ||
|
|
73c465ee64 | ||
|
|
c30892a0a5 | ||
|
|
58e7323c3e | ||
|
|
7fc6577196 | ||
|
|
162c605dac | ||
|
|
280eb0ba51 | ||
|
|
8e5251ba66 | ||
|
|
1e43e34547 | ||
|
|
5575309b79 | ||
|
|
88dae5d5dd | ||
|
|
da3909c08f | ||
|
|
6cad4993ed | ||
|
|
af6e6b9545 | ||
|
|
cd937a812d | ||
|
|
264c0e2c78 | ||
|
|
b42278932e | ||
|
|
7fc7125ed3 | ||
|
|
d3f012de27 | ||
|
|
dfa16c70a7 | ||
|
|
8805a25d85 | ||
|
|
f91a2217c8 | ||
|
|
64f1ae4af6 | ||
|
|
6d9a9d165d | ||
|
|
5edc0d065d | ||
|
|
a346fc3338 | ||
|
|
dc94fedee1 | ||
|
|
93a6a73b4e | ||
|
|
2c849d9cb4 | ||
|
|
b79d452a6d | ||
|
|
fb94374e3c | ||
|
|
5255ae846d | ||
|
|
e816310da8 | ||
|
|
de6ba4fb6a | ||
|
|
e35bfe758c | ||
|
|
fffbacd239 | ||
|
|
f286af3fff | ||
|
|
7e28799f94 | ||
|
|
78dc56d263 | ||
|
|
e3dfdfc6ee | ||
|
|
4819a45be9 | ||
|
|
5e0f8a334d | ||
|
|
5f0cc2b09a | ||
|
|
6ff37c8baa | ||
|
|
f7dc72359b | ||
|
|
1ab5b82b22 | ||
|
|
28c6c90f23 | ||
|
|
9bb38e3193 | ||
|
|
551fac84a5 | ||
|
|
0bc25b263b | ||
|
|
fa9a3ae766 | ||
|
|
33df92ea3a | ||
|
|
c3d86ba6c5 | ||
|
|
b569b9456e | ||
|
|
4e6e58d9ca | ||
|
|
619eec7667 | ||
|
|
97cfb1cfc7 | ||
|
|
c28c8d164a | ||
|
|
e74e1e6829 | ||
|
|
6dbc7adf48 | ||
|
|
cbaef4a092 | ||
|
|
eb10bcbc96 | ||
|
|
2875545fa4 | ||
|
|
be595f2568 | ||
|
|
882f6197c6 | ||
|
|
0d2f370185 | ||
|
|
da1fcfe30a | ||
|
|
f983f95961 | ||
|
|
d67c561fed | ||
|
|
989f7fd51b | ||
|
|
e4b8b74987 | ||
|
|
9e7bb12dc3 | ||
|
|
95c291d630 | ||
|
|
9b4070d971 | ||
|
|
6d0fe4fb58 |
9
.github/workflows/maven.yml
vendored
9
.github/workflows/maven.yml
vendored
@@ -31,12 +31,13 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# 2. Setup Java 1.8 JDK
|
||||
- name: Java 1.8 setup
|
||||
uses: actions/setup-java@v1.4.3
|
||||
# 2. Setup Java 17 JDK (Adopt)
|
||||
- name: Java 17 setup
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-package: jdk
|
||||
java-version: 1.8
|
||||
java-version: '17'
|
||||
|
||||
# 3. Setup local Maven package cache to speed up building
|
||||
- name: Cache Maven packages
|
||||
|
||||
245
Changelog.txt
245
Changelog.txt
@@ -1,8 +1,249 @@
|
||||
Version 2.1.196
|
||||
Crossbows can now be fished up with enchantments
|
||||
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)
|
||||
|
||||
NOTES:
|
||||
There was a big rewrite in this update relating to how various types of metadata were being tracked/stored/retrieved
|
||||
If you run into issues with this version of mcMMO, please post about it on GitHub
|
||||
|
||||
Version 2.1.209
|
||||
Fixed a bug where some config files did not get trimmed completely
|
||||
|
||||
NOTES:
|
||||
This should fix the issue for everyone, let me know if you still run into trouble!
|
||||
Don't be afraid to ping me on discord
|
||||
|
||||
Version 2.1.208
|
||||
Significantly rewrote to how mcMMO loads/updates config files
|
||||
Fixed a bug where huge config files caused the server to take forever to start/shutdown
|
||||
Fixed config files duplicating comments and updated their code to use Spigot API (thanks the456gamer)
|
||||
mcMMO now repairs config files (removing duplicate comments, see notes)
|
||||
Updated lithuanian locale (thanks dexasz)
|
||||
|
||||
NOTES:
|
||||
Due to a change in Spigot mcMMO started growing config files at an alarming rate until they became so big they wouldn't load, and well before they got to that stage they slowed down loading the server
|
||||
mcMMO now uses the Spigot API in a smarter way for config files
|
||||
|
||||
Version 2.1.207
|
||||
Fixed an IndexOutOfBounds exception with our BlockTracker
|
||||
Fixed a bug where leveling up a party at level cap would spam the chat with messages
|
||||
mcMMO will no longer use enchanted repair materials (thanks JeBobs)
|
||||
Added an option to allow enchanted repair materials 'Skills.Repair.Use_Enchanted_Materials' in config.yml
|
||||
Temporarily rolling required Java version back to 16
|
||||
Added unicode (UTF-8) support to locale files (no more UTF-16 codes needed)
|
||||
Added locale key 'Scoreboard.Disabled' to en_US
|
||||
Added locale key 'Scoreboard.NotSetupYet' to en_US
|
||||
Fixed a bug where Salvage sent messages even though the event was cancelled (Thanks TheBusyBiscuit)
|
||||
|
||||
Version 2.1.206
|
||||
Fixed a memory leak involving Herbalism under specific circumstances
|
||||
Fixed a memory leak involving Rupture under specific circumstances
|
||||
Fixed a memory leak involving Dodge
|
||||
Fixed a memory leak involving Endermen and block pickups
|
||||
Fixed a memory leak from plugin conflicts when double drops get activated
|
||||
Fixed a memory leak that required a specific config.yml setup with mob health bars
|
||||
You can no longer set mob health bars to -1 in config.yml to set it to display permanently (this was problematic behavior)
|
||||
Fixed a bug preventing Action Bar messages from showing
|
||||
Fixed a bug where Alchemy XP wasn't being granted
|
||||
Lowered the default volume of level up from .75 to .3 in sounds.yml (delete sounds.yml to get this change automagically)
|
||||
Updated adventure platform dependency
|
||||
Updated to use Java 17
|
||||
|
||||
NOTES:
|
||||
mcMMO will target the newest version of MC moving forward, any backwards compatibility with prior versions of Minecraft should be considered a side effect rather than intended.
|
||||
|
||||
Version 2.1.205
|
||||
Fixed yet another exception preventing Alchemy from working (thanks NemuruYama)
|
||||
Added some code to cleanup potential memory leaks
|
||||
|
||||
NOTES:
|
||||
Sorry for the delay in this patch, I have had a terrible cold all weekend, feeling better now
|
||||
|
||||
Version 2.1.204
|
||||
Fixed IndexOutOfBounds exception (thanks gecko10000) (related to Alchemy)
|
||||
Added double smelt to copper ingot and netherite scrap (thanks Lyther)
|
||||
|
||||
Version 2.1.203
|
||||
mcMMO now requires Java 16
|
||||
mcMMO now requires the newest version of Minecraft (currently 1.17.1)
|
||||
Fixed several API breaks (mostly affected Alchemy)
|
||||
Fixed a bug relating to Shake percentages (thanks Lyther)
|
||||
Fixed hexcolors not displaying correctly in level up milestone broadcasts (thanks gecko10000)
|
||||
(API) Added deprecated constructors for PlayerProfile (thanks PikaMug)
|
||||
mcMMO has had many of its dependencies updated to newer builds
|
||||
|
||||
NOTES:
|
||||
If you want to play mcMMO on older versions, simply use 2.1.202 instead
|
||||
Keeping mcMMO backwards compatible with older versions is getting messy, and I'd rather be able to focus my attention at newer features than having to make an elaborate build process (or alternatively hacky code) to support older versions of the game
|
||||
Furthermore, it seems most people are playing 1.17.1 by a wide margin
|
||||
You may have trouble compiling the source code if your maven is not setup to run JDK16, if you get any errors when compiling this is likely the reason
|
||||
|
||||
The data from bstats went into making this decision (shoutout to Qixils for typing this up too)
|
||||
71.9% of servers are running 1.17.X
|
||||
97.9% of servers are running ≥1.16
|
||||
99.3% of servers are running ≥1.15
|
||||
|
||||
Version 2.1.202
|
||||
Fixed a bug where mcMMO didn't reward XP for Kelp
|
||||
Fixed a bug where mcMMO marked bonemealed Azalea trees as unnatural (and thus did not give XP or get affected by Tree Feller)
|
||||
Added Amethyst_Block to experience.yml for Mining
|
||||
Added Flowering Azalea Leaves to Tree Feller's white list
|
||||
Fixed a bug where mcMMO didn't appropriately flag blocks as natural in some tree growing events
|
||||
(SQL) Added more MySQL/MariaDB settings (allowPublicKeyRetrieval - thanks rosaage)
|
||||
(API) Added CREATED_PARTY and DISBANDED_PARTY to EventReason (used in some party events - thanks PikaMug )
|
||||
Party member name matching is no longer case sensitive (thanks Wariorrrr)
|
||||
Updated zh_CN locale (thanks GhostDC)
|
||||
Added some settings for over fishing (Settings are in experience.yml under Fishing_ExploitFix_Options - thanks tunagohan)
|
||||
|
||||
NOTES:
|
||||
This means tree feller will correctly traverse flowering azalea leaves during its ability
|
||||
|
||||
Version 2.1.201
|
||||
Tweaked the visual/audio effect for Rupture
|
||||
(API) TNT is set as the source in Blast Mining (1.16.1 and up)
|
||||
Fixed an exploit related to Ability Buffs remaining on tools
|
||||
Blast Mining no longer drops Budding Amethyst since its not legal to obtain this item through normal gameplay
|
||||
Added mcinspect and mmoinspect aliases to inspect command
|
||||
Portuguese translation of Woodcutting changed back to Lenhador
|
||||
Updated zh_CN (Chinese) locale, thanks GhostDC!
|
||||
Major changes to zh_TW locale, thanks gregman98
|
||||
Added '/skill keep' shortcut (for example /mining keep) thanks GriffinCodes
|
||||
Impact is now more balanced as the formula has been changed (see notes) thanks emanondev
|
||||
|
||||
NOTES:
|
||||
Impact will deal less durability damage to armors without unbreaking, and more to armors with unbreaking
|
||||
|
||||
Version 2.1.200
|
||||
Fixed a major 1.17 exploit
|
||||
Dodge will no longer trigger while blocking
|
||||
Action Bar messages can now be disabled (thanks TheBusyBiscuit)
|
||||
mcMMO is better at MC version parsing now (thanks stepech & TheBusyBiscuit)
|
||||
|
||||
Version 2.1.199
|
||||
Fixed IndexOutOfBounds error for servers running 1.17 or higher
|
||||
Fixed a bug that caused MySQL/MariaDB to malfunction for 1.17 (see notes)
|
||||
Renamed Deepslate Lapis Lazuli Ore to Deepslate Lapis Ore in experience.yml and config.yml
|
||||
Added some code to prevent mcMMO from breaking if it doesn't recognize the version of the game
|
||||
Optimized CompatibilitySupportLayer - this handles some of the logic for supporting multiple versions of the game
|
||||
Added Unit Tests for MinecraftGameVersion
|
||||
|
||||
NOTES:
|
||||
I have temporarily disabled SSL for MySQL/MariaDB for 1.17 ( proper fix coming soon )
|
||||
|
||||
Version 2.1.198
|
||||
Fixed a bug where Smelting didn't work with the new 1.17 materials
|
||||
Updated dependency Adventure to 4.8.0 (thanks TheBusyBiscuit)
|
||||
|
||||
Version 2.1.197
|
||||
This update adds compatibility for new mobs and blocks from 1.17
|
||||
This build of mcMMO should be more compatible with certain versions of ViaVersion
|
||||
Players are no longer launched from Minecarts when using a Fishing Rod (they are still dismounted) thanks lexikiq
|
||||
Updated Japanese locale (thanks ViaSnake)
|
||||
Updated Brazil Portuguese (pt_BR) locale (thanks Paulo Guilherme)
|
||||
Added Goat to experience.yml for combat and taming
|
||||
Added Axolotl to experience.yml for combat and taming
|
||||
Added Glow_Squid to experience.yml for combat and taming
|
||||
Added Glow Berries to Farmer's Diet
|
||||
Updated Super Breaker to recognize the new pick-axe appropriate blocks
|
||||
Updated Tree Feller to recognize Azalea Leaves
|
||||
|
||||
Added Rooted Dirt to experience.yml for Excavation
|
||||
Added Small Dripleaf to experience.yml for Herbalism
|
||||
Added Big Dripleaf to experience.yml for Herbalism
|
||||
Added Moss Block to experience.yml for Herbalism
|
||||
Added Cave Vines to experience.yml for Herbalism
|
||||
Added Cave Vines Plant to experience.yml for Herbalism
|
||||
Added Glow Lichen to experience.yml for Herbalism
|
||||
Added Tuff to experience.yml for Mining
|
||||
Added Calcite to experience.yml for Mining
|
||||
Added Smooth Basalt to experience.yml for Mining
|
||||
Added Block_Of_Amethyst to experience.yml for Mining
|
||||
Added Budding Amethyst to experience.yml for Mining
|
||||
Added Small_Amethyst_Bud to experience.yml for Mining
|
||||
Added Medium Amethyst Bud to experience.yml for Mining
|
||||
Added Large Amethyst Bud to experience.yml for Mining
|
||||
Added Amethyst Cluster to experience.yml for Mining
|
||||
Added Deepslate to experience.yml for Mining
|
||||
Added Cobbled Deepslate to experience.yml for Mining
|
||||
Added Copper Ore to experience.yml for Mining
|
||||
Added Deepslate Redstone Ore to experience.yml for Mining
|
||||
Added Deepslate Copper Ore to experience.yml for Mining
|
||||
Added Deepslate Coal Ore to experience.yml for Mining
|
||||
Added Deepslate Diamond Ore to experience.yml for Mining
|
||||
Added Deepslate Emerald Ore to experience.yml for Mining
|
||||
Added Deepslate Iron Ore to experience.yml for Mining
|
||||
Added Deepslate Gold Ore to experience.yml for Mining
|
||||
Added Deepslate Lapis Lazuli Ore to experience.yml for Mining
|
||||
Added Lapis Lazuli Ore to experience.yml for Mining (was missing)
|
||||
|
||||
Added Moss Block to Bonus Drops for Herbalism in config.yml
|
||||
Added Glow Berries to Bonus Drops for Herbalism in config.yml
|
||||
Added Cave Vines to Bonus Drops for Herbalism in config.yml
|
||||
Added Cave Vines Plant to Bonus Drops for Herbalism in config.yml
|
||||
Added Tuff to Bonus Drops for Mining in config.yml
|
||||
Added Amethyst Shard to Bonus Drops for Mining in config.yml
|
||||
Added Calcite to Bonus Drops for Mining in config.yml
|
||||
Added Smooth Basalt to Bonus Drops for Mining in config.yml
|
||||
Added Block_Of_Amethyst to Bonus Drops for Mining in config.yml
|
||||
Added Budding Amethyst to Bonus Drops for Mining in config.yml
|
||||
Added Small_Amethyst_Bud to Bonus Drops for Mining in config.yml
|
||||
Added Medium Amethyst Bud to Bonus Drops for Mining in config.yml
|
||||
Added Large Amethyst Bud to Bonus Drops for Mining in config.yml
|
||||
Added Amethyst Cluster to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate to Bonus Drops for Mining in config.yml
|
||||
Added Cobbled Deepslate to Bonus Drops for Mining in config.yml
|
||||
Added Raw Iron to Bonus Drops for Mining in config.yml
|
||||
Added Raw Gold to Bonus Drops for Mining in config.yml
|
||||
Added Raw Copper to Bonus Drops for Mining in config.yml
|
||||
Added Copper Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Redstone Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Copper Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Coal Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Diamond Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Emerald Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Iron Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Gold Ore to Bonus Drops for Mining in config.yml
|
||||
Added Deepslate Lapis Lazuli Ore to Bonus Drops for Mining in config.yml
|
||||
Added Lapis Lazuli Ore to Bonus Drops for Mining in config.yml (was missing)
|
||||
|
||||
Added Cobbled Deepslate to experience.yml for Smelting
|
||||
Added Raw Copper to experience.yml for Smelting
|
||||
Added Raw Iron to experience.yml for Smelting
|
||||
Added Raw Gold to experience.yml for Smelting
|
||||
Added Copper Ore to experience.yml for Smelting
|
||||
Added Deepslate Redstone Ore to experience.yml for Smelting
|
||||
Added Deepslate Copper Ore to experience.yml for Smelting
|
||||
Added Deepslate Coal Ore to experience.yml for Smelting
|
||||
Added Deepslate Diamond Ore to experience.yml for Smelting
|
||||
Added Deepslate Emerald Ore to experience.yml for Smelting
|
||||
Added Deepslate Iron Ore to experience.yml for Smelting
|
||||
Added Deepslate Gold Ore to experience.yml for Smelting
|
||||
Added Deepslate Lapis Lazuli Ore to experience.yml for Smelting
|
||||
Added Lapis Lazuli Ore to experience.yml for Smelting (was missing)
|
||||
|
||||
NOTES:
|
||||
Another patch will follow this one shortly to add more 1.17 support, I am waiting on the Spigot API to test some stuff which isn't out yet.
|
||||
You shouldn't need to edit your configs for this update, your configs should update automatically.
|
||||
Expect some patches following this update for Axolotl and other new entities, waiting on the Spigot API to become available
|
||||
If you run into any issues with ViaVersion or ViaBackwards, use the latest dev builds for each.
|
||||
|
||||
Version 2.1.196
|
||||
Removed the explosion from Rupture
|
||||
Adjusted Rupture to play its particle effect less often
|
||||
Fixed a bug where Rupture never applied to additional targets during Serrated Strikes
|
||||
Fixed a bug where players without Rupture permission could use Rupture during Serrated Strikes
|
||||
Fixed a possible null error for our SelfListener
|
||||
Added locale string 'Swords.Combat.Rupture.Note.Update.One'
|
||||
Updated locale string 'Guides.Swords.Section.1'
|
||||
Crossbows can now be fished up with enchantments
|
||||
(API) Added McMMOEntityDamageByRuptureEvent (thanks qixils)
|
||||
|
||||
NOTES:
|
||||
For now Rupture is non-lethal, I may add back a lethal component at the end of its damage
|
||||
Rupture will be in a state of change for a while as I receive feedback (give me feedback in Discord!)
|
||||
Crossbows is not in the default fishing loot list, you'd have to add it yourself.
|
||||
For Devs: McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent and uses CUSTOM type damage
|
||||
|
||||
Version 2.1.195
|
||||
Fixed a null connection error which affected some SQL users
|
||||
|
||||
129
pom.xml
129
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.196-SNAPSHOT</version>
|
||||
<version>2.1.210-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
@@ -14,6 +14,9 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
<maven.compiler.target>16</maven.compiler.target>
|
||||
<java.version>16</java.version>
|
||||
</properties>
|
||||
|
||||
<issueManagement>
|
||||
@@ -72,11 +75,21 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<version>3.0.0-M5</version>
|
||||
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<version>3.0.0-M5</version>
|
||||
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
@@ -89,11 +102,10 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>16</release>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg> <!-- used for ACF syntax stuff -->
|
||||
</compilerArgs>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<excludes>
|
||||
</excludes>
|
||||
</configuration>
|
||||
@@ -118,7 +130,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
@@ -131,7 +143,6 @@
|
||||
<include>net.kyori:adventure-text-serializer-gson</include>
|
||||
<include>net.kyori:adventure-platform-bukkit</include>
|
||||
<include>net.kyori:adventure-platform-api</include>
|
||||
<include>net.kyori:adventure-platform-common</include>
|
||||
<include>net.kyori:adventure-platform-viaversion</include>
|
||||
<include>net.kyori:adventure-platform-facet</include>
|
||||
<include>net.kyori:adventure-nbt</include>
|
||||
@@ -145,11 +156,10 @@
|
||||
<include>co.aikar:acf-bukkit</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<!-- <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>-->
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.kyori.examination</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.kyori.examination</shadedPattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.examination</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
@@ -199,6 +209,13 @@
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@@ -223,24 +240,7 @@
|
||||
<!-- ... -->
|
||||
<!-- ... -->
|
||||
</repositories>
|
||||
<!-- <dependencyManagement>-->
|
||||
<!-- <dependencies>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.junit</groupId>-->
|
||||
<!-- <artifactId>junit-bom</artifactId>-->
|
||||
<!-- <version>5.7.1</version>-->
|
||||
<!-- <type>pom</type>-->
|
||||
<!-- <scope>import</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- </dependencies>-->
|
||||
<!-- </dependencyManagement>-->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.seeseemelk</groupId>
|
||||
<artifactId>MockBukkit-v1.16</artifactId>
|
||||
<version>0.25.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-bukkit</artifactId> <!-- Don't forget to replace this -->
|
||||
@@ -250,53 +250,42 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-nbt</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-key</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-api</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-common</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-nbt</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||
<version>1.9.4</version>
|
||||
<version>1.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
@@ -307,13 +296,13 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-core</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<version>7.0.4</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- We use jetbrains instead. Excluding this -->
|
||||
@@ -336,50 +325,38 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.7.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.8.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>4.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jdbc</artifactId>
|
||||
<version>7.0.52</version>
|
||||
<version>10.0.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<version>22.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 -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -84,7 +84,7 @@ public final class AbilityAPI {
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
if(entity.isValid()) {
|
||||
if(entity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,16 @@ public class McscoreboardCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Scoreboard.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!ScoreboardManager.isPlayerBoardSetup(sender.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Scoreboard.NotSetupYet"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -15,13 +16,14 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String partyName = playerParty.getName();
|
||||
final Party playerParty = mcMMOPlayer.getParty();
|
||||
final String partyName = playerParty.getName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
@@ -31,7 +33,7 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(playerParty);
|
||||
PartyManager.disbandParty(mcMMOPlayer, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -97,11 +98,11 @@ public class McrankCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -97,11 +98,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
|
||||
@@ -91,7 +91,7 @@ public class HerbalismCommand extends SkillCommand {
|
||||
protected void permissionsCheck(Player player) {
|
||||
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
canGreenTerra = Permissions.greenTerra(player);
|
||||
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
|
||||
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOTS) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
|
||||
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS));
|
||||
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET);
|
||||
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
|
||||
|
||||
@@ -59,18 +59,17 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
boolean isLucky = Permissions.lucky(player, skill);
|
||||
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
||||
boolean hasEndurance = PerksUtils.handleActivationPerks(player, 0, 0) != 0;
|
||||
float skillValue = mcMMOPlayer.getSkillLevel(skill);
|
||||
|
||||
//Send the players a few blank lines to make finding the top of the skill command easier
|
||||
@@ -116,8 +115,21 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if ("keep".equals(args[0].toLowerCase())) {
|
||||
if (!mcMMO.p.getGeneralConfig().getAllowKeepBoard()
|
||||
|| !mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
|
||||
|| !mcMMO.p.getGeneralConfig().getSkillUseBoard()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||
ScoreboardManager.keepBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return skillGuideCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
@@ -211,7 +223,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return ImmutableList.of("?");
|
||||
return ImmutableList.of("?", "keep");
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ public class SwordsCommand extends SkillCommand {
|
||||
ruptureLengthSecondsAgainstMobs));
|
||||
|
||||
messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.TickDamage", rupturePureTickDamageAgainstPlayers, rupturePureTickDamageAgainstMobs));
|
||||
messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.ExplosionDamage", ruptureExplosionDamageAgainstPlayers, ruptureExplosionDamageAgainstMobs));
|
||||
// messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.ExplosionDamage", ruptureExplosionDamageAgainstPlayers, ruptureExplosionDamageAgainstMobs));
|
||||
|
||||
messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note"));
|
||||
messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note.Update.One"));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
|
||||
@@ -10,134 +10,137 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public class AdvancedConfig extends BukkitConfig {
|
||||
|
||||
public AdvancedConfig(File dataFolder) {
|
||||
super("advanced.yml", dataFolder);
|
||||
validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
public void initDefaults() {
|
||||
config.addDefault("Skills.General.StartingLevel", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
List<String> reason = new ArrayList<>();
|
||||
|
||||
/* GENERAL */
|
||||
if (getAbilityLength() < 1) {
|
||||
reason.add("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getEnchantBuff() < 1) {
|
||||
reason.add("Skills.General.Ability.EnchantBuff should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.General.Ability.EnchantBuff should be at least 1!");
|
||||
}
|
||||
|
||||
/* ACROBATICS */
|
||||
if (getMaximumProbability(SubSkillType.ACROBATICS_DODGE) < 1) {
|
||||
reason.add("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.ACROBATICS_DODGE) < 1) {
|
||||
reason.add("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDodgeDamageModifier() <= 1) {
|
||||
reason.add("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.ACROBATICS_ROLL) < 1) {
|
||||
reason.add("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL) < 1) {
|
||||
reason.add("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRollDamageThreshold() < 0) {
|
||||
reason.add("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
|
||||
}
|
||||
|
||||
if (getGracefulRollDamageThreshold() < 0) {
|
||||
reason.add("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
|
||||
}
|
||||
|
||||
if (getCatalysisMinSpeed() <= 0) {
|
||||
reason.add("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
|
||||
}
|
||||
|
||||
if (getCatalysisMaxSpeed() < getCatalysisMinSpeed()) {
|
||||
reason.add("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
|
||||
mcMMO.p.getLogger().warning("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
|
||||
}
|
||||
|
||||
/* ARCHERY */
|
||||
|
||||
if (getSkillShotRankDamageMultiplier() <= 0) {
|
||||
reason.add("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.ARCHERY_DAZE) < 1) {
|
||||
reason.add("Skills.Archery.Daze.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.Daze.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.ARCHERY_DAZE) < 1) {
|
||||
reason.add("Skills.Archery.Daze.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.Daze.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDazeBonusDamage() < 0) {
|
||||
reason.add("Skills.Archery.Daze.BonusDamage should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.Daze.BonusDamage should be at least 0!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.ARCHERY_ARROW_RETRIEVAL) < 1) {
|
||||
reason.add("Skills.Archery.Retrieve.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.Retrieve.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.ARCHERY_ARROW_RETRIEVAL) < 1) {
|
||||
reason.add("Skills.Archery.Retrieve.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.Retrieve.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getForceMultiplier() < 0) {
|
||||
reason.add("Skills.Archery.ForceMultiplier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Archery.ForceMultiplier should be at least 0!");
|
||||
}
|
||||
|
||||
/* AXES */
|
||||
if(getAxeMasteryRankDamageMultiplier() < 0)
|
||||
{
|
||||
reason.add("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
|
||||
if (getAxeMasteryRankDamageMultiplier() < 0) {
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.AXES_CRITICAL_STRIKES) < 1) {
|
||||
reason.add("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.AXES_CRITICAL_STRIKES) < 1) {
|
||||
reason.add("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getCriticalStrikesPVPModifier() < 1) {
|
||||
reason.add("Skills.Axes.CriticalStrikes.PVP_Modifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.CriticalStrikes.PVP_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getCriticalStrikesPVPModifier() < 1) {
|
||||
reason.add("Skills.Axes.CriticalStrikes.PVE_Modifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.CriticalStrikes.PVE_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreaterImpactChance() < 1) {
|
||||
reason.add("Skills.Axes.GreaterImpact.Chance should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.Chance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreaterImpactModifier() < 1) {
|
||||
reason.add("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreaterImpactBonusDamage() < 1) {
|
||||
reason.add("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
|
||||
}
|
||||
|
||||
if (getImpactChance() < 1) {
|
||||
reason.add("Skills.Axes.ArmorImpact.Chance should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.ArmorImpact.Chance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSkullSplitterModifier() < 1) {
|
||||
reason.add("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!");
|
||||
}
|
||||
|
||||
/* FISHING */
|
||||
@@ -145,271 +148,276 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
for (int rank : fishingTierList) {
|
||||
if (getFishingTierLevel(tier) < 0) {
|
||||
reason.add("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be at least 0!");
|
||||
}
|
||||
|
||||
if (getShakeChance(tier) < 0) {
|
||||
reason.add("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifier(tier) < 0) {
|
||||
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("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)) {
|
||||
reason.add("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Fishing.Rank_Levels.Rank_" + nextrank + "!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Fishing.Rank_Levels.Rank_" + nextrank + "!");
|
||||
}
|
||||
|
||||
if (getShakeChance(tier) > getShakeChance(nextTier)) {
|
||||
reason.add("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextrank + "!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextrank + "!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifier(tier) > getFishingVanillaXPModifier(nextTier)) {
|
||||
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextrank + "!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextrank + "!");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (getFishermanDietRankChange() < 1) {
|
||||
reason.add("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
|
||||
}
|
||||
|
||||
/*if (getIceFishingUnlockLevel() < 0) {
|
||||
reason.add("Skills.Fishing.IceFishing.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.IceFishing.UnlockLevel should be at least 0!");
|
||||
}
|
||||
|
||||
if (getMasterAnglerUnlockLevel() < 0) {
|
||||
reason.add("Skills.Fishing.MasterAngler.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
if (getMasterAnglerBoatModifier() < 1) {
|
||||
reason.add("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMasterAnglerBiomeModifier() < 1) {
|
||||
reason.add("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
|
||||
}
|
||||
|
||||
/* HERBALISM */
|
||||
if (getFarmerDietRankChange() < 1) {
|
||||
reason.add("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreenThumbStageChange() < 1) {
|
||||
reason.add("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.HERBALISM_GREEN_THUMB) < 1) {
|
||||
reason.add("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.HERBALISM_GREEN_THUMB) < 1) {
|
||||
reason.add("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.HERBALISM_DOUBLE_DROPS) < 1) {
|
||||
reason.add("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.HERBALISM_DOUBLE_DROPS) < 1) {
|
||||
reason.add("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.HERBALISM_HYLIAN_LUCK) < 1) {
|
||||
reason.add("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.HERBALISM_HYLIAN_LUCK) < 1) {
|
||||
reason.add("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.HERBALISM_SHROOM_THUMB) < 1) {
|
||||
reason.add("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.HERBALISM_SHROOM_THUMB) < 1) {
|
||||
reason.add("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
if (getMaximumProbability(SubSkillType.MINING_DOUBLE_DROPS) < 1) {
|
||||
reason.add("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.MINING_DOUBLE_DROPS) < 1) {
|
||||
reason.add("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* REPAIR */
|
||||
if (getRepairMasteryMaxBonus() < 1) {
|
||||
reason.add("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRepairMasteryMaxLevel() < 1) {
|
||||
reason.add("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.REPAIR_SUPER_REPAIR) < 1) {
|
||||
reason.add("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.REPAIR_SUPER_REPAIR) < 1) {
|
||||
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* SMELTING */
|
||||
if (getBurnModifierMaxLevel() < 1) {
|
||||
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.SMELTING_SECOND_SMELT) < 1) {
|
||||
reason.add("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.SMELTING_SECOND_SMELT) < 1) {
|
||||
reason.add("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getFluxMiningChance() < 1) {
|
||||
reason.add("Skills.Smelting.FluxMining.Chance should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Smelting.FluxMining.Chance should be at least 1!");
|
||||
}
|
||||
|
||||
/* SWORDS */
|
||||
|
||||
if (getMaximumProbability(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
|
||||
reason.add("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
|
||||
reason.add("Skills.Swords.CounterAttack.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getCounterModifier() < 1) {
|
||||
reason.add("Skills.Swords.CounterAttack.DamageModifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.DamageModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSerratedStrikesModifier() < 1) {
|
||||
reason.add("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSerratedStrikesTicks() < 1) {
|
||||
reason.add("Skills.Swords.SerratedStrikes.RuptureTicks should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Swords.SerratedStrikes.RuptureTicks should be at least 1!");
|
||||
}
|
||||
|
||||
/* TAMING */
|
||||
|
||||
if (getMaximumProbability(SubSkillType.TAMING_GORE) < 1) {
|
||||
reason.add("Skills.Taming.Gore.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.Gore.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.TAMING_GORE) < 1) {
|
||||
reason.add("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/*if (getGoreRuptureTicks() < 1) {
|
||||
reason.add("Skills.Taming.Gore.RuptureTicks should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.Gore.RuptureTicks should be at least 1!");
|
||||
}*/
|
||||
|
||||
if (getGoreModifier() < 1) {
|
||||
reason.add("Skills.Taming.Gore.Modifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.Gore.Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
/*if (getFastFoodUnlock() < 0) {
|
||||
reason.add("Skills.Taming.FastFood.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.FastFood.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
if (getFastFoodChance() < 1) {
|
||||
reason.add("Skills.Taming.FastFood.Chance should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.FastFood.Chance should be at least 1!");
|
||||
}
|
||||
|
||||
/*if (getEnviromentallyAwareUnlock() < 0) {
|
||||
reason.add("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
/*if (getThickFurUnlock() < 0) {
|
||||
reason.add("Skills.Taming.ThickFur.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.ThickFur.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
if (getThickFurModifier() < 1) {
|
||||
reason.add("Skills.Taming.ThickFur.Modifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.ThickFur.Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
/*if (getHolyHoundUnlock() < 0) {
|
||||
reason.add("Skills.Taming.HolyHound.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.HolyHound.UnlockLevel should be at least 0!");
|
||||
}
|
||||
|
||||
if (getShockProofUnlock() < 0) {
|
||||
reason.add("Skills.Taming.ShockProof.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.ShockProof.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
if (getShockProofModifier() < 1) {
|
||||
reason.add("Skills.Taming.ShockProof.Modifier should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.ShockProof.Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
/*if (getSharpenedClawsUnlock() < 0) {
|
||||
reason.add("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
if (getSharpenedClawsBonus() < 1) {
|
||||
reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxHorseJumpStrength() < 0 || getMaxHorseJumpStrength() > 2) {
|
||||
reason.add("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
|
||||
mcMMO.p.getLogger().warning("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
|
||||
}
|
||||
|
||||
/* UNARMED */
|
||||
if (getMaximumProbability(SubSkillType.UNARMED_DISARM) < 1) {
|
||||
reason.add("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.UNARMED_DISARM) < 1) {
|
||||
reason.add("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.UNARMED_ARROW_DEFLECT) < 1) {
|
||||
reason.add("Skills.Unarmed.ArrowDeflect.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Unarmed.ArrowDeflect.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.UNARMED_ARROW_DEFLECT) < 1) {
|
||||
reason.add("Skills.Unarmed.ArrowDeflect.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Unarmed.ArrowDeflect.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaximumProbability(SubSkillType.UNARMED_IRON_GRIP) < 1) {
|
||||
reason.add("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.UNARMED_IRON_GRIP) < 1) {
|
||||
reason.add("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* WOODCUTTING */
|
||||
|
||||
/*if (getLeafBlowUnlockLevel() < 0) {
|
||||
reason.add("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
|
||||
}*/
|
||||
|
||||
if (getMaximumProbability(SubSkillType.WOODCUTTING_HARVEST_LUMBER) < 1) {
|
||||
reason.add("Skills.Woodcutting.HarvestLumber.ChanceMax should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Woodcutting.HarvestLumber.ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMaxBonusLevel(SubSkillType.WOODCUTTING_HARVEST_LUMBER) < 1) {
|
||||
reason.add("Skills.Woodcutting.HarvestLumber.MaxBonusLevel should be at least 1!");
|
||||
mcMMO.p.getLogger().warning("Skills.Woodcutting.HarvestLumber.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
protected void loadKeys() {
|
||||
}
|
||||
|
||||
/* GENERAL */
|
||||
|
||||
public boolean canApplyLimitBreakPVE() { return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false); }
|
||||
public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); }
|
||||
public boolean canApplyLimitBreakPVE() {
|
||||
return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false);
|
||||
}
|
||||
|
||||
public int getStartingLevel() {
|
||||
return config.getInt("Skills.General.StartingLevel", 1);
|
||||
}
|
||||
|
||||
public boolean allowPlayerTips() {
|
||||
return config.getBoolean("Feedback.PlayerTips", true);
|
||||
@@ -418,10 +426,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
/**
|
||||
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
|
||||
* It returns a different value depending on whether or not the server is in retro mode
|
||||
*
|
||||
* @return the level at which abilities stop increasing in length
|
||||
*/
|
||||
public int getAbilityLengthCap() {
|
||||
if(!mcMMO.isRetroModeEnabled())
|
||||
if (!mcMMO.isRetroModeEnabled())
|
||||
return config.getInt("Skills.General.Ability.Length.Standard.CapLevel", 50);
|
||||
else
|
||||
return config.getInt("Skills.General.Ability.Length.RetroMode.CapLevel", 500);
|
||||
@@ -430,27 +439,32 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
/**
|
||||
* This returns the frequency at which abilities will increase in length
|
||||
* It returns a different value depending on whether or not the server is in retro mode
|
||||
*
|
||||
* @return the number of levels required per ability length increase
|
||||
*/
|
||||
public int getAbilityLength() {
|
||||
if(!mcMMO.isRetroModeEnabled())
|
||||
if (!mcMMO.isRetroModeEnabled())
|
||||
return config.getInt("Skills.General.Ability.Length.Standard.IncreaseLevel", 5);
|
||||
else
|
||||
return config.getInt("Skills.General.Ability.Length.RetroMode.IncreaseLevel", 50);
|
||||
}
|
||||
|
||||
public int getEnchantBuff() { return config.getInt("Skills.General.Ability.EnchantBuff", 5); }
|
||||
public int getEnchantBuff() {
|
||||
return config.getInt("Skills.General.Ability.EnchantBuff", 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the max bonus level for a skill used in RNG calculations
|
||||
* All max level values in the config are multiplied by 10 if the server is in retro mode as the values in the config are based around the new 1-100 skill system scaling
|
||||
* A value of 10 in the file will be returned as 100 for retro mode servers to accommodate the change in scaling
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
*
|
||||
* @return the level at which this skills max benefits will be reached on the curve
|
||||
*/
|
||||
public int getMaxBonusLevel(SubSkillType subSkillType) {
|
||||
String keyPath = subSkillType.getAdvConfigAddress() + ".MaxBonusLevel.";
|
||||
return mcMMO.isRetroModeEnabled() ? config.getInt(keyPath+"RetroMode", 1000) : config.getInt(keyPath+"Standard", 100);
|
||||
return mcMMO.isRetroModeEnabled() ? config.getInt(keyPath + "RetroMode", 1000) : config.getInt(keyPath + "Standard", 100);
|
||||
}
|
||||
|
||||
public int getMaxBonusLevel(AbstractSubSkill abstractSubSkill) {
|
||||
@@ -462,35 +476,29 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
return config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D);
|
||||
}
|
||||
|
||||
public double getMaximumProbability(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
public double getMaximumProbability(AbstractSubSkill abstractSubSkill) {
|
||||
return getMaximumProbability(abstractSubSkill.getSubSkillType());
|
||||
}
|
||||
|
||||
/* Notification Settings */
|
||||
|
||||
public boolean doesSkillCommandSendBlankLines()
|
||||
{
|
||||
public boolean doesSkillCommandSendBlankLines() {
|
||||
return config.getBoolean("Feedback.SkillCommand.BlankLinesAboveHeader", true);
|
||||
}
|
||||
|
||||
public boolean doesNotificationUseActionBar(NotificationType notificationType)
|
||||
{
|
||||
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".Enabled", true);
|
||||
public boolean doesNotificationUseActionBar(NotificationType notificationType) {
|
||||
return config.getBoolean("Feedback.ActionBarNotifications." + notificationType.toString() + ".Enabled", true);
|
||||
}
|
||||
|
||||
public boolean doesNotificationSendCopyToChat(NotificationType notificationType)
|
||||
{
|
||||
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".SendCopyOfMessageToChat", false);
|
||||
public boolean doesNotificationSendCopyToChat(NotificationType notificationType) {
|
||||
return config.getBoolean("Feedback.ActionBarNotifications." + notificationType.toString() + ".SendCopyOfMessageToChat", false);
|
||||
}
|
||||
|
||||
public boolean useTitlesForXPEvent()
|
||||
{
|
||||
public boolean useTitlesForXPEvent() {
|
||||
return config.getBoolean("Feedback.Events.XP.SendTitles", true);
|
||||
}
|
||||
|
||||
public boolean sendAbilityNotificationToOtherPlayers()
|
||||
{
|
||||
public boolean sendAbilityNotificationToOtherPlayers() {
|
||||
return config.getBoolean("Feedback.Events.AbilityActivation.SendNotificationToOtherPlayers", true);
|
||||
}
|
||||
|
||||
@@ -509,6 +517,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Used to color our details header in our JSON Hover Object tooltips
|
||||
*
|
||||
* @return the ChatColor for this element
|
||||
*/
|
||||
/*public ChatColor getJSONStatHoverDetailsColor()
|
||||
@@ -557,7 +566,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
{
|
||||
return getChatColor(config.getString("Style.JSON.Notification."+notificationType.toString()+".Color"));
|
||||
}*/
|
||||
|
||||
private ChatColor getChatColorFromKey(String keyLocation) {
|
||||
String colorName = config.getString(keyLocation);
|
||||
|
||||
@@ -598,110 +606,243 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Some SubSkills have the ability to retain classic functionality
|
||||
*
|
||||
* @param subSkillType SubSkillType with classic functionality
|
||||
*
|
||||
* @return true if the subskill is in classic mode
|
||||
*/
|
||||
public boolean isSubSkillClassic(SubSkillType subSkillType)
|
||||
{
|
||||
return config.getBoolean(subSkillType.getAdvConfigAddress()+".Classic");
|
||||
public boolean isSubSkillClassic(SubSkillType subSkillType) {
|
||||
return config.getBoolean(subSkillType.getAdvConfigAddress() + ".Classic");
|
||||
}
|
||||
|
||||
/* ACROBATICS */
|
||||
public double getDodgeDamageModifier() { return config.getDouble("Skills.Acrobatics.Dodge.DamageModifier", 2.0D); }
|
||||
public double getDodgeDamageModifier() {
|
||||
return config.getDouble("Skills.Acrobatics.Dodge.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.Roll.DamageThreshold", 7.0D); }
|
||||
public double getRollDamageThreshold() {
|
||||
return config.getDouble("Skills.Acrobatics.Roll.DamageThreshold", 7.0D);
|
||||
}
|
||||
|
||||
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D); }
|
||||
public double getGracefulRollDamageThreshold() {
|
||||
return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D);
|
||||
}
|
||||
|
||||
/* ALCHEMY */
|
||||
public int getCatalysisMaxBonusLevel() { return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000); }
|
||||
public int getCatalysisMaxBonusLevel() {
|
||||
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000);
|
||||
}
|
||||
|
||||
public double getCatalysisMinSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MinSpeed", 1.0D); }
|
||||
public double getCatalysisMaxSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MaxSpeed", 4.0D); }
|
||||
public double getCatalysisMinSpeed() {
|
||||
return config.getDouble("Skills.Alchemy.Catalysis.MinSpeed", 1.0D);
|
||||
}
|
||||
|
||||
public double getCatalysisMaxSpeed() {
|
||||
return config.getDouble("Skills.Alchemy.Catalysis.MaxSpeed", 4.0D);
|
||||
}
|
||||
|
||||
|
||||
/* ARCHERY */
|
||||
public double getSkillShotRankDamageMultiplier() { return config.getDouble("Skills.Archery.SkillShot.RankDamageMultiplier", 10.0D); }
|
||||
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
|
||||
public double getSkillShotRankDamageMultiplier() {
|
||||
return config.getDouble("Skills.Archery.SkillShot.RankDamageMultiplier", 10.0D);
|
||||
}
|
||||
|
||||
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
|
||||
public double getSkillShotDamageMax() {
|
||||
return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D);
|
||||
}
|
||||
|
||||
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
|
||||
public double getDazeBonusDamage() {
|
||||
return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D);
|
||||
}
|
||||
|
||||
public double getForceMultiplier() {
|
||||
return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D);
|
||||
}
|
||||
|
||||
/* AXES */
|
||||
public double getAxeMasteryRankDamageMultiplier() { return config.getDouble("Skills.Axes.AxeMastery.RankDamageMultiplier", 1.0D); }
|
||||
public double getAxeMasteryRankDamageMultiplier() {
|
||||
return config.getDouble("Skills.Axes.AxeMastery.RankDamageMultiplier", 1.0D);
|
||||
}
|
||||
|
||||
public double getCriticalStrikesPVPModifier() { return config.getDouble("Skills.Axes.CriticalStrikes.PVP_Modifier", 1.5D); }
|
||||
public double getCriticalStrikesPVEModifier() { return config.getDouble("Skills.Axes.CriticalStrikes.PVE_Modifier", 2.0D); }
|
||||
public double getCriticalStrikesPVPModifier() {
|
||||
return config.getDouble("Skills.Axes.CriticalStrikes.PVP_Modifier", 1.5D);
|
||||
}
|
||||
|
||||
public double getGreaterImpactChance() { return config.getDouble("Skills.Axes.GreaterImpact.Chance", 25.0D); }
|
||||
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact.KnockbackModifier", 1.5D); }
|
||||
public double getGreaterImpactBonusDamage() { return config.getDouble("Skills.Axes.GreaterImpact.BonusDamage", 2.0D); }
|
||||
public double getCriticalStrikesPVEModifier() {
|
||||
return config.getDouble("Skills.Axes.CriticalStrikes.PVE_Modifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact.Chance", 25.0D); }
|
||||
public double getImpactDurabilityDamageMultiplier() { return config.getDouble("Skills.Axes.ArmorImpact.DamagePerRank", 6.5D); }
|
||||
public double getGreaterImpactChance() {
|
||||
return config.getDouble("Skills.Axes.GreaterImpact.Chance", 25.0D);
|
||||
}
|
||||
|
||||
public double getSkullSplitterModifier() { return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D); }
|
||||
public double getGreaterImpactModifier() {
|
||||
return config.getDouble("Skills.Axes.GreaterImpact.KnockbackModifier", 1.5D);
|
||||
}
|
||||
|
||||
public double getGreaterImpactBonusDamage() {
|
||||
return config.getDouble("Skills.Axes.GreaterImpact.BonusDamage", 2.0D);
|
||||
}
|
||||
|
||||
public double getImpactChance() {
|
||||
return config.getDouble("Skills.Axes.ArmorImpact.Chance", 25.0D);
|
||||
}
|
||||
|
||||
public double getImpactDurabilityDamageMultiplier() {
|
||||
return config.getDouble("Skills.Axes.ArmorImpact.DamagePerRank", 6.5D);
|
||||
}
|
||||
|
||||
public double getSkullSplitterModifier() {
|
||||
return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
//Nothing to configure, everything is already configurable in config.yml
|
||||
|
||||
/* FISHING */
|
||||
public double getShakeChance(int rank) { return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank); }
|
||||
public int getFishingVanillaXPModifier(int rank) { return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank); }
|
||||
public double getShakeChance(int rank) {
|
||||
return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank);
|
||||
}
|
||||
|
||||
public int getFishingReductionMinWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Min_Wait", 10);}
|
||||
public int getFishingReductionMaxWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Max_Wait", 30);}
|
||||
public int getFishingBoatReductionMinWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Min_Wait", 10);}
|
||||
public int getFishingBoatReductionMaxWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Max_Wait", 30);}
|
||||
public int getFishingReductionMinWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Min_Wait", 40);}
|
||||
public int getFishingReductionMaxWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait", 100);}
|
||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200); }
|
||||
public int getFishingVanillaXPModifier(int rank) {
|
||||
return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank);
|
||||
}
|
||||
|
||||
public int getFishingReductionMinWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Min_Wait", 10);
|
||||
}
|
||||
|
||||
public int getFishingReductionMaxWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Max_Wait", 30);
|
||||
}
|
||||
|
||||
public int getFishingBoatReductionMinWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Min_Wait", 10);
|
||||
}
|
||||
|
||||
public int getFishingBoatReductionMaxWaitTicks() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Max_Wait", 30);
|
||||
}
|
||||
|
||||
public int getFishingReductionMinWaitCap() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Min_Wait", 40);
|
||||
}
|
||||
|
||||
public int getFishingReductionMaxWaitCap() {
|
||||
return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait", 100);
|
||||
}
|
||||
|
||||
public int getFishermanDietRankChange() {
|
||||
return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200);
|
||||
}
|
||||
|
||||
|
||||
public double getMasterAnglerBoatModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BoatModifier", 2.0); }
|
||||
public double getMasterAnglerBiomeModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BiomeModifier", 2.0); }
|
||||
public double getMasterAnglerBoatModifier() {
|
||||
return config.getDouble("Skills.Fishing.MasterAngler.BoatModifier", 2.0);
|
||||
}
|
||||
|
||||
public double getMasterAnglerBiomeModifier() {
|
||||
return config.getDouble("Skills.Fishing.MasterAngler.BiomeModifier", 2.0);
|
||||
}
|
||||
|
||||
/* HERBALISM */
|
||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.FarmersDiet.RankChange", 200); }
|
||||
public int getFarmerDietRankChange() {
|
||||
return config.getInt("Skills.Herbalism.FarmersDiet.RankChange", 200);
|
||||
}
|
||||
|
||||
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb.StageChange", 200); }
|
||||
public int getGreenThumbStageChange() {
|
||||
return config.getInt("Skills.Herbalism.GreenThumb.StageChange", 200);
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
public boolean getDoubleDropSilkTouchEnabled() { return config.getBoolean("Skills.Mining.DoubleDrops.SilkTouch", true); }
|
||||
public boolean getAllowMiningTripleDrops() { return config.getBoolean("Skills.Mining.SuperBreaker.AllowTripleDrops", true); }
|
||||
public int getBlastMiningRankLevel(int rank) { return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank); }
|
||||
public double getBlastDamageDecrease(int rank) { return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank); }
|
||||
public double getOreBonus(int rank) { return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank); }
|
||||
public double getDebrisReduction(int rank) { return config.getDouble("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank); }
|
||||
public int getDropMultiplier(int rank) { return config.getInt("Skills.Mining.BlastMining.DropMultiplier.Rank_" + rank); }
|
||||
public double getBlastRadiusModifier(int rank) { return config.getDouble("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + rank); }
|
||||
public boolean getDoubleDropSilkTouchEnabled() {
|
||||
return config.getBoolean("Skills.Mining.DoubleDrops.SilkTouch", true);
|
||||
}
|
||||
|
||||
public boolean getAllowMiningTripleDrops() {
|
||||
return config.getBoolean("Skills.Mining.SuperBreaker.AllowTripleDrops", true);
|
||||
}
|
||||
|
||||
public int getBlastMiningRankLevel(int rank) {
|
||||
return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getBlastDamageDecrease(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getOreBonus(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getDebrisReduction(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank);
|
||||
}
|
||||
|
||||
public int getDropMultiplier(int rank) {
|
||||
return config.getInt("Skills.Mining.BlastMining.DropMultiplier.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getBlastRadiusModifier(int rank) {
|
||||
return config.getDouble("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + rank);
|
||||
}
|
||||
|
||||
/* REPAIR */
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 100); }
|
||||
public double getRepairMasteryMaxBonus() {
|
||||
return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D);
|
||||
}
|
||||
|
||||
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.May_Lose_Enchants", true); }
|
||||
public double getArcaneForgingKeepEnchantsChance(int rank) { return config.getDouble("Skills.Repair.ArcaneForging.Keep_Enchants_Chance.Rank_" + rank); }
|
||||
public int getRepairMasteryMaxLevel() {
|
||||
return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 100);
|
||||
}
|
||||
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
|
||||
public double getArcaneForgingDowngradeChance(int rank) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + rank); }
|
||||
public boolean getAllowEnchantedRepairMaterials() {
|
||||
return config.getBoolean("Skills.Repair.Use_Enchanted_Materials", false);
|
||||
}
|
||||
|
||||
public boolean getArcaneSalvageEnchantDowngradeEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true); }
|
||||
public boolean getArcaneSalvageEnchantLossEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true); }
|
||||
public boolean getArcaneForgingEnchantLossEnabled() {
|
||||
return config.getBoolean("Skills.Repair.ArcaneForging.May_Lose_Enchants", true);
|
||||
}
|
||||
|
||||
public double getArcaneSalvageExtractFullEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank); }
|
||||
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank); }
|
||||
public double getArcaneForgingKeepEnchantsChance(int rank) {
|
||||
return config.getDouble("Skills.Repair.ArcaneForging.Keep_Enchants_Chance.Rank_" + rank);
|
||||
}
|
||||
|
||||
public boolean getArcaneForgingDowngradeEnabled() {
|
||||
return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true);
|
||||
}
|
||||
|
||||
public double getArcaneForgingDowngradeChance(int rank) {
|
||||
return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + rank);
|
||||
}
|
||||
|
||||
public boolean getArcaneSalvageEnchantDowngradeEnabled() {
|
||||
return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true);
|
||||
}
|
||||
|
||||
public boolean getArcaneSalvageEnchantLossEnabled() {
|
||||
return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true);
|
||||
}
|
||||
|
||||
public double getArcaneSalvageExtractFullEnchantsChance(int rank) {
|
||||
return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank);
|
||||
}
|
||||
|
||||
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) {
|
||||
return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank);
|
||||
}
|
||||
|
||||
/* SMELTING */
|
||||
public int getBurnModifierMaxLevel() {
|
||||
if(mcMMO.isRetroModeEnabled())
|
||||
if (mcMMO.isRetroModeEnabled())
|
||||
return config.getInt("Skills.Smelting.FuelEfficiency.RetroMode.MaxBonusLevel", 1000);
|
||||
else
|
||||
return config.getInt("Skills.Smelting.FuelEfficiency.Standard.MaxBonusLevel", 100);
|
||||
}
|
||||
|
||||
public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining.Chance", 33.0D); }
|
||||
public double getFluxMiningChance() {
|
||||
return config.getDouble("Skills.Smelting.FluxMining.Chance", 33.0D);
|
||||
}
|
||||
|
||||
/* SWORDS */
|
||||
public double getRuptureTickDamage(boolean isTargetPlayer, int rank) {
|
||||
@@ -731,35 +872,68 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
return config.getDouble(root + rank, 33);
|
||||
}
|
||||
|
||||
public double getCounterModifier() { return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D); }
|
||||
public double getCounterModifier() {
|
||||
return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getSerratedStrikesModifier() { return config.getDouble("Skills.Swords.SerratedStrikes.DamageModifier", 4.0D); }
|
||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes.RuptureTicks", 5); }
|
||||
public double getSerratedStrikesModifier() {
|
||||
return config.getDouble("Skills.Swords.SerratedStrikes.DamageModifier", 4.0D);
|
||||
}
|
||||
|
||||
public int getSerratedStrikesTicks() {
|
||||
return config.getInt("Skills.Swords.SerratedStrikes.RuptureTicks", 5);
|
||||
}
|
||||
|
||||
/* TAMING */
|
||||
public double getGoreModifier() { return config.getDouble("Skills.Taming.Gore.Modifier", 2.0D); }
|
||||
public double getGoreModifier() {
|
||||
return config.getDouble("Skills.Taming.Gore.Modifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getFastFoodChance() { return config.getDouble("Skills.Taming.FastFoodService.Chance", 50.0D); }
|
||||
public double getPummelChance() { return config.getDouble("Skills.Taming.Pummel.Chance", 10.0D); }
|
||||
public double getFastFoodChance() {
|
||||
return config.getDouble("Skills.Taming.FastFoodService.Chance", 50.0D);
|
||||
}
|
||||
|
||||
public double getThickFurModifier() { return config.getDouble("Skills.Taming.ThickFur.Modifier", 2.0D); }
|
||||
public double getPummelChance() {
|
||||
return config.getDouble("Skills.Taming.Pummel.Chance", 10.0D);
|
||||
}
|
||||
|
||||
public double getShockProofModifier() { return config.getDouble("Skills.Taming.ShockProof.Modifier", 6.0D); }
|
||||
public double getThickFurModifier() {
|
||||
return config.getDouble("Skills.Taming.ThickFur.Modifier", 2.0D);
|
||||
}
|
||||
|
||||
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
|
||||
public double getShockProofModifier() {
|
||||
return config.getDouble("Skills.Taming.ShockProof.Modifier", 6.0D);
|
||||
}
|
||||
|
||||
public double getMinHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D); }
|
||||
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
|
||||
public double getSharpenedClawsBonus() {
|
||||
return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D);
|
||||
}
|
||||
|
||||
public double getMinHorseJumpStrength() {
|
||||
return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D);
|
||||
}
|
||||
|
||||
public double getMaxHorseJumpStrength() {
|
||||
return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D);
|
||||
}
|
||||
|
||||
/* UNARMED */
|
||||
|
||||
public boolean isSteelArmDamageCustom() { return config.getBoolean("Skills.Unarmed.SteelArmStyle.Damage_Override", false); }
|
||||
public boolean isSteelArmDamageCustom() {
|
||||
return config.getBoolean("Skills.Unarmed.SteelArmStyle.Damage_Override", false);
|
||||
}
|
||||
|
||||
public double getSteelArmOverride(int rank, double def) {
|
||||
String key = "Rank_" + rank;
|
||||
return config.getDouble("Skills.Unarmed.SteelArmStyle.Override." + key, def);
|
||||
}
|
||||
public boolean getDisarmProtected() { return config.getBoolean("Skills.Unarmed.Disarm.AntiTheft", false); }
|
||||
|
||||
public boolean getDisarmProtected() {
|
||||
return config.getBoolean("Skills.Unarmed.Disarm.AntiTheft", false);
|
||||
}
|
||||
|
||||
/* WOODCUTTING */
|
||||
public boolean isKnockOnWoodXPOrbEnabled() { return config.getBoolean("Skills.Woodcutting.TreeFeller.Knock_On_Wood.Add_XP_Orbs_To_Drops", true); }
|
||||
public boolean isKnockOnWoodXPOrbEnabled() {
|
||||
return config.getBoolean("Skills.Woodcutting.TreeFeller.Knock_On_Wood.Add_XP_Orbs_To_Drops", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,9 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
@@ -32,7 +31,8 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
|
||||
protected void saveConfig() {
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Saving changes to config file - "+fileName);
|
||||
mcMMO.p.getLogger().info("Saving changes to config file - " + fileName);
|
||||
config.options().indent(2);
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -53,22 +53,24 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
// keys present in current config file that are not in the template
|
||||
Set<String> oldKeys = new HashSet<>(configKeys);
|
||||
oldKeys.removeAll(internalConfigKeys);
|
||||
|
||||
if (!oldKeys.isEmpty()) {
|
||||
mcMMO.p.debug("old key(s) in \"" + fileName + "\"");
|
||||
for (String key : oldKeys) {
|
||||
mcMMO.p.debug(" old-key:" + key);
|
||||
}
|
||||
}
|
||||
|
||||
// keys present in template that are not in current file
|
||||
Set<String> newKeys = new HashSet<>(internalConfigKeys);
|
||||
newKeys.removeAll(configKeys);
|
||||
|
||||
// Don't need a re-save if we have old keys sticking around?
|
||||
// Would be less saving, but less... correct?
|
||||
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
|
||||
if (!newKeys.isEmpty()) {
|
||||
needSave = true;
|
||||
}
|
||||
//
|
||||
// for (String key : oldKeys) {
|
||||
// mcMMO.p.debug("Detected potentially unused key: " + key);
|
||||
// //config.set(key, null);
|
||||
// }
|
||||
|
||||
for (String key : newKeys) {
|
||||
mcMMO.p.debug("Adding new key: " + key + " = " + internalConfig.get(key));
|
||||
@@ -76,71 +78,9 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (needSave) {
|
||||
// Get Bukkit's version of an acceptable config with new keys, and no old keys
|
||||
String output = config.saveToString();
|
||||
|
||||
// Convert to the superior 4 space indentation
|
||||
output = output.replace(" ", " ");
|
||||
|
||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||
while (output.replaceAll("[//s]", "").startsWith("#")) {
|
||||
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||
}
|
||||
|
||||
// Read the internal config to get comments, then put them in the new one
|
||||
try {
|
||||
// Read internal
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(mcMMO.p.getResource(fileName)));
|
||||
LinkedHashMap<String, String> comments = new LinkedHashMap<>();
|
||||
StringBuilder temp = new StringBuilder();
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.contains("#")) {
|
||||
temp.append(line).append("\n");
|
||||
}
|
||||
else if (line.contains(":")) {
|
||||
line = line.substring(0, line.indexOf(":") + 1);
|
||||
if (temp.length() > 0) {
|
||||
if(comments.containsKey(line)) {
|
||||
int index = 0;
|
||||
while(comments.containsKey(line + index)) {
|
||||
index++;
|
||||
}
|
||||
|
||||
line = line + index;
|
||||
}
|
||||
|
||||
comments.put(line, temp.toString());
|
||||
temp = new StringBuilder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dump to the new one
|
||||
HashMap<String, Integer> indexed = new HashMap<>();
|
||||
for (String key : comments.keySet()) {
|
||||
String actualkey = key.substring(0, key.indexOf(":") + 1);
|
||||
|
||||
int index = 0;
|
||||
if(indexed.containsKey(actualkey)) {
|
||||
index = indexed.get(actualkey);
|
||||
}
|
||||
boolean isAtTop = !output.contains("\n" + actualkey);
|
||||
index = output.indexOf((isAtTop ? "" : "\n") + actualkey, index);
|
||||
|
||||
if (index >= 0) {
|
||||
output = output.substring(0, index) + "\n" + comments.get(key) + output.substring(isAtTop ? index : index + 1);
|
||||
indexed.put(actualkey, index + comments.get(key).length() + actualkey.length() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Save it
|
||||
if(dataFolder == null) {
|
||||
|
||||
if (dataFolder == null) {
|
||||
mcMMO.p.getLogger().severe("Data folder should never be null!");
|
||||
return;
|
||||
}
|
||||
@@ -153,13 +93,11 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
}
|
||||
|
||||
File newSaveFile = new File(dataFolder, saveName);
|
||||
FileWriter fileWriter = new FileWriter(newSaveFile.getAbsolutePath());
|
||||
BufferedWriter writer = new BufferedWriter(fileWriter);
|
||||
writer.write(output);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
YamlConfiguration yamlConfiguration = config;
|
||||
yamlConfiguration.options().indent(4);
|
||||
yamlConfiguration.save(newSaveFile);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
224
src/main/java/com/gmail/nossr50/config/BukkitConfig.java
Normal file
224
src/main/java/com/gmail/nossr50/config/BukkitConfig.java
Normal file
@@ -0,0 +1,224 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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;
|
||||
|
||||
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 = '#';
|
||||
protected final String fileName;
|
||||
protected final File configFile;
|
||||
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
|
||||
|
||||
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
|
||||
mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
|
||||
this.fileName = fileName;
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, fileName);
|
||||
purgeComments(true);
|
||||
this.config = initConfig();
|
||||
initDefaults();
|
||||
updateFile();
|
||||
mcMMO.p.getLogger().info("[config] Config initialized: " + fileName);
|
||||
validate();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BukkitConfig(@NotNull String fileName) {
|
||||
this(fileName, mcMMO.p.getDataFolder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize default values for the config
|
||||
*/
|
||||
public void initDefaults() {}
|
||||
|
||||
/**
|
||||
* Update the file on the disk by copying out any new and missing defaults
|
||||
*/
|
||||
public void updateFile() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private YamlConfiguration initConfig() {
|
||||
if (!configFile.exists()) {
|
||||
mcMMO.p.getLogger().info("[config] 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);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.options().indent(4);
|
||||
|
||||
try {
|
||||
config.options().parseComments(true);
|
||||
} catch (NoSuchMethodError e) {
|
||||
//e.printStackTrace();
|
||||
// mcMMO.p.getLogger().severe("Your Spigot/CraftBukkit API is out of date, update your server software!");
|
||||
}
|
||||
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
try {
|
||||
config.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected 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
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
validateConfigKeys();
|
||||
|
||||
if (unmodifiedConfig) {
|
||||
mcMMO.p.debug("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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
|
||||
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
||||
|
||||
if (mcMMO.p.getResource(fileName) != null) {
|
||||
mcMMO.p.saveResource(fileName, true);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().warning("Reloading " + fileName + " with new values...");
|
||||
initConfig();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,11 @@ import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChatConfig extends AutoUpdateConfigLoader {
|
||||
public class ChatConfig extends BukkitConfig {
|
||||
private static ChatConfig instance;
|
||||
|
||||
private ChatConfig() {
|
||||
super("chat.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static ChatConfig getInstance() {
|
||||
@@ -26,8 +25,8 @@ public class ChatConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
return true;
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
public boolean isChatEnabled() {
|
||||
@@ -41,7 +40,9 @@ public class ChatConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Whether or not to use display names for players in target {@link ChatChannel}
|
||||
*
|
||||
* @param chatChannel target chat channel
|
||||
*
|
||||
* @return true if display names should be used
|
||||
*/
|
||||
public boolean useDisplayNames(@NotNull ChatChannel chatChannel) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -9,10 +8,10 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
protected String fileName;
|
||||
protected final File configFile;
|
||||
protected FileConfiguration config;
|
||||
protected @NotNull final File dataFolder;
|
||||
protected final @NotNull File dataFolder;
|
||||
protected String fileName;
|
||||
protected YamlConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) {
|
||||
this.fileName = fileName;
|
||||
@@ -46,17 +45,15 @@ public abstract class ConfigLoader {
|
||||
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
mcMMO.p.debug("Creating mcMMO " + fileName + " File...");
|
||||
mcMMO.p.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||
|
||||
try {
|
||||
mcMMO.p.saveResource(fileName, false); // Normal files
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mcMMO.p.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.debug("Loading mcMMO " + fileName + " File...");
|
||||
} else {
|
||||
mcMMO.p.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
@@ -79,11 +76,9 @@ public abstract class ConfigLoader {
|
||||
protected void validate() {
|
||||
if (validateKeys()) {
|
||||
mcMMO.p.debug("No errors found in " + fileName + "!");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
|
||||
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
|
||||
mcMMO.p.noErrorsInConfigFiles = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,18 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
|
||||
public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||
public class CoreSkillsConfig extends BukkitConfig {
|
||||
private static CoreSkillsConfig instance;
|
||||
|
||||
public CoreSkillsConfig()
|
||||
{
|
||||
public CoreSkillsConfig() {
|
||||
super("coreskills.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static CoreSkillsConfig getInstance() {
|
||||
if (instance == null)
|
||||
instance = new CoreSkillsConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -18,18 +23,9 @@ public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
}
|
||||
|
||||
public static CoreSkillsConfig getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
return new CoreSkillsConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
|
||||
return true;
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -39,21 +35,23 @@ public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||
/**
|
||||
* Whether or not a skill is enabled
|
||||
* Defaults true
|
||||
*
|
||||
* @param abstractSubSkill SubSkill definition to check
|
||||
*
|
||||
* @return true if subskill is enabled
|
||||
*/
|
||||
public boolean isSkillEnabled(AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
return config.getBoolean(StringUtils.getCapitalized(abstractSubSkill.getPrimarySkill().toString())+"."+ abstractSubSkill.getConfigKeyName()+".Enabled", true);
|
||||
public boolean isSkillEnabled(AbstractSubSkill abstractSubSkill) {
|
||||
return config.getBoolean(StringUtils.getCapitalized(abstractSubSkill.getPrimarySkill().toString()) + "." + abstractSubSkill.getConfigKeyName() + ".Enabled", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this primary skill is enabled
|
||||
*
|
||||
* @param primarySkillType target primary skill
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isPrimarySkillEnabled(PrimarySkillType primarySkillType)
|
||||
{
|
||||
return config.getBoolean(StringUtils.getCapitalized(primarySkillType.toString())+".Enabled", true);
|
||||
public boolean isPrimarySkillEnabled(PrimarySkillType primarySkillType) {
|
||||
return config.getBoolean(StringUtils.getCapitalized(primarySkillType.toString()) + ".Enabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,12 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
|
||||
public class PersistentDataConfig extends AutoUpdateConfigLoader {
|
||||
public class PersistentDataConfig extends BukkitConfig {
|
||||
private static PersistentDataConfig instance;
|
||||
|
||||
private PersistentDataConfig() {
|
||||
super("persistent_data.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static PersistentDataConfig getInstance() {
|
||||
@@ -24,8 +23,8 @@ public class PersistentDataConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
return true;
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
//Persistent Data Toggles
|
||||
|
||||
@@ -12,26 +12,24 @@ import java.util.List;
|
||||
public class RankConfig extends AutoUpdateConfigLoader {
|
||||
private static RankConfig instance;
|
||||
|
||||
public RankConfig()
|
||||
{
|
||||
public RankConfig() {
|
||||
super("skillranks.yml");
|
||||
validate();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public static RankConfig getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
public static RankConfig getInstance() {
|
||||
if (instance == null)
|
||||
return new RankConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
List<String> reason = new ArrayList<>();
|
||||
@@ -46,12 +44,13 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank)
|
||||
{
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank) {
|
||||
String key = subSkillType.getRankConfigAddress();
|
||||
|
||||
return findRankByRootAddress(rank, key);
|
||||
@@ -59,33 +58,37 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
*
|
||||
* @param subSkillType target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode)
|
||||
{
|
||||
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode) {
|
||||
String key = getRankAddressKey(subSkillType, rank, retroMode);
|
||||
return config.getInt(key, getInternalConfig().getInt(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
*
|
||||
* @param abstractSubSkill target subskill
|
||||
* @param rank the rank we are checking
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank)
|
||||
{
|
||||
String key = abstractSubSkill.getPrimaryKeyName()+"."+abstractSubSkill.getConfigKeyName();
|
||||
public int getSubSkillUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) {
|
||||
String key = abstractSubSkill.getPrimaryKeyName() + "." + abstractSubSkill.getConfigKeyName();
|
||||
|
||||
return findRankByRootAddress(rank, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unlock level for a subskill depending on the gamemode
|
||||
* @param key root address of the subskill in the rankskills.yml file
|
||||
*
|
||||
* @param key root address of the subskill in the rankskills.yml file
|
||||
* @param rank the rank we are checking
|
||||
*
|
||||
* @return the level requirement for a subskill at this particular rank
|
||||
*/
|
||||
private int findRankByRootAddress(int rank, String key) {
|
||||
@@ -127,60 +130,55 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
String key = getRankAddressKey(subSkillType, rank, retroMode);
|
||||
int defaultValue = getInternalConfig().getInt(key);
|
||||
config.set(key, defaultValue);
|
||||
mcMMO.p.getLogger().info(key +" SET -> " + defaultValue);
|
||||
mcMMO.p.getLogger().info(key + " SET -> " + defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for valid keys for subskill ranks
|
||||
*/
|
||||
private void checkKeys(@NotNull List<String> reasons)
|
||||
{
|
||||
private void checkKeys(@NotNull List<String> reasons) {
|
||||
HashSet<SubSkillType> badSkillSetup = new HashSet<>();
|
||||
|
||||
|
||||
//For now we will only check ranks of stuff I've overhauled
|
||||
checkConfig(reasons, badSkillSetup, true);
|
||||
checkConfig(reasons, badSkillSetup, false);
|
||||
|
||||
//Fix bad entries
|
||||
if(badSkillSetup.isEmpty())
|
||||
if (badSkillSetup.isEmpty())
|
||||
return;
|
||||
|
||||
mcMMO.p.getLogger().info("(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
|
||||
|
||||
for(SubSkillType subSkillType : badSkillSetup) {
|
||||
mcMMO.p.getLogger().info("(FIXING CONFIG) Resetting rank config settings for skill named - "+subSkillType.toString());
|
||||
for (SubSkillType subSkillType : badSkillSetup) {
|
||||
mcMMO.p.getLogger().info("(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
|
||||
fixBadEntries(subSkillType);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkConfig(@NotNull List<String> reasons, @NotNull HashSet<SubSkillType> badSkillSetup, boolean retroMode) {
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
for (SubSkillType subSkillType : SubSkillType.values()) {
|
||||
//Keeping track of the rank requirements and making sure there are no logical errors
|
||||
int curRank = 0;
|
||||
int prevRank = 0;
|
||||
|
||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||
{
|
||||
int index = x+1;
|
||||
for (int x = 0; x < subSkillType.getNumRanks(); x++) {
|
||||
int index = x + 1;
|
||||
|
||||
if(curRank > 0)
|
||||
if (curRank > 0)
|
||||
prevRank = curRank;
|
||||
|
||||
curRank = getSubSkillUnlockLevel(subSkillType, index, retroMode);
|
||||
|
||||
//Do we really care if its below 0? Probably not
|
||||
if(curRank < 0)
|
||||
{
|
||||
reasons.add("(CONFIG ISSUE) " + subSkillType.toString() + " should not have any ranks that require a negative level!");
|
||||
if (curRank < 0) {
|
||||
reasons.add("(CONFIG ISSUE) " + subSkillType + " should not have any ranks that require a negative level!");
|
||||
badSkillSetup.add(subSkillType);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(prevRank > curRank)
|
||||
{
|
||||
if (prevRank > curRank) {
|
||||
//We're going to allow this but we're going to warn them
|
||||
mcMMO.p.getLogger().info("(CONFIG ISSUE) You have the ranks for the subskill "+ subSkillType.toString()+" set up poorly, sequential ranks should have ascending requirements");
|
||||
mcMMO.p.getLogger().info("(CONFIG ISSUE) You have the ranks for the subskill " + subSkillType + " set up poorly, sequential ranks should have ascending requirements");
|
||||
badSkillSetup.add(subSkillType);
|
||||
}
|
||||
}
|
||||
@@ -188,9 +186,8 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
private void fixBadEntries(@NotNull SubSkillType subSkillType) {
|
||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||
{
|
||||
int index = x+1;
|
||||
for (int x = 0; x < subSkillType.getNumRanks(); x++) {
|
||||
int index = x + 1;
|
||||
|
||||
//Reset Retromode entries
|
||||
resetRankValue(subSkillType, index, true);
|
||||
|
||||
@@ -3,69 +3,63 @@ package com.gmail.nossr50.config;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
|
||||
public class SoundConfig extends AutoUpdateConfigLoader {
|
||||
public class SoundConfig extends BukkitConfig {
|
||||
private static SoundConfig instance;
|
||||
|
||||
public SoundConfig()
|
||||
{
|
||||
public SoundConfig() {
|
||||
super("sounds.yml");
|
||||
validate();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static SoundConfig getInstance() {
|
||||
if (instance == null)
|
||||
return new SoundConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public static SoundConfig getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
return new SoundConfig();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
for(SoundType soundType : SoundType.values())
|
||||
{
|
||||
if(config.getDouble("Sounds."+soundType.toString()+".Volume") < 0)
|
||||
{
|
||||
mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for "+soundType.toString());
|
||||
return false;
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
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;
|
||||
}
|
||||
|
||||
//Sounds with custom pitching don't use pitch values
|
||||
if(!soundType.usesCustomPitch())
|
||||
{
|
||||
if(config.getDouble("Sounds."+soundType.toString()+".Pitch") < 0)
|
||||
{
|
||||
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for "+soundType.toString());
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
||||
public float getMasterVolume() {
|
||||
return (float) config.getDouble("Sounds.MasterVolume", 1.0);
|
||||
}
|
||||
|
||||
public float getVolume(SoundType soundType)
|
||||
{
|
||||
String key = "Sounds."+soundType.toString()+".Volume";
|
||||
public float getVolume(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Volume";
|
||||
return (float) config.getDouble(key);
|
||||
}
|
||||
|
||||
public float getPitch(SoundType soundType)
|
||||
{
|
||||
String key = "Sounds."+soundType.toString()+".Pitch";
|
||||
public float getPitch(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Pitch";
|
||||
return (float) config.getDouble(key);
|
||||
}
|
||||
|
||||
public boolean getIsEnabled(SoundType soundType)
|
||||
{
|
||||
String key = "Sounds."+soundType.toString()+".Enabled";
|
||||
public boolean getIsEnabled(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Enabled";
|
||||
return config.getBoolean(key, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,20 +15,28 @@ public class WorldBlacklist {
|
||||
|
||||
private final String blackListFileName = "world_blacklist.txt";
|
||||
|
||||
public WorldBlacklist(mcMMO plugin)
|
||||
{
|
||||
public WorldBlacklist(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
blacklist = new ArrayList<>();
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
public static boolean isWorldBlacklisted(World world) {
|
||||
|
||||
for (String s : blacklist) {
|
||||
if (world.getName().equalsIgnoreCase(s))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
//Make the blacklist file if it doesn't exist
|
||||
File blackListFile = new File(plugin.getDataFolder() + File.separator + blackListFileName);
|
||||
|
||||
try {
|
||||
if(!blackListFile.exists())
|
||||
if (!blackListFile.exists())
|
||||
blackListFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -48,12 +56,11 @@ public class WorldBlacklist {
|
||||
|
||||
String currentLine;
|
||||
|
||||
while((currentLine = bufferedReader.readLine()) != null)
|
||||
{
|
||||
if(currentLine.length() == 0)
|
||||
while ((currentLine = bufferedReader.readLine()) != null) {
|
||||
if (currentLine.length() == 0)
|
||||
continue;
|
||||
|
||||
if(!blacklist.contains(currentLine))
|
||||
if (!blacklist.contains(currentLine))
|
||||
blacklist.add(currentLine);
|
||||
}
|
||||
|
||||
@@ -66,11 +73,11 @@ public class WorldBlacklist {
|
||||
closeRead(fileReader);
|
||||
}
|
||||
|
||||
plugin.getLogger().info(blacklist.size()+" entries in mcMMO World Blacklist");
|
||||
plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
|
||||
}
|
||||
|
||||
private void closeRead(Reader reader) {
|
||||
if(reader != null) {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
@@ -78,16 +85,4 @@ public class WorldBlacklist {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWorldBlacklisted(World world)
|
||||
{
|
||||
|
||||
for(String s : blacklist)
|
||||
{
|
||||
if(world.getName().equalsIgnoreCase(s))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.gmail.nossr50.config.experience;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
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;
|
||||
@@ -13,16 +14,17 @@ 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 AutoUpdateConfigLoader {
|
||||
public class ExperienceConfig extends BukkitConfig {
|
||||
private static ExperienceConfig instance;
|
||||
|
||||
private ExperienceConfig() {
|
||||
super("experience.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static ExperienceConfig getInstance() {
|
||||
@@ -34,10 +36,17 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
public void initDefaults() {
|
||||
super.initDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
protected void loadKeys() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
List<String> reason = new ArrayList<>();
|
||||
|
||||
/*
|
||||
@@ -45,41 +54,48 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
*/
|
||||
|
||||
/* Curve values */
|
||||
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
|
||||
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
|
||||
}
|
||||
final BiConsumer<String, Object> consumer = (String str, Object obj) -> config.set(str, obj);
|
||||
|
||||
if (getMultiplier(FormulaType.LINEAR) <= 0) {
|
||||
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 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) {
|
||||
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 (getExponent(FormulaType.EXPONENTIAL) <= 0) {
|
||||
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 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);
|
||||
}
|
||||
|
||||
/* Global modifier */
|
||||
if (getExperienceGainsGlobalMultiplier() <= 0) {
|
||||
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Formula.Multiplier.Global should be at least 0!");
|
||||
config.set("Experience_Formula.Multiplier.Global", 1.0);
|
||||
|
||||
}
|
||||
|
||||
/* PVP modifier */
|
||||
if (getPlayerVersusPlayerXP() < 0) {
|
||||
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Formula.Multiplier.PVP should be at least 0!");
|
||||
}
|
||||
|
||||
/* Spawned Mob modifier */
|
||||
if (getSpawnedMobXpMultiplier() < 0) {
|
||||
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
|
||||
}
|
||||
|
||||
/* Bred Mob modifier */
|
||||
if (getBredMobXpMultiplier() < 0) {
|
||||
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Formula.Breeding.Multiplier should be at least 0!");
|
||||
}
|
||||
|
||||
/* Conversion */
|
||||
if (getExpModifier() <= 0) {
|
||||
reason.add("Conversion.Exp_Modifier should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Conversion.Exp_Modifier should be greater than 0!");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -89,131 +105,230 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
/* Alchemy */
|
||||
for (PotionStage potionStage : PotionStage.values()) {
|
||||
if (getPotionXP(potionStage) < 0) {
|
||||
reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
|
||||
}
|
||||
}
|
||||
|
||||
/* Archery */
|
||||
if (getArcheryDistanceMultiplier() < 0) {
|
||||
reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
|
||||
}
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
if (getAnimalsXP() < 0) {
|
||||
reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
|
||||
}
|
||||
|
||||
if (getDodgeXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getRollXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFallXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
|
||||
mcMMO.p.getLogger().warning("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) {
|
||||
reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Fishing.Shake should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Repair */
|
||||
if (getRepairXPBase() <= 0) {
|
||||
reason.add("Experience_Values.Repair.Base should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Repair.Base should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Taming */
|
||||
if (getTamingXP(EntityType.WOLF) <= 0) {
|
||||
reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getTamingXP(EntityType.OCELOT) <= 0) {
|
||||
reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); }
|
||||
public boolean isEarlyGameBoostEnabled() {
|
||||
return config.getBoolean("EarlyGameBoost.Enabled", true);
|
||||
}
|
||||
|
||||
/*
|
||||
* FORMULA SETTINGS
|
||||
*/
|
||||
|
||||
/* EXPLOIT TOGGLES */
|
||||
public boolean isSnowExploitPrevented() { return config.getBoolean("ExploitFix.SnowGolemExcavation", true); }
|
||||
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
|
||||
public boolean isPistonCheatingPrevented() { return config.getBoolean("ExploitFix.PistonCheating", true); }
|
||||
public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
|
||||
public boolean allowUnsafeEnchantments() { return config.getBoolean("ExploitFix.UnsafeEnchantments", false); }
|
||||
public boolean isCOTWBreedingPrevented() { return config.getBoolean("ExploitFix.COTWBreeding", true); }
|
||||
public boolean isNPCInteractionPrevented() { return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true); }
|
||||
public boolean isSnowExploitPrevented() {
|
||||
return config.getBoolean("ExploitFix.SnowGolemExcavation", true);
|
||||
}
|
||||
|
||||
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
|
||||
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
|
||||
public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); }
|
||||
public boolean isEndermanEndermiteFarmingPrevented() {
|
||||
return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true);
|
||||
}
|
||||
|
||||
public boolean isPistonCheatingPrevented() {
|
||||
return config.getBoolean("ExploitFix.PistonCheating", true);
|
||||
}
|
||||
|
||||
public boolean isPistonExploitPrevented() {
|
||||
return config.getBoolean("ExploitFix.Pistons", false);
|
||||
}
|
||||
|
||||
public boolean allowUnsafeEnchantments() {
|
||||
return config.getBoolean("ExploitFix.UnsafeEnchantments", false);
|
||||
}
|
||||
|
||||
public boolean isCOTWBreedingPrevented() {
|
||||
return config.getBoolean("ExploitFix.COTWBreeding", true);
|
||||
}
|
||||
|
||||
public boolean isNPCInteractionPrevented() {
|
||||
return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true);
|
||||
}
|
||||
|
||||
public boolean isFishingExploitingPrevented() {
|
||||
return config.getBoolean("ExploitFix.Fishing", true);
|
||||
}
|
||||
|
||||
public int getFishingExploitingOptionMoveRange() {
|
||||
return config.getInt("Fishing_ExploitFix_Options.MoveRange", 3);
|
||||
}
|
||||
|
||||
public int getFishingExploitingOptionOverFishLimit() {
|
||||
return config.getInt("Fishing_ExploitFix_Options.OverFishLimit", 10);
|
||||
}
|
||||
|
||||
public boolean isAcrobaticsExploitingPrevented() {
|
||||
return config.getBoolean("ExploitFix.Acrobatics", true);
|
||||
}
|
||||
|
||||
public boolean isTreeFellerXPReduced() {
|
||||
return config.getBoolean("ExploitFix.TreeFellerReducedXP", true);
|
||||
}
|
||||
|
||||
/* Curve settings */
|
||||
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
|
||||
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
|
||||
public FormulaType getFormulaType() {
|
||||
return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve"));
|
||||
}
|
||||
|
||||
public boolean getCumulativeCurveEnabled() {
|
||||
return config.getBoolean("Experience_Formula.Cumulative_Curve", false);
|
||||
}
|
||||
|
||||
/* Curve values */
|
||||
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
|
||||
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
|
||||
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
|
||||
public double getMultiplier(FormulaType type) {
|
||||
return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier");
|
||||
}
|
||||
|
||||
public int getBase(FormulaType type) {
|
||||
return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base");
|
||||
}
|
||||
|
||||
public double getExponent(FormulaType type) {
|
||||
return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent");
|
||||
}
|
||||
|
||||
/* Global modifier */
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
|
||||
public double getExperienceGainsGlobalMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Multiplier.Global", 1.0);
|
||||
}
|
||||
|
||||
public void setExperienceGainsGlobalMultiplier(double value) {
|
||||
config.set("Experience_Formula.Multiplier.Global", value);
|
||||
}
|
||||
|
||||
/* PVP modifier */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
|
||||
public double getPlayerVersusPlayerXP() {
|
||||
return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0);
|
||||
}
|
||||
|
||||
/* Spawned Mob modifier */
|
||||
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
||||
public double getEggXpMultiplier() { return config.getDouble("Experience_Formula.Eggs.Multiplier", 0.0); }
|
||||
public double getTamedMobXpMultiplier() { return config.getDouble("Experience_Formula.Player_Tamed.Multiplier", 0.0); }
|
||||
public double getNetherPortalXpMultiplier() { return config.getDouble("Experience_Formula.Nether_Portal.Multiplier", 0.0); }
|
||||
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
|
||||
public double getSpawnedMobXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getEggXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Eggs.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getTamedMobXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Player_Tamed.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getNetherPortalXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Nether_Portal.Multiplier", 0.0);
|
||||
}
|
||||
|
||||
public double getBredMobXpMultiplier() {
|
||||
return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0);
|
||||
}
|
||||
|
||||
/* Skill modifiers */
|
||||
public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
public double getFormulaSkillModifier(PrimarySkillType skill) {
|
||||
return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()));
|
||||
}
|
||||
|
||||
/* Custom XP perk */
|
||||
public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
|
||||
public double getCustomXpPerkBoost() {
|
||||
return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25);
|
||||
}
|
||||
|
||||
/* Diminished Returns */
|
||||
public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
|
||||
public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
|
||||
public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
|
||||
public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
|
||||
public float getDiminishedReturnsCap() {
|
||||
return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D);
|
||||
}
|
||||
|
||||
public boolean getDiminishedReturnsEnabled() {
|
||||
return config.getBoolean("Diminished_Returns.Enabled", false);
|
||||
}
|
||||
|
||||
public int getDiminishedReturnsThreshold(PrimarySkillType skill) {
|
||||
return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000);
|
||||
}
|
||||
|
||||
public int getDiminishedReturnsTimeInterval() {
|
||||
return config.getInt("Diminished_Returns.Time_Interval", 10);
|
||||
}
|
||||
|
||||
/* Conversion */
|
||||
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
|
||||
public double getExpModifier() {
|
||||
return config.getDouble("Conversion.Exp_Modifier", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() {
|
||||
return config.getBoolean("Experience_Values.PVP.Rewards", true);
|
||||
}
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
|
||||
public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); }
|
||||
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
public double getCombatXP(EntityType entity) {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
|
||||
}
|
||||
|
||||
public double getAnimalsXP(EntityType entity) {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP());
|
||||
}
|
||||
|
||||
public double getAnimalsXP() {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0);
|
||||
}
|
||||
|
||||
public boolean hasCombatXP(EntityType entity) {
|
||||
return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Material material)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, Material material) {
|
||||
//TODO: Temporary measure to fix an exploit caused by a yet to be fixed Spigot bug (as of 7/3/2020)
|
||||
if(material.toString().equalsIgnoreCase("LILY_PAD"))
|
||||
if (material.toString().equalsIgnoreCase("LILY_PAD"))
|
||||
return 0;
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@@ -230,8 +345,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockState blockState)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, BlockState blockState) {
|
||||
Material data = blockState.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@@ -248,8 +362,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Block block)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, Block block) {
|
||||
Material data = block.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@@ -266,8 +379,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockData data)
|
||||
{
|
||||
public int getXp(PrimarySkillType skill, BlockData data) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
@@ -281,8 +393,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
|
||||
{
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
@@ -294,8 +405,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return config.contains(wildcardString);
|
||||
}
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
|
||||
{
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
@@ -311,32 +421,35 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
* Experience Bar Stuff
|
||||
*/
|
||||
|
||||
public boolean isPartyExperienceBarsEnabled()
|
||||
{
|
||||
public boolean isPartyExperienceBarsEnabled() {
|
||||
return config.getBoolean("Experience_Bars.Update.Party", true);
|
||||
}
|
||||
|
||||
public boolean isPassiveGainsExperienceBarsEnabled()
|
||||
{
|
||||
public boolean isPassiveGainsExperienceBarsEnabled() {
|
||||
return config.getBoolean("Experience_Bars.Update.Passive", true);
|
||||
}
|
||||
|
||||
public boolean getDoExperienceBarsAlwaysUpdateTitle()
|
||||
{
|
||||
public boolean getDoExperienceBarsAlwaysUpdateTitle() {
|
||||
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
|
||||
}
|
||||
|
||||
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
|
||||
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
|
||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
|
||||
public boolean getAddExtraDetails() {
|
||||
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);
|
||||
}
|
||||
|
||||
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
|
||||
{
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color");
|
||||
public boolean isExperienceBarsEnabled() {
|
||||
return config.getBoolean("Experience_Bars.Enable", true);
|
||||
}
|
||||
|
||||
for(BarColor barColor : BarColor.values())
|
||||
{
|
||||
if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) {
|
||||
return config.getBoolean("Experience_Bars." + StringUtils.getCapitalized(primarySkillType.toString()) + ".Enable", true);
|
||||
}
|
||||
|
||||
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars." + StringUtils.getCapitalized(primarySkillType.toString()) + ".Color");
|
||||
|
||||
for (BarColor barColor : BarColor.values()) {
|
||||
if (barColor.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
return barColor;
|
||||
}
|
||||
|
||||
@@ -344,13 +457,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return BarColor.WHITE;
|
||||
}
|
||||
|
||||
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
|
||||
{
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
|
||||
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars." + StringUtils.getCapitalized(primarySkillType.toString()) + ".BarStyle");
|
||||
|
||||
for(BarStyle barStyle : BarStyle.values())
|
||||
{
|
||||
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
for (BarStyle barStyle : BarStyle.values()) {
|
||||
if (barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
return barStyle;
|
||||
}
|
||||
|
||||
@@ -359,29 +470,51 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Acrobatics */
|
||||
public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
|
||||
public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); }
|
||||
public int getDodgeXPModifier() {
|
||||
return config.getInt("Experience_Values.Acrobatics.Dodge", 120);
|
||||
}
|
||||
|
||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||
public int getRollXPModifier() {
|
||||
return config.getInt("Experience_Values.Acrobatics.Roll", 80);
|
||||
}
|
||||
|
||||
public int getFallXPModifier() {
|
||||
return config.getInt("Experience_Values.Acrobatics.Fall", 120);
|
||||
}
|
||||
|
||||
public double getFeatherFallXPModifier() {
|
||||
return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0);
|
||||
}
|
||||
|
||||
/* Alchemy */
|
||||
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
|
||||
public double getPotionXP(PotionStage stage) {
|
||||
return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D);
|
||||
}
|
||||
|
||||
/* Archery */
|
||||
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); }
|
||||
public double getArcheryDistanceMultiplier() {
|
||||
return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025);
|
||||
}
|
||||
|
||||
public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); }
|
||||
public int getFishingShakeXP() {
|
||||
return config.getInt("Experience_Values.Fishing.Shake", 50);
|
||||
}
|
||||
|
||||
/* Repair */
|
||||
public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); }
|
||||
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||
public double getRepairXPBase() {
|
||||
return config.getDouble("Experience_Values.Repair.Base", 1000.0);
|
||||
}
|
||||
|
||||
public double getRepairXP(MaterialType repairMaterialType) {
|
||||
return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString()));
|
||||
}
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXP(EntityType type)
|
||||
{
|
||||
public int getTamingXP(EntityType type) {
|
||||
return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
|
||||
}
|
||||
|
||||
public boolean preventStoneLavaFarming() { return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);}
|
||||
public boolean preventStoneLavaFarming() {
|
||||
return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,12 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customBoots = new ArrayList<>();
|
||||
public List<Material> customBoots = new ArrayList<>();
|
||||
public List<Material> customChestplates = new ArrayList<>();
|
||||
public List<Material> customHelmets = new ArrayList<>();
|
||||
public List<Material> customLeggings = new ArrayList<>();
|
||||
|
||||
public List<Material> customHelmets = new ArrayList<>();
|
||||
public List<Material> customLeggings = new ArrayList<>();
|
||||
public List<Repairable> repairables = new ArrayList<>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
protected CustomArmorConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
|
||||
@@ -12,17 +12,15 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
public List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
public List<Material> customMiningBlocks = new ArrayList<>();
|
||||
public List<Material> customOres = new ArrayList<>();
|
||||
public List<Material> customLogs = new ArrayList<>();
|
||||
public List<Material> customLeaves = new ArrayList<>();
|
||||
public List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
|
||||
public List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
public List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
public List<Material> customMiningBlocks = new ArrayList<>();
|
||||
public List<Material> customOres = new ArrayList<>();
|
||||
public List<Material> customLogs = new ArrayList<>();
|
||||
public List<Material> customLeaves = new ArrayList<>();
|
||||
public List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
protected CustomBlockConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
@@ -85,12 +83,10 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterial);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
} else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockMaterial);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
customLeaves.add(blockMaterial);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.HashMap;
|
||||
|
||||
public class CustomEntityConfig extends ConfigLoader {
|
||||
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>();
|
||||
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
|
||||
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
|
||||
|
||||
protected CustomEntityConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
@@ -31,8 +31,7 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
|
||||
try {
|
||||
clazz = ClassUtils.getClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
mcMMO.p.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
|
||||
mcMMO.p.getLogger().warning("This custom entity may not function properly.");
|
||||
}
|
||||
|
||||
@@ -16,18 +16,15 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customAxes = new ArrayList<>();
|
||||
public List<Material> customBows = new ArrayList<>();
|
||||
public List<Material> customHoes = new ArrayList<>();
|
||||
public List<Material> customAxes = new ArrayList<>();
|
||||
public List<Material> customBows = new ArrayList<>();
|
||||
public List<Material> customHoes = new ArrayList<>();
|
||||
public List<Material> customPickaxes = new ArrayList<>();
|
||||
public List<Material> customShovels = new ArrayList<>();
|
||||
public List<Material> customSwords = new ArrayList<>();
|
||||
|
||||
public List<Material> customShovels = new ArrayList<>();
|
||||
public List<Material> customSwords = new ArrayList<>();
|
||||
public HashMap<Material, CustomTool> customToolMap = new HashMap<>();
|
||||
|
||||
public List<Repairable> repairables = new ArrayList<>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
protected CustomToolConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ItemWeightConfig extends ConfigLoader {
|
||||
public class ItemWeightConfig extends BukkitConfig {
|
||||
private static ItemWeightConfig instance;
|
||||
|
||||
private ItemWeightConfig() {
|
||||
@@ -22,6 +22,11 @@ public class ItemWeightConfig extends ConfigLoader {
|
||||
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"));
|
||||
}
|
||||
@@ -40,5 +45,6 @@ public class ItemWeightConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
protected void loadKeys() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +95,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
if (potion != null) {
|
||||
potionMap.put(potionName, potion);
|
||||
pass++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
@@ -114,13 +113,13 @@ public class PotionConfig extends ConfigLoader {
|
||||
*/
|
||||
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
String name = potion_section.getString("Name");
|
||||
if (name != null) {
|
||||
name = ChatColor.translateAlternateColorCodes('&', name);
|
||||
}
|
||||
|
||||
|
||||
PotionData data;
|
||||
if (!potion_section.contains("PotionData")) { // Backwards config compatability
|
||||
short dataValue = Short.parseShort(potion_section.getName());
|
||||
@@ -130,7 +129,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
|
||||
data = new PotionData(PotionType.valueOf(potionData.getString("PotionType", "WATER")), potionData.getBoolean("Extended", false), potionData.getBoolean("Upgraded", false));
|
||||
}
|
||||
|
||||
|
||||
Material material = Material.POTION;
|
||||
String mat = potion_section.getString("Material", null);
|
||||
if (mat != null) {
|
||||
@@ -155,18 +154,16 @@ public class PotionConfig extends ConfigLoader {
|
||||
|
||||
if (type != null) {
|
||||
effects.add(new PotionEffect(type, duration, amplifier));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse effect for potion " + name + ": " + effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Color color;
|
||||
if (potion_section.contains("Color")) {
|
||||
color = Color.fromRGB(potion_section.getInt("Color"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
color = this.generateColor(effects);
|
||||
}
|
||||
|
||||
@@ -176,16 +173,14 @@ public class PotionConfig extends ConfigLoader {
|
||||
ItemStack ingredient = loadIngredient(child);
|
||||
if (ingredient != null) {
|
||||
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new AlchemyPotion(material, data, name, lore, effects, color, children);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
||||
return null;
|
||||
}
|
||||
@@ -243,7 +238,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
public AlchemyPotion getPotion(String name) {
|
||||
return potionMap.get(name);
|
||||
}
|
||||
|
||||
|
||||
public AlchemyPotion getPotion(ItemStack item) {
|
||||
for (AlchemyPotion potion : potionMap.values()) {
|
||||
if (potion.isSimilar(item)) {
|
||||
@@ -252,7 +247,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Color generateColor(List<PotionEffect> effects) {
|
||||
if (effects != null && !effects.isEmpty()) {
|
||||
List<Color> colors = new ArrayList<>();
|
||||
@@ -270,7 +265,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Color calculateAverageColor(List<Color> colors) {
|
||||
int red = 0;
|
||||
int green = 0;
|
||||
@@ -280,7 +275,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
green += color.getGreen();
|
||||
blue += color.getBlue();
|
||||
}
|
||||
return Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size());
|
||||
return Color.fromRGB(red / colors.size(), green / colors.size(), blue / colors.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -13,9 +13,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private List<Repairable> repairables;
|
||||
public class RepairConfig extends BukkitConfig {
|
||||
private final HashSet<String> notSupported;
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(String fileName) {
|
||||
super(fileName);
|
||||
@@ -23,6 +23,11 @@ public class RepairConfig extends ConfigLoader {
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<>();
|
||||
@@ -62,34 +67,26 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isWoodTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(repairItem)) {
|
||||
} else if (ItemUtils.isStoneTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.STONE;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(repairItem)) {
|
||||
} else if (ItemUtils.isStringTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.STRING;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(repairItem)) {
|
||||
} else if (ItemUtils.isLeatherArmor(repairItem)) {
|
||||
repairMaterialType = MaterialType.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
||||
} else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.IRON;
|
||||
}
|
||||
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
||||
} else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.GOLD;
|
||||
}
|
||||
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
||||
} else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.DIAMOND;
|
||||
} else if (ItemUtils.isNetheriteArmor(repairItem) || ItemUtils.isNetheriteTool(repairItem)) {
|
||||
repairMaterialType = MaterialType.NETHERITE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mcMMO.p.getLogger().warning(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +107,7 @@ public class RepairConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (maximumDurability <= 0) {
|
||||
reason.add("Maximum durability of " + key + " must be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Maximum durability of " + key + " must be greater than 0!");
|
||||
}
|
||||
|
||||
// Item Type
|
||||
@@ -122,17 +119,14 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isMinecraftTool(repairItem)) {
|
||||
repairItemType = ItemType.TOOL;
|
||||
}
|
||||
else if (ItemUtils.isArmor(repairItem)) {
|
||||
} else if (ItemUtils.isArmor(repairItem)) {
|
||||
repairItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
repairItemType = ItemType.valueOf(repairItemTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mcMMO.p.getLogger().warning(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,13 +134,13 @@ public class RepairConfig extends ConfigLoader {
|
||||
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
|
||||
|
||||
if (minimumLevel < 0) {
|
||||
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
mcMMO.p.getLogger().warning(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
}
|
||||
|
||||
// Minimum Quantity
|
||||
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity");
|
||||
|
||||
if(minimumQuantity == 0) {
|
||||
if (minimumQuantity == 0) {
|
||||
minimumQuantity = -1;
|
||||
}
|
||||
|
||||
@@ -158,13 +152,13 @@ public class RepairConfig extends ConfigLoader {
|
||||
//Report unsupported
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
if(notSupported.size() > 0) {
|
||||
if (notSupported.size() > 0) {
|
||||
stringBuilder.append("mcMMO found the following materials in the Repair config that are not supported by the version of Minecraft running on this server: ");
|
||||
|
||||
for (Iterator<String> iterator = notSupported.iterator(); iterator.hasNext(); ) {
|
||||
String unsupportedMaterial = iterator.next();
|
||||
|
||||
if(!iterator.hasNext()) {
|
||||
if (!iterator.hasNext()) {
|
||||
stringBuilder.append(unsupportedMaterial);
|
||||
} else {
|
||||
stringBuilder.append(unsupportedMaterial).append(", ");
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package com.gmail.nossr50.config.skills.repair;
|
||||
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.FixSpellingNetheriteUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private final List<Repairable> repairables = new ArrayList<>();
|
||||
public static final String REPAIR_VANILLA_YML = "repair.vanilla.yml";
|
||||
private static final Collection<Repairable> repairables = new HashSet<>();
|
||||
|
||||
public RepairConfigManager(mcMMO plugin) {
|
||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("repair.vanilla.yml", false);
|
||||
}
|
||||
RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML);
|
||||
repairables.addAll(mainRepairConfig.getLoadedRepairables());
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if(fileName.equals(REPAIR_VANILLA_YML))
|
||||
continue;
|
||||
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
@@ -33,19 +33,12 @@ public class RepairConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_SPELLING_NETHERITE_REPAIR)) {
|
||||
//Check spelling mistakes (early versions of 1.16 support had Netherite misspelled)
|
||||
plugin.getLogger().info("Checking for certain invalid material names in Repair config...");
|
||||
FixSpellingNetheriteUtil.processFileCheck(mcMMO.p, fileName, UpgradeType.FIX_SPELLING_NETHERITE_REPAIR);
|
||||
}
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(fileName);
|
||||
repairables.addAll(rConfig.getLoadedRepairables());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
public Collection<Repairable> getLoadedRepairables() {
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
@@ -16,9 +16,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class SalvageConfig extends ConfigLoader {
|
||||
private List<Salvageable> salvageables;
|
||||
public class SalvageConfig extends BukkitConfig {
|
||||
private final HashSet<String> notSupported;
|
||||
private Set<Salvageable> salvageables;
|
||||
|
||||
public SalvageConfig(String fileName) {
|
||||
super(fileName);
|
||||
@@ -26,9 +26,14 @@ public class SalvageConfig extends ConfigLoader {
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
salvageables = new ArrayList<>();
|
||||
salvageables = new HashSet<>();
|
||||
|
||||
if (!config.isConfigurationSection("Salvageables")) {
|
||||
mcMMO.p.getLogger().severe("Could not find Salvageables section in " + fileName);
|
||||
@@ -40,9 +45,9 @@ public class SalvageConfig extends ConfigLoader {
|
||||
|
||||
//Original version of 1.16 support had maximum quantities that were bad, this fixes it
|
||||
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
|
||||
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
|
||||
mcMMO.p.getLogger().info("Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
|
||||
for(String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
|
||||
for (String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
|
||||
config.set("Salvageables." + namespacedkey.toUpperCase() + ".MaximumQuantity", 4); //TODO: Doesn't make sense to default to 4 for everything
|
||||
}
|
||||
|
||||
@@ -78,34 +83,26 @@ public class SalvageConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isWoodTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(salvageItem)) {
|
||||
} else if (ItemUtils.isStoneTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.STONE;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(salvageItem)) {
|
||||
} else if (ItemUtils.isStringTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.STRING;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
||||
} else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
||||
} else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.IRON;
|
||||
}
|
||||
else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
||||
} else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.GOLD;
|
||||
}
|
||||
else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
||||
} else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.DIAMOND;
|
||||
} else if (ItemUtils.isNetheriteTool(salvageItem) || ItemUtils.isNetheriteArmor(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.NETHERITE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mcMMO.p.getLogger().warning(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,17 +127,14 @@ public class SalvageConfig extends ConfigLoader {
|
||||
|
||||
if (ItemUtils.isMinecraftTool(salvageItem)) {
|
||||
salvageItemType = ItemType.TOOL;
|
||||
}
|
||||
else if (ItemUtils.isArmor(salvageItem)) {
|
||||
} else if (ItemUtils.isArmor(salvageItem)) {
|
||||
salvageItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mcMMO.p.getLogger().warning(key + " has an invalid ItemType of " + salvageItemTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +142,7 @@ public class SalvageConfig extends ConfigLoader {
|
||||
double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1);
|
||||
|
||||
if (minimumLevel < 0) {
|
||||
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
mcMMO.p.getLogger().warning(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
}
|
||||
|
||||
// Maximum Quantity
|
||||
@@ -165,7 +159,7 @@ public class SalvageConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (maximumQuantity <= 0) {
|
||||
reason.add("Maximum quantity of " + key + " must be greater than 0!");
|
||||
mcMMO.p.getLogger().warning("Maximum quantity of " + key + " must be greater than 0!");
|
||||
}
|
||||
|
||||
if (noErrorsInSalvageable(reason)) {
|
||||
@@ -176,13 +170,13 @@ public class SalvageConfig extends ConfigLoader {
|
||||
//Report unsupported
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
if(notSupported.size() > 0) {
|
||||
if (notSupported.size() > 0) {
|
||||
stringBuilder.append("mcMMO found the following materials in the Salvage config that are not supported by the version of Minecraft running on this server: ");
|
||||
|
||||
for (Iterator<String> iterator = notSupported.iterator(); iterator.hasNext(); ) {
|
||||
String unsupportedMaterial = iterator.next();
|
||||
|
||||
if(!iterator.hasNext()) {
|
||||
if (!iterator.hasNext()) {
|
||||
stringBuilder.append(unsupportedMaterial);
|
||||
} else {
|
||||
stringBuilder.append(unsupportedMaterial).append(", ");
|
||||
@@ -194,8 +188,8 @@ public class SalvageConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables == null ? new ArrayList<>() : salvageables;
|
||||
protected Collection<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables == null ? new HashSet<>() : salvageables;
|
||||
}
|
||||
|
||||
private boolean noErrorsInSalvageable(List<String> issues) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.util.FixSpellingNetheriteUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -11,18 +9,21 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SalvageConfigManager {
|
||||
private final List<Salvageable> salvageables = new ArrayList<>();
|
||||
public static final String SALVAGE_VANILLA_YML = "salvage.vanilla.yml";
|
||||
private final List<Salvageable> salvageables = new ArrayList<>(); //TODO: Collision checking, make the list a set
|
||||
|
||||
|
||||
public SalvageConfigManager(mcMMO plugin) {
|
||||
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "salvage.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("salvage.vanilla.yml", false);
|
||||
}
|
||||
SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML);
|
||||
salvageables.addAll(mainSalvageConfig.getLoadedSalvageables());
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if(fileName.equals(SALVAGE_VANILLA_YML))
|
||||
continue;
|
||||
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
@@ -33,20 +34,12 @@ public class SalvageConfigManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_SPELLING_NETHERITE_SALVAGE)) {
|
||||
//Check spelling mistakes (early versions of 1.16 support had Netherite misspelled)
|
||||
plugin.getLogger().info("Checking for certain invalid material names in Salvage config...");
|
||||
FixSpellingNetheriteUtil.processFileCheck(mcMMO.p, fileName, UpgradeType.FIX_SPELLING_NETHERITE_SALVAGE);
|
||||
}
|
||||
|
||||
|
||||
SalvageConfig salvageConfig = new SalvageConfig(fileName);
|
||||
salvageables.addAll(salvageConfig.getLoadedSalvageables());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables;
|
||||
return new ArrayList<>(salvageables);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.treasure.*;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
@@ -18,19 +18,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FishingTreasureConfig extends ConfigLoader {
|
||||
public class FishingTreasureConfig extends BukkitConfig {
|
||||
|
||||
public static final String FILENAME = "fishing_treasures.yml";
|
||||
private static FishingTreasureConfig instance;
|
||||
|
||||
public @NotNull HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
|
||||
public @NotNull HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
|
||||
public @NotNull HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
|
||||
public @NotNull HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
|
||||
public @NotNull HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
|
||||
|
||||
private FishingTreasureConfig() {
|
||||
super(FILENAME);
|
||||
loadKeys();
|
||||
validate();
|
||||
}
|
||||
|
||||
public static FishingTreasureConfig getInstance() {
|
||||
@@ -42,39 +41,43 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
List<String> reason = new ArrayList<>();
|
||||
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
|
||||
double totalEnchantDropRate = 0;
|
||||
double totalItemDropRate = 0;
|
||||
ConfigurationSection enchantment_drop_rates = config.getConfigurationSection("Enchantment_Drop_Rates");
|
||||
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
|
||||
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity.toString());
|
||||
if(enchantment_drop_rates != null) {
|
||||
for (String tier : enchantment_drop_rates.getKeys(false)) {
|
||||
double totalEnchantDropRate = 0;
|
||||
double totalItemDropRate = 0;
|
||||
|
||||
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) {
|
||||
reason.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
|
||||
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity);
|
||||
|
||||
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) {
|
||||
mcMMO.p.getLogger().warning("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!");
|
||||
}
|
||||
|
||||
totalEnchantDropRate += enchantDropRate;
|
||||
totalItemDropRate += itemDropRate;
|
||||
}
|
||||
|
||||
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
|
||||
reason.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
||||
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
||||
mcMMO.p.getLogger().warning("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
}
|
||||
|
||||
totalEnchantDropRate += enchantDropRate;
|
||||
totalItemDropRate += itemDropRate;
|
||||
}
|
||||
|
||||
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
||||
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
}
|
||||
|
||||
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
||||
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
|
||||
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
||||
mcMMO.p.getLogger().warning("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
|
||||
@@ -89,7 +92,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
|
||||
for (EntityType entity : EntityType.values()) {
|
||||
if (entity.isAlive()) {
|
||||
loadTreasures("Shake." + entity.toString());
|
||||
loadTreasures("Shake." + entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +138,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||
|
||||
if (material == null) {
|
||||
reason.add("Cannot find matching item type in this version of MC, skipping - " + materialName);
|
||||
mcMMO.p.getLogger().warning("Cannot find matching item type in this version of MC, skipping - " + materialName);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -144,7 +147,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (material.isBlock() && (data > 127 || data < -128)) {
|
||||
reason.add("Data of " + treasureName + " is invalid! " + data);
|
||||
mcMMO.p.getLogger().warning("Data of " + treasureName + " is invalid! " + data);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -156,15 +159,15 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
|
||||
|
||||
if (xp < 0) {
|
||||
reason.add(treasureName + " has an invalid XP value: " + xp);
|
||||
mcMMO.p.getLogger().warning(treasureName + " has an invalid XP value: " + xp);
|
||||
}
|
||||
|
||||
if (dropChance < 0.0D) {
|
||||
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||
mcMMO.p.getLogger().warning(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||
}
|
||||
|
||||
if (dropLevel < 0) {
|
||||
reason.add("Fishing Config: " + treasureName + " has an invalid Drop_Level: " + dropLevel);
|
||||
mcMMO.p.getLogger().warning("Fishing Config: " + treasureName + " has an invalid Drop_Level: " + dropLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -175,7 +178,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
if (isFishing) {
|
||||
String rarityStr = config.getString(type + "." + treasureName + ".Rarity");
|
||||
|
||||
if(rarityStr != null) {
|
||||
if (rarityStr != null) {
|
||||
rarity = Rarity.getRarity(rarityStr);
|
||||
} else {
|
||||
mcMMO.p.getLogger().severe("Please edit your config and add a Rarity definition for - " + treasureName);
|
||||
@@ -192,19 +195,19 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
|
||||
String customName = null;
|
||||
|
||||
if(hasCustomName(type, treasureName)) {
|
||||
if (hasCustomName(type, treasureName)) {
|
||||
customName = config.getString(type + "." + treasureName + ".Custom_Name");
|
||||
}
|
||||
|
||||
if (materialName.contains("POTION")) {
|
||||
Material mat = Material.matchMaterial(materialName);
|
||||
if (mat == null) {
|
||||
reason.add("Potion format for " + FILENAME + " has changed");
|
||||
mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
|
||||
} else {
|
||||
item = new ItemStack(mat, amount, data);
|
||||
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
if(itemMeta == null) {
|
||||
if (itemMeta == null) {
|
||||
mcMMO.p.getLogger().severe("Item meta when adding potion to fishing treasure was null, contact the mcMMO devs!");
|
||||
continue;
|
||||
}
|
||||
@@ -213,7 +216,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
try {
|
||||
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
mcMMO.p.getLogger().warning("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);
|
||||
@@ -232,7 +235,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
} else if(material == Material.ENCHANTED_BOOK) {
|
||||
} else if (material == Material.ENCHANTED_BOOK) {
|
||||
//If any whitelisted enchants exist we use whitelist-based matching
|
||||
item = new ItemStack(material, 1);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
@@ -276,16 +279,15 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,26 +309,27 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
/**
|
||||
* Matches enchantments on a list (user provided string) to known enchantments in the Spigot API
|
||||
* Any matches are added to the passed set
|
||||
*
|
||||
* @param enchantListStr the users string list of enchantments
|
||||
* @param permissiveList the permissive list of enchantments
|
||||
*/
|
||||
private void matchAndFillSet(@NotNull List<String> enchantListStr, @NotNull Set<Enchantment> permissiveList) {
|
||||
if(enchantListStr.isEmpty()) {
|
||||
if (enchantListStr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(String str : enchantListStr) {
|
||||
for (String str : enchantListStr) {
|
||||
boolean foundMatch = false;
|
||||
for(Enchantment enchantment : Enchantment.values()) {
|
||||
if(enchantment.getKey().getKey().equalsIgnoreCase(str)) {
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
if (enchantment.getKey().getKey().equalsIgnoreCase(str)) {
|
||||
permissiveList.add(enchantment);
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundMatch) {
|
||||
mcMMO.p.getLogger().info("[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: "+str);
|
||||
if (!foundMatch) {
|
||||
mcMMO.p.getLogger().info("[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +347,7 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
for (String enchantmentName : enchantmentSection.getKeys(false)) {
|
||||
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
|
||||
int level = config.getInt("Enchantments_Rarity." + rarity + "." + enchantmentName);
|
||||
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
||||
|
||||
if (enchantment == null) {
|
||||
@@ -374,10 +377,10 @@ public class FishingTreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
public double getItemDropRate(int tier, @NotNull Rarity rarity) {
|
||||
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
||||
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity);
|
||||
}
|
||||
|
||||
public double getEnchantmentDropRate(int tier, @NotNull Rarity rarity) {
|
||||
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
||||
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TreasureConfig extends ConfigLoader {
|
||||
public class TreasureConfig extends BukkitConfig {
|
||||
|
||||
public static final String FILENAME = "treasures.yml";
|
||||
public static final String LEVEL_REQUIREMENT_RETRO_MODE = ".Level_Requirement.Retro_Mode";
|
||||
@@ -32,12 +32,11 @@ public class TreasureConfig extends ConfigLoader {
|
||||
private static TreasureConfig instance;
|
||||
|
||||
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
|
||||
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
|
||||
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
|
||||
|
||||
private TreasureConfig() {
|
||||
super(FILENAME);
|
||||
loadKeys();
|
||||
validate();
|
||||
}
|
||||
|
||||
public static TreasureConfig getInstance() {
|
||||
@@ -49,11 +48,8 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
List<String> reason = new ArrayList<>();
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +91,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||
|
||||
if (material == null) {
|
||||
reason.add("Invalid material: " + materialName);
|
||||
mcMMO.p.getLogger().warning("Invalid material: " + materialName);
|
||||
}
|
||||
|
||||
if (amount <= 0) {
|
||||
@@ -103,7 +99,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
|
||||
reason.add("Data of " + treasureName + " is invalid! " + data);
|
||||
mcMMO.p.getLogger().warning("Data of " + treasureName + " is invalid! " + data);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,43 +111,43 @@ public class TreasureConfig extends ConfigLoader {
|
||||
DropLevelKeyConversionType conversionType;
|
||||
|
||||
//Check for legacy drop level values and convert
|
||||
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.LEGACY) != -1) {
|
||||
if (getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.LEGACY) != -1) {
|
||||
//Legacy Drop level, needs to be converted
|
||||
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.LEGACY);
|
||||
}
|
||||
|
||||
//Check for a bad key that was accidentally shipped out to some users
|
||||
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD) != -1) {
|
||||
if (getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD) != -1) {
|
||||
//Partially converted to the new system, I had a dyslexic moment so some configs have this
|
||||
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD);
|
||||
}
|
||||
|
||||
//Check for a bad key that was accidentally shipped out to some users
|
||||
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO) != -1) {
|
||||
if (getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO) != -1) {
|
||||
//Partially converted to the new system, I had a dyslexic moment so some configs have this
|
||||
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO);
|
||||
}
|
||||
|
||||
int dropLevel = -1;
|
||||
|
||||
if(mcMMO.isRetroModeEnabled()) {
|
||||
if (mcMMO.isRetroModeEnabled()) {
|
||||
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, -1);
|
||||
} else {
|
||||
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, -1);
|
||||
}
|
||||
|
||||
if(dropLevel == -1) {
|
||||
if (dropLevel == -1) {
|
||||
mcMMO.p.getLogger().severe("Could not find a Level_Requirement entry for treasure " + treasureName);
|
||||
mcMMO.p.getLogger().severe("Skipping treasure");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (xp < 0) {
|
||||
reason.add(treasureName + " has an invalid XP value: " + xp);
|
||||
mcMMO.p.getLogger().warning(treasureName + " has an invalid XP value: " + xp);
|
||||
}
|
||||
|
||||
if (dropChance < 0.0D) {
|
||||
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||
mcMMO.p.getLogger().warning(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -162,7 +158,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
if (materialName.contains("POTION")) {
|
||||
Material mat = Material.matchMaterial(materialName);
|
||||
if (mat == null) {
|
||||
reason.add("Potion format for " + FILENAME + " has changed");
|
||||
mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
|
||||
} else {
|
||||
item = new ItemStack(mat, amount, data);
|
||||
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
||||
@@ -171,7 +167,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
try {
|
||||
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
mcMMO.p.getLogger().warning("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);
|
||||
@@ -210,55 +206,55 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
if (noErrorsInConfig(reason)) {
|
||||
if (isExcavation) {
|
||||
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||
//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");
|
||||
|
||||
for (String blockType : dropList) {
|
||||
if (!excavationMap.containsKey(blockType))
|
||||
excavationMap.put(blockType, new ArrayList<>());
|
||||
excavationMap.get(blockType).add(excavationTreasure);
|
||||
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);
|
||||
|
||||
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
|
||||
continue;
|
||||
}
|
||||
} 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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Apply our fix
|
||||
if(shouldWeUpdateFile) {
|
||||
if (shouldWeUpdateFile) {
|
||||
try {
|
||||
config.save(getFile());
|
||||
} catch (IOException e) {
|
||||
@@ -283,7 +279,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
int wrongKeyValueStandard = getWrongKeyValue(type, treasureName, conversionType);
|
||||
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
|
||||
|
||||
if(wrongKeyValueStandard != -1) {
|
||||
if (wrongKeyValueStandard != -1) {
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, wrongKeyValueStandard);
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueStandard * 10); //Multiply by 10 for Retro
|
||||
}
|
||||
@@ -295,7 +291,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
int wrongKeyValueRetro = getWrongKeyValue(type, treasureName, conversionType);
|
||||
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
|
||||
|
||||
if(wrongKeyValueRetro != -1) {
|
||||
if (wrongKeyValueRetro != -1) {
|
||||
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueRetro);
|
||||
}
|
||||
|
||||
@@ -306,22 +302,12 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
private int getWrongKeyValue(String type, String treasureName, DropLevelKeyConversionType dropLevelKeyConversionType) {
|
||||
switch (dropLevelKeyConversionType) {
|
||||
case LEGACY:
|
||||
return config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
|
||||
case WRONG_KEY_STANDARD:
|
||||
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_STANDARD, -1);
|
||||
case WRONG_KEY_RETRO:
|
||||
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_RETRO, -1);
|
||||
}
|
||||
return switch (dropLevelKeyConversionType) {
|
||||
case LEGACY -> config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
|
||||
case WRONG_KEY_STANDARD -> config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_STANDARD, -1);
|
||||
case WRONG_KEY_RETRO -> config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_RETRO, -1);
|
||||
};
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private enum DropLevelKeyConversionType {
|
||||
LEGACY,
|
||||
WRONG_KEY_STANDARD,
|
||||
WRONG_KEY_RETRO
|
||||
}
|
||||
|
||||
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
|
||||
@@ -329,4 +315,10 @@ public class TreasureConfig extends ConfigLoader {
|
||||
hylianMap.put(dropper, new ArrayList<>());
|
||||
hylianMap.get(dropper).add(treasure);
|
||||
}
|
||||
|
||||
private enum DropLevelKeyConversionType {
|
||||
LEGACY,
|
||||
WRONG_KEY_STANDARD,
|
||||
WRONG_KEY_RETRO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
|
||||
// This code is O(n) instead of O(n²)
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
|
||||
@@ -51,7 +51,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
|
||||
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().getMySQLSSL())
|
||||
if(!mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 17, 0) //Temporary hack for SQL and 1.17 support
|
||||
&& mcMMO.p.getGeneralConfig().getMySQLSSL())
|
||||
connectionString +=
|
||||
"?verifyServerCertificate=false"+
|
||||
"&useSSL=true"+
|
||||
@@ -60,6 +61,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
connectionString+=
|
||||
"?useSSL=false";
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().getMySQLPublicKeyRetrieval()) {
|
||||
connectionString+=
|
||||
"&allowPublicKeyRetrieval=true";
|
||||
}
|
||||
|
||||
try {
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName(driverPath);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.interactions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This class helps define the types of information interactions we will have with players
|
||||
*/
|
||||
@@ -23,14 +25,14 @@ public enum NotificationType {
|
||||
CHAT_ONLY("ChatOnly"),
|
||||
PARTY_MESSAGE("PartyMessage");
|
||||
|
||||
final String niceName;
|
||||
private final String niceName;
|
||||
|
||||
NotificationType(String niceName)
|
||||
{
|
||||
NotificationType(@NotNull String niceName) {
|
||||
this.niceName = niceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public @NotNull String toString() {
|
||||
return niceName;
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,10 +252,10 @@ public class Party {
|
||||
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
}
|
||||
|
||||
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
}
|
||||
|
||||
public boolean hasReachedLevelCap() {
|
||||
@@ -327,7 +327,7 @@ public class Party {
|
||||
}
|
||||
|
||||
public boolean hasMember(String memberName) {
|
||||
return this.getMembers().containsValue(memberName);
|
||||
return this.getMembers().values().stream().anyMatch(memberName::equalsIgnoreCase);
|
||||
}
|
||||
|
||||
public boolean hasMember(UUID uuid) {
|
||||
|
||||
@@ -41,10 +41,7 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -645,7 +642,7 @@ public class McMMOPlayer implements Identified {
|
||||
|
||||
applyXpGain(skill, modifyXpGain(skill, xp), xpGainReason, xpGainSource);
|
||||
|
||||
if (party == null) {
|
||||
if (party == null || party.hasReachedLevelCap()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1137,13 +1134,13 @@ public class McMMOPlayer implements Identified {
|
||||
*/
|
||||
public void logout(boolean syncSave) {
|
||||
Player thisPlayer = getPlayer();
|
||||
if(getPlayer().hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) getPlayer().getMetadata(mcMMO.RUPTURE_META_KEY).get(0);
|
||||
if(getPlayer().hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) getPlayer().getMetadata(MetadataConstants.METADATA_KEY_RUPTURE).get(0);
|
||||
|
||||
//Punish a logout
|
||||
ruptureTaskMeta.getRuptureTimerTask().explode();
|
||||
ruptureTaskMeta.getRuptureTimerTask().explode();
|
||||
ruptureTaskMeta.getRuptureTimerTask().explode();
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
}
|
||||
|
||||
cleanup();
|
||||
|
||||
@@ -43,12 +43,20 @@ public class PlayerProfile {
|
||||
private final Map<PrimarySkillType, Float> rollingSkillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class);
|
||||
|
||||
@Deprecated
|
||||
//TODO: Add deprecated constructor w/o startinglevel
|
||||
public PlayerProfile(String playerName) {
|
||||
this(playerName, null, 0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName, UUID uuid) {
|
||||
this(playerName, uuid, 0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName, int startingLevel) {
|
||||
this(playerName, null, startingLevel);
|
||||
}
|
||||
|
||||
//TODO: Add deprecated constructor w/o startinglevel
|
||||
public PlayerProfile(String playerName, @Nullable UUID uuid, int startingLevel) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
@@ -80,7 +88,7 @@ public class PlayerProfile {
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
public PlayerProfile(@NotNull String playerName, UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) {
|
||||
public PlayerProfile(@NotNull String playerName, @Nullable UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) {
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
|
||||
@@ -3,9 +3,12 @@ package com.gmail.nossr50.events.fake;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.inventory.BrewEvent;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FakeBrewEvent extends BrewEvent implements FakeEvent {
|
||||
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
|
||||
super(brewer, contents, fuelLevel);
|
||||
public FakeBrewEvent(Block brewer, BrewerInventory contents, List<ItemStack> results, int fuelLevel) {
|
||||
super(brewer, contents, results, fuelLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
@@ -13,21 +13,21 @@ import java.util.Map;
|
||||
*/
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements FakeEvent {
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers) {
|
||||
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
|
||||
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
|
||||
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
|
||||
@NotNull
|
||||
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(@NotNull Map<DamageModifier, Double> modifiers) {
|
||||
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
|
||||
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
modifierFunctions.put(modifier, ZERO);
|
||||
modifierFunctions.put(modifier, (o -> -0.0));
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.gmail.nossr50.events.items;
|
||||
|
||||
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when mcMMO is preparing to drop an item.
|
||||
@@ -16,14 +18,25 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
||||
private ItemStack itemStack;
|
||||
private boolean cancelled;
|
||||
private final ItemSpawnReason itemSpawnReason;
|
||||
private final Player player;
|
||||
|
||||
public McMMOItemSpawnEvent(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public McMMOItemSpawnEvent(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason, @Nullable Player player) {
|
||||
this.location = location;
|
||||
this.itemStack = itemStack;
|
||||
this.itemSpawnReason = itemSpawnReason;
|
||||
this.player = player;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated player
|
||||
* This can be null
|
||||
* @return the associated player if one exists null otherwise
|
||||
*/
|
||||
public @Nullable Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reason an item is being spawned by mcMMO
|
||||
* @see ItemSpawnReason
|
||||
|
||||
@@ -53,6 +53,16 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Created a party.
|
||||
*/
|
||||
CREATED_PARTY,
|
||||
|
||||
/**
|
||||
* Disbanded a party.
|
||||
*/
|
||||
DISBANDED_PARTY,
|
||||
|
||||
/**
|
||||
* Joined a party for the first time.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.gmail.nossr50.events.skills.rupture;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent {
|
||||
private final McMMOPlayer mcMMODamager;
|
||||
|
||||
public McMMOEntityDamageByRuptureEvent(@NotNull McMMOPlayer damager, @NotNull Entity damagee, double damage) {
|
||||
super(damager.getPlayer(), damagee, DamageCause.CUSTOM, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, (o -> -0.0))));
|
||||
this.mcMMODamager = damager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public McMMOPlayer getMcMMODamager() {
|
||||
return mcMMODamager;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
@@ -20,7 +21,6 @@ import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.compat.layers.world.WorldCompatibilityLayer;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@@ -46,9 +46,16 @@ public class BlockListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
|
||||
public void onBlockDropItemEvent(BlockDropItemEvent event)
|
||||
{
|
||||
//Make sure we clean up metadata on these blocks
|
||||
if(event.isCancelled()) {
|
||||
if(event.getBlock().hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS))
|
||||
event.getBlock().removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
//Track how many "things" are being dropped
|
||||
HashSet<Material> uniqueMaterials = new HashSet<>();
|
||||
boolean dontRewardTE = false; //If we suspect TEs are mixed in with other things don't reward bonus drops for anything that isn't a block
|
||||
@@ -91,19 +98,19 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0) {
|
||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).get(0);
|
||||
if (event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).size() > 0) {
|
||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).get(0);
|
||||
int bonusCount = bonusDropMeta.asInt();
|
||||
|
||||
for (int i = 0; i < bonusCount; i++) {
|
||||
Misc.spawnItemNaturally(event.getBlockState().getLocation(), is, ItemSpawnReason.BONUS_DROPS);
|
||||
Misc.spawnItemNaturally(event.getPlayer(), event.getBlockState().getLocation(), is, ItemSpawnReason.BONUS_DROPS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(event.getBlock().hasMetadata(mcMMO.BONUS_DROPS_METAKEY))
|
||||
event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
|
||||
if(event.getBlock().hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS))
|
||||
event.getBlock().removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,12 +130,10 @@ public class BlockListener implements Listener {
|
||||
|
||||
BlockFace direction = event.getDirection();
|
||||
Block movedBlock;
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
for (Block block : event.getBlocks()) {
|
||||
movedBlock = block.getRelative(direction);
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, movedBlock)) {
|
||||
if(BlockUtils.isWithinWorldBounds(movedBlock)) {
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
}
|
||||
}
|
||||
@@ -153,15 +158,13 @@ public class BlockListener implements Listener {
|
||||
BlockFace direction = event.getDirection();
|
||||
Block movedBlock = event.getBlock().getRelative(direction);
|
||||
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
//Spigot makes bad things happen in its API
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, movedBlock)) {
|
||||
if(BlockUtils.isWithinWorldBounds(movedBlock)) {
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
}
|
||||
|
||||
for (Block block : event.getBlocks()) {
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
||||
}
|
||||
}
|
||||
@@ -184,10 +187,9 @@ public class BlockListener implements Listener {
|
||||
BlockState blockState = event.getNewState();
|
||||
|
||||
if(ExperienceConfig.getInstance().isSnowExploitPrevented() && BlockUtils.shouldBeWatched(blockState)) {
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
}
|
||||
}
|
||||
@@ -207,10 +209,9 @@ public class BlockListener implements Listener {
|
||||
|
||||
if(ExperienceConfig.getInstance().preventStoneLavaFarming()) {
|
||||
BlockState newState = event.getNewState();
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
if(newState.getType() != Material.OBSIDIAN && ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, newState.getBlockData())) {
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, newState.getBlock())) {
|
||||
if(BlockUtils.isWithinWorldBounds(newState.getBlock())) {
|
||||
mcMMO.getPlaceStore().setTrue(newState);
|
||||
}
|
||||
}
|
||||
@@ -235,10 +236,11 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
//NOTE: BlockMultiPlace has its own logic so don't handle anything that would overlap
|
||||
if (!(event instanceof BlockMultiPlaceEvent)) {
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -272,11 +274,18 @@ public class BlockListener implements Listener {
|
||||
BlockState blockState = replacedBlockState.getBlock().getState();
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
//Updated: 10/5/2021
|
||||
//Note: For some reason Azalea trees trigger this event but no other tree does (as of 10/5/2021) but if this changes in the future we may need to update this
|
||||
if(BlockUtils.isPartOfTree(event.getBlockPlaced())) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Track unnatural blocks
|
||||
for(BlockState replacedStates : event.getReplacedBlockStates()) {
|
||||
mcMMO.getPlaceStore().setTrue(replacedStates);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,9 +300,7 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
|
||||
// Minecraft is dumb, the events still throw when a plant "grows" higher than the max block height. Even though no new block is created
|
||||
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
||||
|
||||
if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
||||
if(BlockUtils.isWithinWorldBounds(block)) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
}
|
||||
}
|
||||
@@ -306,21 +313,27 @@ public class BlockListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
|
||||
return;
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
if(WorldBlacklist.isWorldBlacklisted(block.getWorld())) {
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer())) {
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
// if (!BlockUtils.shouldBeWatched(blockState)) {
|
||||
@@ -335,6 +348,7 @@ public class BlockListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,7 +357,8 @@ public class BlockListener implements Listener {
|
||||
//Check if profile is loaded
|
||||
if(mcMMOPlayer == null) {
|
||||
/* Remove metadata from placed watched blocks */
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -405,7 +420,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* Remove metadata from placed watched blocks */
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
BlockUtils.cleanupBlockMetadata(block);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,6 +430,9 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreakHigher(BlockBreakEvent event) {
|
||||
if(event instanceof FakeEvent)
|
||||
return;
|
||||
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
||||
return;
|
||||
@@ -426,10 +444,6 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
|
||||
@@ -8,20 +8,19 @@ import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.metadata.MobMetadataService;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.TravelingBlockMetaCleanup;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@@ -52,7 +51,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
private final mcMMO pluginRef;
|
||||
private final @NotNull AbstractPersistentDataLayer persistentDataLayer;
|
||||
private final @NotNull MobMetadataService mobMetadataService;
|
||||
|
||||
/**
|
||||
* We can use this {@link NamespacedKey} for {@link Enchantment} comparisons to
|
||||
@@ -62,7 +61,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
public EntityListener(final mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
persistentDataLayer = mcMMO.getCompatibilityManager().getPersistentDataLayer();
|
||||
mobMetadataService = mcMMO.getMetadataService().getMobMetadataService();
|
||||
}
|
||||
|
||||
// @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@@ -95,11 +94,11 @@ public class EntityListener implements Listener {
|
||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||
|
||||
//Transfer metadata keys from mob-spawned mobs to new mobs
|
||||
if(persistentDataLayer.hasMobFlags(livingEntity)) {
|
||||
if(mobMetadataService.hasMobFlags(livingEntity)) {
|
||||
for(Entity entity : event.getTransformedEntities()) {
|
||||
if(entity instanceof LivingEntity) {
|
||||
LivingEntity transformedEntity = (LivingEntity) entity;
|
||||
persistentDataLayer.addMobFlags(livingEntity, transformedEntity);
|
||||
mobMetadataService.addMobFlags(livingEntity, transformedEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,8 +122,8 @@ public class EntityListener implements Listener {
|
||||
if(event.getEntity() instanceof Enderman) {
|
||||
Enderman enderman = (Enderman) event.getEntity();
|
||||
|
||||
if(!persistentDataLayer.hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
|
||||
persistentDataLayer.flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
|
||||
if(!mobMetadataService.hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
|
||||
mobMetadataService.flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,11 +157,11 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (bow != null
|
||||
&& bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_INF_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
//Cleanup metadata in 1 minute in case normal collection falls through
|
||||
CombatUtils.delayArrowMetaCleanup((Projectile) projectile);
|
||||
}
|
||||
@@ -190,11 +189,11 @@ public class EntityListener implements Listener {
|
||||
if(entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
|
||||
CombatUtils.delayArrowMetaCleanup(projectile); //Cleans up metadata 1 minute from now in case other collection methods fall through
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.bowForceKey))
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0));
|
||||
if(!projectile.hasMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE))
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, new FixedMetadataValue(pluginRef, 1.0));
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
if(!projectile.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE))
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
|
||||
//Check both hands
|
||||
if(ItemUtils.doesPlayerHaveEnchantmentInHands(player, "piercing")) {
|
||||
@@ -202,7 +201,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
||||
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,17 +238,21 @@ public class EntityListener implements Listener {
|
||||
* It's a headache to read but it works, I'm tempted to just remove it
|
||||
*/
|
||||
if (entity instanceof FallingBlock || entity instanceof Enderman) {
|
||||
boolean isTracked = entity.hasMetadata(mcMMO.travelingBlock);
|
||||
boolean isTracked = entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK);
|
||||
|
||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
|
||||
entity.setMetadata(mcMMO.travelingBlock, mcMMO.metadataValue);
|
||||
entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
TravelingBlockMetaCleanup metaCleanupTask = new TravelingBlockMetaCleanup(entity, pluginRef);
|
||||
metaCleanupTask.runTaskTimer(pluginRef, 20, 20*60); //6000 ticks is 5 minutes
|
||||
}
|
||||
else if (isTracked) {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
|
||||
}
|
||||
} else if ((block.getType() == Material.REDSTONE_ORE)) {
|
||||
} else if ((block.getType() == Material.REDSTONE_ORE || block.getType().getKey().getKey().equalsIgnoreCase("deepslate_redstone_ore"))) {
|
||||
//Redstone ore fire this event and should be ignored
|
||||
}
|
||||
else {
|
||||
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||
@@ -290,7 +293,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent || event instanceof McMMOEntityDamageByRuptureEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -487,8 +490,8 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity().hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
|
||||
event.getEntity().removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
if(event.getEntity().hasMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE)) {
|
||||
event.getEntity().removeMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
@@ -663,7 +666,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDeathLowest(EntityDeathEvent event) {
|
||||
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getEntity());
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -726,11 +729,11 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
private void trackSpawnedAndPassengers(LivingEntity livingEntity, MobMetaFlagType mobMetaFlagType) {
|
||||
persistentDataLayer.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
mobMetadataService.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
|
||||
for(Entity passenger : livingEntity.getPassengers()) {
|
||||
if(passenger != null) {
|
||||
persistentDataLayer.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
mobMetadataService.flagMetadata(mobMetaFlagType, livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -738,7 +741,7 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onEntityBreed(EntityBreedEvent event) {
|
||||
if(ExperienceConfig.getInstance().isCOTWBreedingPrevented()) {
|
||||
if(persistentDataLayer.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getFather()) || persistentDataLayer.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getMother())) {
|
||||
if(mobMetadataService.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getFather()) || mobMetadataService.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getMother())) {
|
||||
event.setCancelled(true);
|
||||
Animals mom = (Animals) event.getMother();
|
||||
Animals father = (Animals) event.getFather();
|
||||
@@ -770,13 +773,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@@ -816,13 +819,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@@ -911,6 +914,16 @@ public class EntityListener implements Listener {
|
||||
* is based on how 'common' the item is We can adjust this quite easily
|
||||
* if we find something is giving too much of a bonus
|
||||
*/
|
||||
|
||||
//Hacky 1.17 support
|
||||
if(foodInHand.getKey().getKey().equalsIgnoreCase("glow_berries")) {
|
||||
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (foodInHand) {
|
||||
case BAKED_POTATO: /*
|
||||
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
||||
@@ -994,12 +1007,12 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)
|
||||
|| (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(livingEntity))
|
||||
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|
||||
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
|
||||
|| mobMetadataService.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|
||||
|| mobMetadataService.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
persistentDataLayer.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
|
||||
mobMetadataService.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
@@ -1082,4 +1095,6 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -66,8 +67,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
//Profile doesn't exist
|
||||
if(UserManager.getOfflinePlayer(offlinePlayer) == null)
|
||||
{
|
||||
if(UserManager.getOfflinePlayer(offlinePlayer) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -403,6 +403,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
SkillUtils.removeAbilityBuff(event.getCurrentItem());
|
||||
|
||||
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
|
||||
if(isOutsideWindowClick(event))
|
||||
return;
|
||||
@@ -427,7 +428,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
final HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
|
||||
if (!whoClicked.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player killedPlayer = event.getEntity();
|
||||
|
||||
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
if (!killedPlayer.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -212,6 +212,11 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
|
||||
public void onPlayerDeathNormal(PlayerDeathEvent playerDeathEvent) {
|
||||
SkillUtils.removeAbilityBoostsFromInventory(playerDeathEvent.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerChangedWorldEvents.
|
||||
* <p>
|
||||
@@ -267,7 +272,7 @@ public class PlayerListener implements Listener {
|
||||
ItemStack dropStack = drop.getItemStack();
|
||||
|
||||
if (ItemUtils.isSharable(dropStack)) {
|
||||
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
|
||||
drop.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ITEM, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
SkillUtils.removeAbilityBuff(dropStack);
|
||||
@@ -398,7 +403,7 @@ public class PlayerListener implements Listener {
|
||||
//Track the hook
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
|
||||
{
|
||||
if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0)
|
||||
if(event.getHook().getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() == 0)
|
||||
{
|
||||
fishingManager.setFishHookReference(event.getHook());
|
||||
}
|
||||
@@ -443,7 +448,7 @@ public class PlayerListener implements Listener {
|
||||
if(caught instanceof Item) {
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
|
||||
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
||||
event.setExpToDrop(0);
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
@@ -509,19 +514,19 @@ public class PlayerListener implements Listener {
|
||||
ItemStack dropStack = drop.getItemStack();
|
||||
|
||||
//Remove tracking
|
||||
if(drop.hasMetadata(mcMMO.trackedArrow)) {
|
||||
drop.removeMetadata(mcMMO.trackedArrow, mcMMO.p);
|
||||
if(drop.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW)) {
|
||||
drop.removeMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, mcMMO.p);
|
||||
}
|
||||
|
||||
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
|
||||
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
|
||||
if (drop.hasMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM)) {
|
||||
if (!player.getName().equals(drop.getMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM).get(0).asString())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
if (!drop.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ITEM) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -568,7 +573,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
//Use a sync save if the server is shutting down to avoid race conditions
|
||||
mcMMOPlayer.logout(mcMMO.isServerShutdownExecuted());
|
||||
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getPlayer());
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -794,7 +799,6 @@ public class PlayerListener implements Listener {
|
||||
if(player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart))
|
||||
{
|
||||
player.getVehicle().eject();
|
||||
player.setVelocity(player.getEyeLocation().getDirection().multiply(10));
|
||||
}
|
||||
|
||||
//mcMMOPlayer.getFishingManager().setFishingRodCastTimestamp();
|
||||
@@ -832,23 +836,24 @@ public class PlayerListener implements Listener {
|
||||
ChimaeraWing.activationCheck(player);
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
|
||||
if (heldItem.getType() == Material.BONE_MEAL) {
|
||||
switch (blockState.getType()) {
|
||||
case BEETROOTS:
|
||||
case CARROT:
|
||||
case COCOA:
|
||||
case WHEAT:
|
||||
case NETHER_WART_BLOCK:
|
||||
case POTATO:
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
|
||||
if(!event.isCancelled() || event.useInteractedBlock() != Event.Result.DENY) {
|
||||
//TODO: Is this code to set false from bone meal even needed? I'll have to double check later.
|
||||
if (heldItem.getType() == Material.BONE_MEAL) {
|
||||
switch (blockState.getType()) {
|
||||
case BEETROOTS:
|
||||
case CARROT:
|
||||
case COCOA:
|
||||
case WHEAT:
|
||||
case NETHER_WART_BLOCK:
|
||||
case POTATO:
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
//call event for Green Thumb Block
|
||||
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
|
||||
@@ -880,7 +885,7 @@ public class PlayerListener implements Listener {
|
||||
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (mcMMO.p.getGeneralConfig().getAbilitiesEnabled()) {
|
||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
|
||||
@@ -999,7 +1004,7 @@ public class PlayerListener implements Listener {
|
||||
* When a {@link Player} attempts to place an {@link ItemStack}
|
||||
* into an {@link ItemFrame}, we want to make sure to remove any
|
||||
* Ability buffs from that item.
|
||||
*
|
||||
*
|
||||
* @param event The {@link PlayerInteractEntityEvent} to handle
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
@@ -1031,17 +1036,9 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
// public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
|
||||
// /* WORLD BLACKLIST CHECK */
|
||||
// if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
|
||||
// return;
|
||||
//
|
||||
// if (!mcMMO.getHolidayManager().isAprilFirst()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// mcMMO.getHolidayManager().handleStatisticEvent(event);
|
||||
// }
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||
SkillUtils.removeAbilityBuff(event.getMainHandItem());
|
||||
SkillUtils.removeAbilityBuff(event.getOffHandItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@ public class SelfListener implements Listener {
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PrimarySkillType skill = event.getSkill();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//TODO: Handle proper validation at the event level
|
||||
if(mcMMOPlayer == null || !mcMMOPlayer.getProfile().isLoaded())
|
||||
return;
|
||||
|
||||
if(player.isOnline()) {
|
||||
//Players can gain multiple levels especially during xprate events
|
||||
for(int i = 0; i < event.getLevelsGained(); i++)
|
||||
@@ -73,6 +80,11 @@ public class SelfListener implements Listener {
|
||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//TODO: Handle proper validation at the event level
|
||||
if(mcMMOPlayer == null || !mcMMOPlayer.getProfile().isLoaded())
|
||||
return;
|
||||
|
||||
PrimarySkillType primarySkillType = event.getSkill();
|
||||
|
||||
if(mcMMOPlayer.isDebugMode()) {
|
||||
|
||||
@@ -29,10 +29,6 @@ public class WorldListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
|
||||
return;
|
||||
|
||||
if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class LocaleLoader {
|
||||
*
|
||||
* @return The properly formatted text component
|
||||
*/
|
||||
public static TextComponent getTextComponent(String key, Object... messageArguments) {
|
||||
public static @NotNull TextComponent getTextComponent(@NotNull String key, Object... messageArguments) {
|
||||
if (bundle == null) {
|
||||
initialize();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public final class LocaleLoader {
|
||||
return string;
|
||||
}
|
||||
|
||||
public static TextComponent formatComponent(String string, Object... messageArguments) {
|
||||
public static @NotNull TextComponent formatComponent(@NotNull String string, Object... messageArguments) {
|
||||
if (messageArguments != null) {
|
||||
MessageFormat formatter = new MessageFormat("");
|
||||
formatter.applyPattern(string.replace("'", "''"));
|
||||
@@ -246,7 +246,6 @@ public final class LocaleLoader {
|
||||
"# If you wish to replace every line in some way, feel free to copy the entire contents of this file, just be advised that you will need to be on top of locale updates in mcMMO and follow our changelog closely.\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# WARNING: Locales only support ASCII and UTF16 characters at the moment, so you'll need to run special characters through a UTF16 converter (google it) to get them to work. This will be fixed in the future!\n" +
|
||||
"# FIND KEYS HERE: On our github repo (en_US is our master file and has ALL the keys) -> https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"# WARNING: Some keys in our master file are unused, make gratuitous use of Ctrl+F\n" +
|
||||
"# HOW TO APPLY: You can either restart the server for these changes to take effect or run /mcreloadlocale.\n" +
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
|
||||
import com.gmail.nossr50.listeners.*;
|
||||
import com.gmail.nossr50.metadata.MetadataService;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||
@@ -75,8 +76,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
/* Managers */
|
||||
|
||||
|
||||
/* Managers & Services */
|
||||
private static PlatformManager platformManager;
|
||||
private static MetadataService metadataService;
|
||||
private static ChunkManager placeStore;
|
||||
private static RepairableManager repairableManager;
|
||||
private static SalvageableManager salvageableManager;
|
||||
@@ -121,37 +125,11 @@ public class mcMMO extends JavaPlugin {
|
||||
// API checks
|
||||
private static boolean serverAPIOutdated = false;
|
||||
|
||||
// Config Validation Check
|
||||
public boolean noErrorsInConfigFiles = true;
|
||||
|
||||
// XP Event Check
|
||||
private boolean xpEventEnabled;
|
||||
|
||||
private static boolean isRetroModeEnabled;
|
||||
|
||||
/* Metadata Values */
|
||||
public static final String REPLANT_META_KEY = "mcMMO: Recently Replanted";
|
||||
public static final String EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
|
||||
public static final String RUPTURE_META_KEY = "mcMMO: RuptureTask";
|
||||
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
|
||||
public static final String DODGE_TRACKER = "mcMMO: Dodge Tracker";
|
||||
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
|
||||
public static final String travelingBlock = "mcMMO: Traveling Block";
|
||||
public static final String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
public static final String tntMetadataKey = "mcMMO: Tracked TNT";
|
||||
public static final String customNameKey = "mcMMO: Custom Name";
|
||||
public static final String customVisibleKey = "mcMMO: Name Visibility";
|
||||
public static final String droppedItemKey = "mcMMO: Tracked Item";
|
||||
public static final String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
||||
public static final String trackedArrow = "mcMMO: Tracked Arrow";
|
||||
public static final String bowForceKey = "mcMMO: Bow Force";
|
||||
public static final String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||
public static final String BONUS_DROPS_METAKEY = "mcMMO: Double Drops";
|
||||
public static final String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||
public static final String playerDataKey = "mcMMO: Player Data";
|
||||
public static final String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
private long purgeTime = 2630000000L;
|
||||
|
||||
private GeneralConfig generalConfig;
|
||||
@@ -196,10 +174,13 @@ public class mcMMO extends JavaPlugin {
|
||||
//Platform Manager
|
||||
platformManager = new PlatformManager();
|
||||
|
||||
//metadata service
|
||||
metadataService = new MetadataService(this);
|
||||
|
||||
//Filter out any debug messages (if debug/verbose logging is not enabled)
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
MetadataConstants.MCMMO_METADATA_VALUE = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
@@ -215,10 +196,6 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
loadConfigFiles();
|
||||
|
||||
if (!noErrorsInConfigFiles) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
|
||||
checkModConfigs();
|
||||
}
|
||||
@@ -483,10 +460,14 @@ public class mcMMO extends JavaPlugin {
|
||||
return upgradeManager;
|
||||
}
|
||||
|
||||
public static CompatibilityManager getCompatibilityManager() {
|
||||
public static @Nullable CompatibilityManager getCompatibilityManager() {
|
||||
return platformManager.getCompatibilityManager();
|
||||
}
|
||||
|
||||
public static MetadataService getMetadataService() {
|
||||
return metadataService;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
||||
mcMMO.databaseManager = databaseManager;
|
||||
@@ -599,7 +580,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
// Load salvage configs, make manager and register them at this time
|
||||
SalvageConfigManager sManager = new SalvageConfigManager(this);
|
||||
List<Salvageable> salvageables = new ArrayList<>(sManager.getLoadedSalvageables());
|
||||
List<Salvageable> salvageables = sManager.getLoadedSalvageables();
|
||||
salvageableManager = new SimpleSalvageableManager(salvageables.size());
|
||||
salvageableManager.registerSalvageables(salvageables);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataHolder;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.gmail.nossr50.metadata.MetadataService.NSK_FURNACE_UUID_LEAST_SIG;
|
||||
import static com.gmail.nossr50.metadata.MetadataService.NSK_FURNACE_UUID_MOST_SIG;
|
||||
|
||||
public class BlockMetadataService {
|
||||
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public BlockMetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public @Nullable UUID getFurnaceOwner(@NotNull Furnace furnace) {
|
||||
//Get container from entity
|
||||
PersistentDataContainer dataContainer = ((PersistentDataHolder) furnace).getPersistentDataContainer();
|
||||
|
||||
//Too lazy to make a custom data type for this stuff
|
||||
Long mostSigBits = dataContainer.get(NSK_FURNACE_UUID_MOST_SIG, PersistentDataType.LONG);
|
||||
Long leastSigBits = dataContainer.get(NSK_FURNACE_UUID_LEAST_SIG, PersistentDataType.LONG);
|
||||
|
||||
if (mostSigBits != null && leastSigBits != null) {
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFurnaceOwner(@NotNull Furnace furnace, @NotNull UUID uuid) {
|
||||
PersistentDataContainer dataContainer = ((PersistentDataHolder) furnace).getPersistentDataContainer();
|
||||
|
||||
dataContainer.set(NSK_FURNACE_UUID_MOST_SIG, PersistentDataType.LONG, uuid.getMostSignificantBits());
|
||||
dataContainer.set(NSK_FURNACE_UUID_LEAST_SIG, PersistentDataType.LONG, uuid.getLeastSignificantBits());
|
||||
|
||||
furnace.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.gmail.nossr50.metadata.MetadataService.NSK_SUPER_ABILITY_BOOSTED_ITEM;
|
||||
|
||||
public class ItemMetadataService {
|
||||
|
||||
public final @NotNull String LEGACY_ABILITY_TOOL_LORE = "mcMMO Ability Tool";
|
||||
public final @NotNull mcMMO pluginRef;
|
||||
|
||||
public ItemMetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public void setSuperAbilityBoostedItem(@NotNull ItemStack itemStack, int originalDigSpeed) {
|
||||
if (itemStack.getItemMeta() == null) {
|
||||
mcMMO.p.getLogger().severe("Can not assign persistent data to an item with null item metadata");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
dataContainer.set(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER, originalDigSpeed);
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public boolean isSuperAbilityBoosted(@NotNull ItemStack itemStack) {
|
||||
if (itemStack.getItemMeta() == null)
|
||||
return false;
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
//Get container from entity
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
//If this value isn't null, then the tool can be considered dig speed boosted
|
||||
Integer boostValue = dataContainer.get(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER);
|
||||
|
||||
return boostValue != null;
|
||||
}
|
||||
|
||||
public int getSuperAbilityToolOriginalDigSpeed(@NotNull ItemStack itemStack) {
|
||||
//Get container from entity
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (itemMeta == null)
|
||||
return 0;
|
||||
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
|
||||
if (dataContainer.get(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER) == null) {
|
||||
mcMMO.p.getLogger().severe("Value should never be null for a boosted item");
|
||||
return 0;
|
||||
} else {
|
||||
//Too lazy to make a custom data type for this stuff
|
||||
Integer boostValue = dataContainer.get(NSK_SUPER_ABILITY_BOOSTED_ITEM, PersistentDataType.INTEGER);
|
||||
return Math.max(boostValue, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBonusDigSpeedOnSuperAbilityTool(@NotNull ItemStack itemStack) {
|
||||
int originalSpeed = getSuperAbilityToolOriginalDigSpeed(itemStack);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if(itemMeta != null) {
|
||||
//TODO: can be optimized
|
||||
if (itemMeta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
|
||||
if (originalSpeed > 0) {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, originalSpeed, true);
|
||||
}
|
||||
|
||||
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||
dataContainer.remove(NSK_SUPER_ABILITY_BOOSTED_ITEM); //Remove persistent data
|
||||
|
||||
//TODO: needed?
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLegacyAbilityTool(@NotNull ItemStack itemStack) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (itemMeta == null)
|
||||
return false;
|
||||
|
||||
List<String> lore = itemMeta.getLore();
|
||||
|
||||
if (lore == null || lore.isEmpty())
|
||||
return false;
|
||||
|
||||
return lore.contains(LEGACY_ABILITY_TOOL_LORE);
|
||||
}
|
||||
|
||||
public @NotNull String getLegacyAbilityToolLore() {
|
||||
return LEGACY_ABILITY_TOOL_LORE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MetadataService {
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
protected static final @NotNull NamespacedKey NSK_SUPER_ABILITY_BOOSTED_ITEM;
|
||||
protected static final @NotNull NamespacedKey NSK_MOB_SPAWNER_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_EGG_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_NETHER_GATE_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_COTW_SUMMONED_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_PLAYER_BRED_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_PLAYER_TAMED_MOB;
|
||||
protected static final @NotNull NamespacedKey NSK_VILLAGER_TRADE_ORIGIN_ITEM;
|
||||
protected static final @NotNull NamespacedKey NSK_EXPLOITED_ENDERMEN;
|
||||
protected static final @NotNull NamespacedKey NSK_FURNACE_UUID_MOST_SIG;
|
||||
protected static final @NotNull NamespacedKey NSK_FURNACE_UUID_LEAST_SIG;
|
||||
|
||||
static {
|
||||
NSK_SUPER_ABILITY_BOOSTED_ITEM = getNamespacedKey(MetadataConstants.METADATA_KEY_SUPER_ABILITY_BOOSTED_ITEM);
|
||||
NSK_MOB_SPAWNER_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_MOB_SPAWNER_MOB);
|
||||
NSK_EGG_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_EGG_MOB);
|
||||
NSK_NETHER_GATE_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_NETHER_PORTAL_MOB);
|
||||
NSK_COTW_SUMMONED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_COTW_SUMMONED_MOB);
|
||||
NSK_PLAYER_BRED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_PLAYER_BRED_MOB);
|
||||
NSK_PLAYER_TAMED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_PLAYER_TAMED_MOB);
|
||||
NSK_VILLAGER_TRADE_ORIGIN_ITEM = getNamespacedKey(MetadataConstants.METADATA_KEY_VILLAGER_TRADE_ORIGIN_ITEM);
|
||||
NSK_EXPLOITED_ENDERMEN = getNamespacedKey(MetadataConstants.METADATA_KEY_EXPLOITED_ENDERMEN);
|
||||
NSK_FURNACE_UUID_MOST_SIG = getNamespacedKey(MetadataConstants.METADATA_KEY_FURNACE_UUID_MOST_SIG);
|
||||
NSK_FURNACE_UUID_LEAST_SIG = getNamespacedKey(MetadataConstants.METADATA_KEY_FURNACE_UUID_LEAST_SIG);
|
||||
}
|
||||
|
||||
private final @NotNull ItemMetadataService itemMetadataService;
|
||||
private final @NotNull MobMetadataService mobMetadataService;
|
||||
private final @NotNull BlockMetadataService blockMetadataService;
|
||||
|
||||
public MetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
|
||||
blockMetadataService = new BlockMetadataService(pluginRef);
|
||||
mobMetadataService = new MobMetadataService(pluginRef);
|
||||
itemMetadataService = new ItemMetadataService(pluginRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify generating namespaced keys
|
||||
*
|
||||
* @param key the {@link String} value of the key
|
||||
*
|
||||
* @return the generated {@link NamespacedKey}
|
||||
*/
|
||||
public static @NotNull NamespacedKey getNamespacedKey(@NotNull String key) {
|
||||
return new NamespacedKey(mcMMO.p, key);
|
||||
}
|
||||
|
||||
public @NotNull ItemMetadataService getItemMetadataService() {
|
||||
return itemMetadataService;
|
||||
}
|
||||
|
||||
public @NotNull MobMetadataService getMobMetadataService() {
|
||||
return mobMetadataService;
|
||||
}
|
||||
|
||||
public @NotNull BlockMetadataService getBlockMetadataService() {
|
||||
return blockMetadataService;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
public enum MobMetaFlagType {
|
||||
MOB_SPAWNER_MOB,
|
||||
177
src/main/java/com/gmail/nossr50/metadata/MobMetadataService.java
Normal file
177
src/main/java/com/gmail/nossr50/metadata/MobMetadataService.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package com.gmail.nossr50.metadata;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.IncompleteNamespacedKeyRegister;
|
||||
import com.gmail.nossr50.config.PersistentDataConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import static com.gmail.nossr50.metadata.MetadataService.*;
|
||||
|
||||
//TODO: Use SpawnReason where appropriate instead of MobMetaFlagType
|
||||
public class MobMetadataService {
|
||||
private final @NotNull WeakHashMap<Entity, HashSet<MobMetaFlagType>> mobRegistry; //transient data
|
||||
private final @NotNull EnumMap<MobMetaFlagType, NamespacedKey> mobFlagKeyMap; //used for persistent data
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
private boolean isUsingPersistentData = false;
|
||||
|
||||
public MobMetadataService(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
mobFlagKeyMap = new EnumMap<>(MobMetaFlagType.class);
|
||||
mobRegistry = new WeakHashMap<>();
|
||||
initMobFlagKeyMap();
|
||||
|
||||
for (MobMetaFlagType metaFlagType : MobMetaFlagType.values()) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(metaFlagType))
|
||||
isUsingPersistentData = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the namespaced keys required by the API (CB/Spigot)
|
||||
* Used primarily for persistent data
|
||||
*/
|
||||
private void initMobFlagKeyMap() throws IncompleteNamespacedKeyRegister {
|
||||
for (MobMetaFlagType mobMetaFlagType : MobMetaFlagType.values()) {
|
||||
switch (mobMetaFlagType) {
|
||||
case MOB_SPAWNER_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_MOB_SPAWNER_MOB);
|
||||
case EGG_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_EGG_MOB);
|
||||
case NETHER_PORTAL_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_NETHER_GATE_MOB);
|
||||
case COTW_SUMMONED_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_COTW_SUMMONED_MOB);
|
||||
case PLAYER_BRED_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_PLAYER_BRED_MOB);
|
||||
case EXPLOITED_ENDERMEN -> mobFlagKeyMap.put(mobMetaFlagType, NSK_EXPLOITED_ENDERMEN);
|
||||
case PLAYER_TAMED_MOB -> mobFlagKeyMap.put(mobMetaFlagType, NSK_PLAYER_TAMED_MOB);
|
||||
default -> throw new IncompleteNamespacedKeyRegister("missing namespaced key register for type: " + mobMetaFlagType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a target {@link LivingEntity} has a specific mcMMO mob flags
|
||||
*
|
||||
* @param flag the type of mob flag to check for
|
||||
* @param livingEntity the living entity to check for metadata
|
||||
*
|
||||
* @return true if the mob has metadata values for target {@link MobMetaFlagType}
|
||||
*/
|
||||
public boolean hasMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
return livingEntity.getPersistentDataContainer().has(mobFlagKeyMap.get(flag), PersistentDataType.BYTE);
|
||||
} else {
|
||||
if (mobRegistry.containsKey(livingEntity)) {
|
||||
return mobRegistry.get(livingEntity).contains(flag);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a target {@link LivingEntity} has any mcMMO mob flags
|
||||
*
|
||||
* @param livingEntity the living entity to check for metadata
|
||||
*
|
||||
* @return true if the mob has any mcMMO mob related metadata values
|
||||
*/
|
||||
public boolean hasMobFlags(@NotNull LivingEntity livingEntity) {
|
||||
if (isUsingPersistentData) {
|
||||
for (MobMetaFlagType metaFlagType : MobMetaFlagType.values()) {
|
||||
if (hasMobFlag(metaFlagType, livingEntity))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return mobRegistry.containsKey(livingEntity) && mobRegistry.get(livingEntity).size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all mcMMO mob flags from one {@link LivingEntity} to another {@link LivingEntity}
|
||||
* This does not clear existing mcMMO mob flags on the target
|
||||
*
|
||||
* @param sourceEntity entity to copy from
|
||||
* @param targetEntity entity to copy to
|
||||
*/
|
||||
public void addMobFlags(@NotNull LivingEntity sourceEntity, @NotNull LivingEntity targetEntity) {
|
||||
if (!hasMobFlags(sourceEntity))
|
||||
return;
|
||||
|
||||
if (isUsingPersistentData) {
|
||||
for (MobMetaFlagType flag : MobMetaFlagType.values()) {
|
||||
if (hasMobFlag(flag, sourceEntity)) {
|
||||
flagMetadata(flag, targetEntity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HashSet<MobMetaFlagType> flags = new HashSet<>(mobRegistry.get(sourceEntity));
|
||||
mobRegistry.put(targetEntity, flags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mob flag to a {@link LivingEntity} which effectively acts a true/false boolean
|
||||
* Existence of the flag can be considered a true value, non-existence can be considered false for all intents and purposes
|
||||
*
|
||||
* @param flag the desired flag to assign
|
||||
* @param livingEntity the target living entity
|
||||
*/
|
||||
public void flagMetadata(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
if (!hasMobFlag(flag, livingEntity)) {
|
||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||
persistentDataContainer.set(mobFlagKeyMap.get(flag), PersistentDataType.BYTE, MetadataConstants.SIMPLE_FLAG_VALUE);
|
||||
}
|
||||
} else {
|
||||
HashSet<MobMetaFlagType> flags = mobRegistry.getOrDefault(livingEntity, new HashSet<>());
|
||||
flags.add(flag); // add the new flag
|
||||
mobRegistry.put(livingEntity, flags); //update registry
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a specific mob flag from target {@link LivingEntity}
|
||||
*
|
||||
* @param flag desired flag to remove
|
||||
* @param livingEntity the target living entity
|
||||
*/
|
||||
public void removeMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if (PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
if (hasMobFlag(flag, livingEntity)) {
|
||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||
persistentDataContainer.remove(mobFlagKeyMap.get(flag));
|
||||
}
|
||||
} else {
|
||||
if (mobRegistry.containsKey(livingEntity)) {
|
||||
mobRegistry.get(livingEntity).remove(flag);
|
||||
|
||||
if (mobRegistry.get(livingEntity).size() == 0)
|
||||
mobRegistry.remove(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all mcMMO related mob flags from the target {@link LivingEntity}
|
||||
*
|
||||
* @param livingEntity target entity
|
||||
*/
|
||||
public void removeMobFlags(@NotNull LivingEntity livingEntity) {
|
||||
if (isUsingPersistentData) {
|
||||
for (MobMetaFlagType flag : MobMetaFlagType.values()) {
|
||||
removeMobFlag(flag, livingEntity);
|
||||
}
|
||||
} else {
|
||||
mobRegistry.remove(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,10 +347,20 @@ public final class PartyManager {
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param party The party to remove
|
||||
* @deprecated Use {@link #disbandParty(McMMOPlayer, Party)}
|
||||
*/
|
||||
public static void disbandParty(Party party) {
|
||||
disbandParty(null, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param party The party to remove
|
||||
*/
|
||||
public static void disbandParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||
//TODO: Potential issues with unloaded profile?
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
for (final Player member : party.getOnlineMembers()) {
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(member) == null)
|
||||
{
|
||||
@@ -366,6 +376,9 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
parties.remove(party);
|
||||
if (mcMMOPlayer != null) {
|
||||
handlePartyChangeEvent(mcMMOPlayer.getPlayer(), party.getName(), null, EventReason.DISBANDED_PARTY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,6 +401,7 @@ public final class PartyManager {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
||||
addToParty(mcMMOPlayer, party);
|
||||
handlePartyChangeEvent(player, null, partyName, EventReason.CREATED_PARTY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MobDodgeMetaCleanup extends BukkitRunnable {
|
||||
private final @NotNull Mob mob;
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public MobDodgeMetaCleanup(@NotNull Mob mob, @NotNull mcMMO pluginRef) {
|
||||
this.mob = mob;
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!mob.isValid() || mob.getTarget() == null) {
|
||||
mob.removeMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, pluginRef);
|
||||
this.cancel();
|
||||
} else if (!mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER)) {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@@ -13,14 +14,14 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (target.hasMetadata(mcMMO.customNameKey)) {
|
||||
target.setCustomName(target.getMetadata(mcMMO.customNameKey).get(0).asString());
|
||||
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
|
||||
if (target.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME)) {
|
||||
target.setCustomName(target.getMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME).get(0).asString());
|
||||
target.removeMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME, mcMMO.p);
|
||||
}
|
||||
|
||||
if (target.hasMetadata(mcMMO.customVisibleKey)) {
|
||||
target.setCustomNameVisible(target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
||||
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
|
||||
if (target.hasMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY)) {
|
||||
target.setCustomNameVisible(target.getMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY).get(0).asBoolean());
|
||||
target.removeMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, mcMMO.p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -33,9 +34,9 @@ public class PistonTrackerTask extends BukkitRunnable {
|
||||
for (Block b : blocks) {
|
||||
Block nextBlock = b.getRelative(direction);
|
||||
|
||||
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
|
||||
if (nextBlock.hasMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING)) {
|
||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
||||
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p);
|
||||
nextBlock.removeMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING, mcMMO.p);
|
||||
}
|
||||
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
|
||||
// Block doesn't have metadatakey but isTrue - set it to false
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TravelingBlockMetaCleanup extends BukkitRunnable {
|
||||
private final @NotNull Entity entity;
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public TravelingBlockMetaCleanup(@NotNull Entity entity, @NotNull mcMMO pluginRef) {
|
||||
this.entity = entity;
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(!entity.isValid()) {
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
|
||||
this.cancel();
|
||||
} else if (!entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK)) {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.commands;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -37,7 +38,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
if (useChat) {
|
||||
displayChat();
|
||||
}
|
||||
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||
((Player) sender).removeMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, mcMMO.p);
|
||||
}
|
||||
|
||||
private void displayChat() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -42,7 +43,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||
((Player) sender).removeMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, mcMMO.p);
|
||||
}
|
||||
if(sender instanceof Player)
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -53,7 +52,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
mcMMOPlayer.setAbilityMode(ability, false);
|
||||
mcMMOPlayer.setAbilityInformed(ability, false);
|
||||
|
||||
ParticleEffectUtils.playAbilityDisabledEffect(player);
|
||||
// ParticleEffectUtils.playAbilityDisabledEffect(player);
|
||||
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
//player.sendMessage(ability.getAbilityOff());
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.meta.RecentlyReplantedCropMeta;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -171,8 +172,8 @@ public class DelayedCropReplant extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Block cropBlock = cropLoc.getBlock();
|
||||
if(cropBlock.getMetadata(mcMMO.REPLANT_META_KEY).size() > 0)
|
||||
cropBlock.setMetadata(mcMMO.REPLANT_META_KEY, new RecentlyReplantedCropMeta(mcMMO.p, false));
|
||||
if(cropBlock.getMetadata(MetadataConstants.METADATA_KEY_REPLANT).size() > 0)
|
||||
cropBlock.setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RuptureTask extends BukkitRunnable {
|
||||
|
||||
public static final int DAMAGE_TICK_INTERVAL = 10;
|
||||
public static final int ANIMATION_TICK_INTERVAL = 1;
|
||||
|
||||
private final @NotNull McMMOPlayer ruptureSource;
|
||||
private final @NotNull LivingEntity targetEntity;
|
||||
@@ -20,8 +22,9 @@ public class RuptureTask extends BukkitRunnable {
|
||||
|
||||
private int ruptureTick;
|
||||
private int damageTickTracker;
|
||||
private final double pureTickDamage; //TODO: Make configurable
|
||||
private final double explosionDamage; //TODO: Make configurable
|
||||
private int animationTick;
|
||||
private final double pureTickDamage;
|
||||
private final double explosionDamage;
|
||||
|
||||
public RuptureTask(@NotNull McMMOPlayer ruptureSource, @NotNull LivingEntity targetEntity, double pureTickDamage, double explosionDamage) {
|
||||
this.ruptureSource = ruptureSource;
|
||||
@@ -30,6 +33,7 @@ public class RuptureTask extends BukkitRunnable {
|
||||
|
||||
this.ruptureTick = 0;
|
||||
this.damageTickTracker = 0;
|
||||
this.animationTick = ANIMATION_TICK_INTERVAL; //Play an animation right away
|
||||
this.pureTickDamage = pureTickDamage;
|
||||
this.explosionDamage = explosionDamage;
|
||||
}
|
||||
@@ -41,51 +45,81 @@ public class RuptureTask extends BukkitRunnable {
|
||||
ruptureTick += 1; //Advance rupture tick by 1.
|
||||
damageTickTracker += 1; //Increment damage tick tracker
|
||||
|
||||
//TODO: Clean this code up, applyRupture() is a confusing name for something that returns boolean
|
||||
//Rupture hasn't ended yet
|
||||
if(ruptureTick < expireTick) {
|
||||
//Is it time to damage?
|
||||
if(damageTickTracker >= DAMAGE_TICK_INTERVAL) {
|
||||
damageTickTracker = 0; //Reset
|
||||
ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
|
||||
|
||||
if(targetEntity.getHealth() > 0.01) {
|
||||
double healthBeforeRuptureIsApplied = targetEntity.getHealth();
|
||||
double damagedHealth = healthBeforeRuptureIsApplied - calculateAdjustedTickDamage();
|
||||
damageTickTracker = 0; //Reset timer
|
||||
if (applyRupture()) return;
|
||||
|
||||
if(damagedHealth <= 0) {
|
||||
mcMMO.p.getLogger().severe("DEBUG: Miscalculating Rupture tick damage");
|
||||
} else {
|
||||
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()
|
||||
}
|
||||
}
|
||||
playAnimation();
|
||||
}
|
||||
} else {
|
||||
explode();
|
||||
if(!applyRupture()) {
|
||||
playAnimation();
|
||||
}
|
||||
|
||||
endRupture();
|
||||
}
|
||||
} else {
|
||||
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
|
||||
targetEntity.removeMetadata(MetadataConstants.METADATA_KEY_RUPTURE, mcMMO.p);
|
||||
this.cancel(); //Task no longer needed
|
||||
}
|
||||
}
|
||||
|
||||
private void playAnimation() {
|
||||
if(animationTick >= ANIMATION_TICK_INTERVAL) {
|
||||
ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
|
||||
animationTick = 0;
|
||||
} else {
|
||||
animationTick++;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean applyRupture() {
|
||||
double healthBeforeRuptureIsApplied = targetEntity.getHealth();
|
||||
|
||||
//Ensure victim has health
|
||||
if (healthBeforeRuptureIsApplied > 0.01) {
|
||||
//Send a fake damage event
|
||||
McMMOEntityDamageByRuptureEvent event = new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage());
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
//Ensure the event wasn't cancelled and damage is still greater than 0
|
||||
double damage = event.getFinalDamage();
|
||||
|
||||
if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
|
||||
return true;
|
||||
|
||||
double damagedHealth = healthBeforeRuptureIsApplied - damage;
|
||||
|
||||
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void refreshRupture() {
|
||||
damageTickTracker = DAMAGE_TICK_INTERVAL;
|
||||
ruptureTick = 0;
|
||||
}
|
||||
|
||||
public void explode() {
|
||||
targetEntity.setMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, new FixedMetadataValue(mcMMO.p, "null"));
|
||||
|
||||
ParticleEffectUtils.playGreaterImpactEffect(targetEntity); //Animate
|
||||
|
||||
if(ruptureSource.getPlayer() != null && ruptureSource.getPlayer().isValid()) {
|
||||
targetEntity.damage(getExplosionDamage(), ruptureSource.getPlayer());
|
||||
} else {
|
||||
targetEntity.damage(getExplosionDamage(), null);
|
||||
}
|
||||
|
||||
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
|
||||
public void endRupture() {
|
||||
// targetEntity.setMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, new FixedMetadataValue(mcMMO.p, "null"));
|
||||
//
|
||||
// ParticleEffectUtils.playGreaterImpactEffect(targetEntity); //Animate
|
||||
//
|
||||
// if(ruptureSource.getPlayer() != null && ruptureSource.getPlayer().isValid()) {
|
||||
// targetEntity.damage(getExplosionDamage(), ruptureSource.getPlayer());
|
||||
// } else {
|
||||
// targetEntity.damage(getExplosionDamage(), null);
|
||||
// }
|
||||
//
|
||||
// targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
|
||||
|
||||
targetEntity.removeMetadata(MetadataConstants.METADATA_KEY_RUPTURE, mcMMO.p);
|
||||
this.cancel(); //Task no longer needed
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.MobDodgeMetaCleanup;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@@ -20,6 +22,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
@@ -64,6 +67,9 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canDodge(Entity damager) {
|
||||
if(getPlayer().isBlocking())
|
||||
return false;
|
||||
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
|
||||
return false;
|
||||
|
||||
@@ -96,20 +102,22 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
if(!(attacker instanceof Player)) {
|
||||
if(attacker instanceof Mob) {
|
||||
Mob mob = (Mob) attacker;
|
||||
//Check to see how many dodge XP rewards this mob has handed out
|
||||
if(attacker.hasMetadata(mcMMO.DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
if(mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
//If Dodge XP has been handed out 5 times then consider it being exploited
|
||||
MetadataValue metadataValue = attacker.getMetadata(mcMMO.DODGE_TRACKER).get(0);
|
||||
int count = attacker.getMetadata(mcMMO.DODGE_TRACKER).get(0).asInt();
|
||||
MetadataValue metadataValue = mob.getMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER).get(0);
|
||||
int count = metadataValue.asInt();
|
||||
|
||||
if(count <= 5) {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
attacker.setMetadata(mcMMO.DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
mob.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
MobDodgeMetaCleanup metaCleanupTask = new MobDodgeMetaCleanup(mob, mcMMO.p);
|
||||
metaCleanupTask.runTaskTimer(mcMMO.p, 20, 20*60); //one minute
|
||||
}
|
||||
} else {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
attacker.setMetadata(mcMMO.DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class AlchemyPotionBrewer {
|
||||
@@ -113,8 +114,8 @@ public final class AlchemyPotionBrewer {
|
||||
return;
|
||||
}
|
||||
|
||||
List<AlchemyPotion> inputList = new ArrayList<>();
|
||||
ItemStack[] outputList = new ItemStack[3];
|
||||
List<AlchemyPotion> inputList = new ArrayList<>(Collections.nCopies(3, null));
|
||||
List<ItemStack> outputList = new ArrayList<>(Collections.nCopies(3, null));
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
@@ -126,14 +127,14 @@ public final class AlchemyPotionBrewer {
|
||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
|
||||
AlchemyPotion output = input.getChild(ingredient);
|
||||
|
||||
inputList.add(input);
|
||||
inputList.set(i, input);
|
||||
|
||||
if (output != null) {
|
||||
outputList[i] = output.toItemStack(item.getAmount()).clone();
|
||||
outputList.set(i, output.toItemStack(item.getAmount()).clone());
|
||||
}
|
||||
}
|
||||
|
||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, ((BrewingStand) brewingStand).getFuelLevel());
|
||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, outputList, ((BrewingStand) brewingStand).getFuelLevel());
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled() || inputList.isEmpty()) {
|
||||
@@ -141,14 +142,16 @@ public final class AlchemyPotionBrewer {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(outputList[i] != null) {
|
||||
inventory.setItem(i, outputList[i]);
|
||||
if(outputList.get(i) != null) {
|
||||
inventory.setItem(i, outputList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
removeIngredient(inventory, player);
|
||||
|
||||
for (AlchemyPotion input : inputList) {
|
||||
if (input == null) continue;
|
||||
|
||||
AlchemyPotion output = input.getChild(ingredient);
|
||||
|
||||
if (output != null && player != null) {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Archery {
|
||||
TrackedEntity trackedEntity = entityIterator.next();
|
||||
|
||||
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
|
||||
Misc.spawnItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount(), ItemSpawnReason.ARROW_RETRIEVAL_ACTIVATED);
|
||||
Misc.spawnItems(null, livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount(), ItemSpawnReason.ARROW_RETRIEVAL_ACTIVATED);
|
||||
entityIterator.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@@ -54,10 +55,10 @@ public class ArcheryManager extends SkillManager {
|
||||
*/
|
||||
public double distanceXpBonusMultiplier(LivingEntity target, Entity arrow) {
|
||||
//Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
|
||||
if(!arrow.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
if(!arrow.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE))
|
||||
return 1;
|
||||
|
||||
Location firedLocation = (Location) arrow.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
|
||||
Location firedLocation = (Location) arrow.getMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE).get(0).value();
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
if(firedLocation == null || firedLocation.getWorld() == null)
|
||||
@@ -76,9 +77,9 @@ public class ArcheryManager extends SkillManager {
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
*/
|
||||
public void retrieveArrows(LivingEntity target, Projectile projectile) {
|
||||
if(projectile.hasMetadata(mcMMO.trackedArrow)) {
|
||||
if(projectile.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW)) {
|
||||
Archery.incrementTrackerValue(target);
|
||||
projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile
|
||||
projectile.removeMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, mcMMO.p); //Only 1 entity per projectile
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class AxesManager extends SkillManager {
|
||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||
if (armor != null && ItemUtils.isArmor(armor)) {
|
||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) {
|
||||
SkillUtils.handleDurabilityChange(armor, durabilityDamage, 1);
|
||||
SkillUtils.handleArmorDurabilityChange(armor, durabilityDamage, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.skills.child;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
@@ -9,12 +9,17 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
public class ChildConfig extends BukkitConfig {
|
||||
public ChildConfig() {
|
||||
super("child.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateConfigKeys() {
|
||||
//TODO: Rewrite legacy validation code
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader("child.yml")));
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ExcavationManager extends SkillManager {
|
||||
}
|
||||
|
||||
xp += treasure.getXp();
|
||||
Misc.spawnItem(location, treasure.getDrop(), ItemSpawnReason.EXCAVATION_TREASURE);
|
||||
Misc.spawnItem(getPlayer(), location, treasure.getDrop(), ItemSpawnReason.EXCAVATION_TREASURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.util.*;
|
||||
|
||||
public class FishingManager extends SkillManager {
|
||||
public static final int FISHING_ROD_CAST_CD_MILLISECONDS = 100;
|
||||
public static final int OVERFISH_LIMIT = 10;
|
||||
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||
|
||||
private long fishingRodCastTimestamp = 0L;
|
||||
@@ -101,10 +100,10 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
public void setFishHookReference(FishHook fishHook)
|
||||
{
|
||||
if(fishHook.getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() > 0)
|
||||
if(fishHook.getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() > 0)
|
||||
return;
|
||||
|
||||
fishHook.setMetadata(mcMMO.FISH_HOOK_REF_METAKEY, mcMMO.metadataValue);
|
||||
fishHook.setMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
this.fishHookReference = fishHook;
|
||||
fishHookSpawnTimestamp = System.currentTimeMillis();
|
||||
fishingRodCastTimestamp = System.currentTimeMillis();
|
||||
@@ -143,20 +142,21 @@ public class FishingManager extends SkillManager {
|
||||
else
|
||||
fishCaughtCounter = 1;
|
||||
|
||||
if(fishCaughtCounter + 1 == OVERFISH_LIMIT)
|
||||
if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit())
|
||||
{
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", 3));
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
||||
}
|
||||
|
||||
//If the new bounding box does not intersect with the old one, then update our bounding box reference
|
||||
if(!sameTarget)
|
||||
lastFishingBoundingBox = newCastBoundingBox;
|
||||
|
||||
return sameTarget && fishCaughtCounter >= OVERFISH_LIMIT;
|
||||
return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
|
||||
}
|
||||
|
||||
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
|
||||
return BoundingBox.of(centerOfCastVector, 1, 1, 1);
|
||||
int exploitingRange = ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange();
|
||||
return BoundingBox.of(centerOfCastVector, exploitingRange / 2, 1, exploitingRange / 2);
|
||||
}
|
||||
|
||||
public void setFishingTarget() {
|
||||
@@ -446,7 +446,7 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
if(fishingSucceeds) {
|
||||
if (mcMMO.p.getGeneralConfig().getFishingExtraFish()) {
|
||||
Misc.spawnItem(player.getEyeLocation(), fishingCatch.getItemStack(), ItemSpawnReason.FISHING_EXTRA_FISH);
|
||||
Misc.spawnItem(getPlayer(), player.getEyeLocation(), fishingCatch.getItemStack(), ItemSpawnReason.FISHING_EXTRA_FISH);
|
||||
}
|
||||
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
@@ -553,7 +553,7 @@ public class FishingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
Misc.spawnItem(target.getLocation(), drop, ItemSpawnReason.FISHING_SHAKE_TREASURE);
|
||||
Misc.spawnItem(getPlayer(), target.getLocation(), drop, ItemSpawnReason.FISHING_SHAKE_TREASURE);
|
||||
CombatUtils.dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times.
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ public class Herbalism {
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState
|
||||
* The {@link BlockState} to check ability activation for
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||
@@ -22,16 +22,16 @@ public class Herbalism {
|
||||
blockState.setType(Material.MOSSY_STONE_BRICKS);
|
||||
return true;
|
||||
|
||||
case DIRT :
|
||||
case GRASS_PATH :
|
||||
case DIRT:
|
||||
case DIRT_PATH:
|
||||
blockState.setType(Material.GRASS_BLOCK);
|
||||
return true;
|
||||
|
||||
case COBBLESTONE :
|
||||
case COBBLESTONE:
|
||||
blockState.setType(Material.MOSSY_COBBLESTONE);
|
||||
return true;
|
||||
|
||||
default :
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -39,19 +39,19 @@ public class Herbalism {
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState
|
||||
* The {@link BlockState} to check ability activation for
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case DIRT :
|
||||
case DIRT:
|
||||
case GRASS_BLOCK:
|
||||
case GRASS_PATH :
|
||||
case DIRT_PATH:
|
||||
blockState.setType(Material.MYCELIUM);
|
||||
return true;
|
||||
|
||||
default :
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,18 +209,21 @@ public class HerbalismManager extends SkillManager {
|
||||
public void processHerbalismBlockBreakEvent(BlockBreakEvent blockBreakEvent) {
|
||||
Player player = getPlayer();
|
||||
|
||||
Block block = blockBreakEvent.getBlock();
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getHerbalismPreventAFK() && player.isInsideVehicle()) {
|
||||
if(block.hasMetadata(MetadataConstants.METADATA_KEY_REPLANT)) {
|
||||
block.removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if the plant was recently replanted
|
||||
if(blockBreakEvent.getBlock().getBlockData() instanceof Ageable) {
|
||||
Ageable ageableCrop = (Ageable) blockBreakEvent.getBlock().getBlockData();
|
||||
|
||||
if(blockBreakEvent.getBlock().getMetadata(mcMMO.REPLANT_META_KEY).size() >= 1) {
|
||||
if(blockBreakEvent.getBlock().getMetadata(mcMMO.REPLANT_META_KEY).get(0).asBoolean()) {
|
||||
if(block.getBlockData() instanceof Ageable ageableCrop) {
|
||||
if(block.getMetadata(MetadataConstants.METADATA_KEY_REPLANT).size() >= 1) {
|
||||
if(block.getMetadata(MetadataConstants.METADATA_KEY_REPLANT).get(0).asBoolean()) {
|
||||
if(isAgeableMature(ageableCrop)) {
|
||||
blockBreakEvent.getBlock().removeMetadata(mcMMO.REPLANT_META_KEY, mcMMO.p);
|
||||
block.removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
|
||||
} else {
|
||||
//Crop is recently replanted to back out of destroying it
|
||||
blockBreakEvent.setCancelled(true);
|
||||
@@ -251,6 +254,9 @@ public class HerbalismManager extends SkillManager {
|
||||
* @param brokenPlants plant blocks to process
|
||||
*/
|
||||
private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent, HashSet<Block> brokenPlants) {
|
||||
if(blockBreakEvent.isCancelled())
|
||||
return;
|
||||
|
||||
BlockState originalBreak = blockBreakEvent.getBlock().getState();
|
||||
boolean greenThumbActivated = false;
|
||||
|
||||
@@ -263,16 +269,6 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
//When replanting a immature crop we cancel the block break event and back out
|
||||
if(greenThumbActivated) {
|
||||
if(originalBreak.getBlock().getBlockData() instanceof Ageable) {
|
||||
Ageable ageableCrop = (Ageable) originalBreak.getBlock().getBlockData();
|
||||
if(!isAgeableMature(ageableCrop)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark blocks for double drops
|
||||
* Be aware of the hacky interactions we are doing with Chorus Plants
|
||||
@@ -321,7 +317,7 @@ public class HerbalismManager extends SkillManager {
|
||||
DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mmoPlayer, delayedChorusBlocks);
|
||||
|
||||
//Large delay because the tree takes a while to break
|
||||
delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 20); //Calculate Chorus XP + Bonus Drops 1 tick later
|
||||
delayedHerbalismXPCheckTask.runTaskLater(mcMMO.p, 0); //Calculate Chorus XP + Bonus Drops 1 tick later
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,6 +390,7 @@ public class HerbalismManager extends SkillManager {
|
||||
//Catcus and Sugar Canes cannot be trusted
|
||||
switch(blockData.getMaterial()) {
|
||||
case CACTUS:
|
||||
case KELP:
|
||||
case SUGAR_CANE:
|
||||
return true;
|
||||
default:
|
||||
@@ -494,8 +491,8 @@ public class HerbalismManager extends SkillManager {
|
||||
BlockState brokenBlockNewState = blockSnapshot.getBlockRef().getState();
|
||||
|
||||
//Remove metadata from the snapshot of blocks
|
||||
if(brokenBlockNewState.hasMetadata(mcMMO.BONUS_DROPS_METAKEY)) {
|
||||
brokenBlockNewState.removeMetadata(mcMMO.BONUS_DROPS_METAKEY, mcMMO.p);
|
||||
if(brokenBlockNewState.hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS)) {
|
||||
brokenBlockNewState.removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, mcMMO.p);
|
||||
}
|
||||
|
||||
//If the block is not AIR that means it wasn't broken
|
||||
@@ -530,21 +527,18 @@ public class HerbalismManager extends SkillManager {
|
||||
* @param blockBreakEvent target event
|
||||
* @return a set of plant-blocks that were broken as a result of this event
|
||||
*/
|
||||
private HashSet<Block> getBrokenHerbalismBlocks(BlockBreakEvent blockBreakEvent) {
|
||||
private HashSet<Block> getBrokenHerbalismBlocks(@NotNull BlockBreakEvent blockBreakEvent) {
|
||||
//Get an updated capture of this block
|
||||
BlockState originalBlockBlockState = blockBreakEvent.getBlock().getState();
|
||||
Material originalBlockMaterial = originalBlockBlockState.getType();
|
||||
BlockState originBlockState = blockBreakEvent.getBlock().getState();
|
||||
Material originBlockMaterial = originBlockState.getType();
|
||||
HashSet<Block> blocksBroken = new HashSet<>(); //Blocks broken
|
||||
|
||||
//Check if this block is a one block plant or not
|
||||
boolean oneBlockPlant = isOneBlockPlant(originalBlockMaterial);
|
||||
//Add the initial block
|
||||
blocksBroken.add(originBlockState.getBlock());
|
||||
|
||||
if(oneBlockPlant) {
|
||||
//If the block is a one-block plant return only that
|
||||
blocksBroken.add(originalBlockBlockState.getBlock());
|
||||
} else {
|
||||
if(!isOneBlockPlant(originBlockMaterial)) {
|
||||
//If the block is a multi-block structure, capture a set of all blocks broken and return that
|
||||
blocksBroken = getBrokenBlocksMultiBlockPlants(originalBlockBlockState, blockBreakEvent);
|
||||
blocksBroken = getBrokenBlocksMultiBlockPlants(originBlockState);
|
||||
}
|
||||
|
||||
//Return all broken plant-blocks
|
||||
@@ -580,17 +574,16 @@ public class HerbalismManager extends SkillManager {
|
||||
* The method to grab these blocks is a bit hacky and does not hook into the API
|
||||
* Basically we expect the blocks to be broken if this event is not cancelled and we determine which block are broken on our end rather than any event state captures
|
||||
*
|
||||
* @param blockBreakEvent target event
|
||||
* @return a set of plant-blocks broken from this event
|
||||
*/
|
||||
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState originalBlockBroken, BlockBreakEvent blockBreakEvent) {
|
||||
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState brokenBlock) {
|
||||
//Track the broken blocks
|
||||
HashSet<Block> brokenBlocks;
|
||||
|
||||
if (isChorusBranch(originalBlockBroken.getType())) {
|
||||
brokenBlocks = getBrokenChorusBlocks(originalBlockBroken);
|
||||
if (isChorusBranch(brokenBlock.getType())) {
|
||||
brokenBlocks = getBrokenChorusBlocks(brokenBlock);
|
||||
} else {
|
||||
brokenBlocks = getBlocksBrokenAbove(originalBlockBroken);
|
||||
brokenBlocks = getBlocksBrokenAbove(brokenBlock, false);
|
||||
}
|
||||
|
||||
return brokenBlocks;
|
||||
@@ -610,21 +603,22 @@ public class HerbalismManager extends SkillManager {
|
||||
* The vertical search returns early if it runs into anything that is not a multi-block plant
|
||||
* Multi-block plants are hard-coded and kept in {@link MaterialMapStore}
|
||||
*
|
||||
* @param breakPointBlockState The point of the "break"
|
||||
* @param originBlock The point of the "break"
|
||||
* @return A set of blocks above the target block which can be assumed to be broken
|
||||
*/
|
||||
private HashSet<Block> getBlocksBrokenAbove(BlockState breakPointBlockState) {
|
||||
private HashSet<Block> getBlocksBrokenAbove(BlockState originBlock, boolean inclusive) {
|
||||
HashSet<Block> brokenBlocks = new HashSet<>();
|
||||
Block block = breakPointBlockState.getBlock();
|
||||
Block block = originBlock.getBlock();
|
||||
|
||||
//Add the initial block to the set
|
||||
brokenBlocks.add(block);
|
||||
if(inclusive)
|
||||
brokenBlocks.add(block);
|
||||
|
||||
//Limit our search
|
||||
int maxHeight = 255;
|
||||
int maxHeight = 512;
|
||||
|
||||
// Search vertically for multi-block plants, exit early if any non-multi block plants
|
||||
for (int y = 1; y < maxHeight; y++) {
|
||||
for (int y = 0; y < maxHeight; y++) {
|
||||
//TODO: Should this grab state? It would be more expensive..
|
||||
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
|
||||
|
||||
@@ -704,7 +698,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
blockState.setType(Material.AIR);
|
||||
Misc.spawnItem(location, treasure.getDrop(), ItemSpawnReason.HYLIAN_LUCK_TREASURE);
|
||||
Misc.spawnItem(getPlayer(), location, treasure.getDrop(), ItemSpawnReason.HYLIAN_LUCK_TREASURE);
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Herbalism.HylianLuck");
|
||||
return true;
|
||||
}
|
||||
@@ -753,7 +747,7 @@ public class HerbalismManager extends SkillManager {
|
||||
private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) {
|
||||
//Mark the plant as recently replanted to avoid accidental breakage
|
||||
new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(mcMMO.p, 20 * 2);
|
||||
blockBreakEvent.getBlock().setMetadata(mcMMO.REPLANT_META_KEY, new RecentlyReplantedCropMeta(mcMMO.p, true));
|
||||
blockBreakEvent.getBlock().setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -91,12 +92,12 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
|
||||
if (!tnt.hasMetadata(mcMMO.tntMetadataKey) || !UserManager.hasPlayerDataKey(defender)) {
|
||||
if (!tnt.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT) || !UserManager.hasPlayerDataKey(defender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!(player != null && player.equals(defender))) {
|
||||
return false;
|
||||
|
||||
@@ -26,11 +26,15 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MiningManager extends SkillManager {
|
||||
|
||||
public static final String BUDDING_AMETHYST = "budding_amethyst";
|
||||
|
||||
public MiningManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.MINING);
|
||||
}
|
||||
@@ -117,8 +121,11 @@ public class MiningManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom");
|
||||
//player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||
|
||||
tnt.setMetadata(mcMMO.tntMetadataKey, mmoPlayer.getPlayerMetadata());
|
||||
tnt.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT, mmoPlayer.getPlayerMetadata());
|
||||
tnt.setFuseTicks(0);
|
||||
if (mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 16, 4)) {
|
||||
tnt.setSource(player);
|
||||
}
|
||||
targetBlock.setType(Material.AIR);
|
||||
|
||||
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
@@ -133,29 +140,6 @@ public class MiningManager extends SkillManager {
|
||||
* @param event The {@link EntityExplodeEvent}
|
||||
*/
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
//TODO: Rewrite this garbage
|
||||
public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
|
||||
if (yield == 0)
|
||||
return;
|
||||
@@ -181,28 +165,33 @@ public class MiningManager extends SkillManager {
|
||||
int xp = 0;
|
||||
|
||||
float oreBonus = (float) (getOreBonus() / 100);
|
||||
//TODO: Pretty sure something is fucked with debrisReduction stuff
|
||||
float debrisReduction = (float) (getDebrisReduction() / 100);
|
||||
int dropMultiplier = getDropMultiplier();
|
||||
float debrisYield = yield - debrisReduction;
|
||||
|
||||
//Drop "debris" based on skill modifiers
|
||||
for(BlockState blockState : notOres) {
|
||||
if(isDropIllegal(blockState.getType()))
|
||||
continue;
|
||||
|
||||
if(RandomUtils.nextFloat() < debrisYield) {
|
||||
Misc.spawnItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
|
||||
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockState blockState : ores) {
|
||||
if(isDropIllegal(blockState.getType()))
|
||||
continue;
|
||||
|
||||
if (RandomUtils.nextFloat() < (yield + oreBonus)) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
|
||||
Misc.spawnItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES); // Initial block that would have been dropped
|
||||
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
// Bukkit.broadcastMessage("Bonus Drop on Ore: "+blockState.getType().toString());
|
||||
Misc.spawnItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP); // Initial block that would have been dropped
|
||||
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP); // Initial block that would have been dropped
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,6 +205,17 @@ public class MiningManager extends SkillManager {
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if it would be illegal (in vanilla) to obtain the block
|
||||
* Certain things should never drop ( such as budding_amethyst )
|
||||
*
|
||||
* @param material target material
|
||||
* @return true if it's not legal to obtain the block through normal gameplay
|
||||
*/
|
||||
public boolean isDropIllegal(@NotNull Material material) {
|
||||
return material.getKey().getKey().equalsIgnoreCase(BUDDING_AMETHYST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the blast radius of the explosion.
|
||||
*
|
||||
|
||||
@@ -28,8 +28,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class RepairManager extends SkillManager {
|
||||
private boolean placedAnvil;
|
||||
@@ -128,6 +131,35 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
// toRemove should be refreshed before the event call.
|
||||
toRemove = inventory.getItem(inventory.first(repairMaterial)).clone();
|
||||
|
||||
// Check if we allow enchanted materials to be used to repair objects.
|
||||
// (Servers may provide enchanted items that don't follow their intended use)
|
||||
if (!mcMMO.p.getAdvancedConfig().getAllowEnchantedRepairMaterials()) {
|
||||
|
||||
// See if our proposed item is even enchanted in the first place.
|
||||
if (toRemove.getEnchantments().size() > 0) {
|
||||
|
||||
// Lots of array sorting to find a potential non-enchanted candidate item.
|
||||
Optional<ItemStack> possibleMaterial = Arrays.stream(inventory.getContents())
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.getType() == repairMaterial)
|
||||
.filter(p -> p.getEnchantments().isEmpty())
|
||||
.findFirst();
|
||||
|
||||
// Fail out with "you need material" if we don't find a suitable alternative.
|
||||
if (possibleMaterial.isEmpty()) {
|
||||
String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
|
||||
|
||||
String materialsNeeded = "";
|
||||
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Skills.NeedMore.Extra", prettyName, materialsNeeded);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update our toRemove item to our suggested possible material.
|
||||
toRemove = possibleMaterial.get().clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Call event
|
||||
if (EventUtils.callRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item).isCancelled()) {
|
||||
|
||||
@@ -129,14 +129,6 @@ public class SalvageManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else if(salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
}
|
||||
|
||||
ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), lotteryResults);
|
||||
|
||||
//Call event
|
||||
@@ -144,6 +136,15 @@ public class SalvageManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// We only send a confirmation message after processing the event (fixes #4694)
|
||||
if (lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else if (salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
} else {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
|
||||
}
|
||||
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
|
||||
Location anvilLoc = location.clone();
|
||||
@@ -160,10 +161,10 @@ public class SalvageManager extends SkillManager {
|
||||
anvilLoc.add(0, .1, 0);
|
||||
|
||||
if (enchantBook != null) {
|
||||
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed, ItemSpawnReason.SALVAGE_ENCHANTMENT_BOOK);
|
||||
Misc.spawnItemTowardsLocation(getPlayer(), anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed, ItemSpawnReason.SALVAGE_ENCHANTMENT_BOOK);
|
||||
}
|
||||
|
||||
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed, ItemSpawnReason.SALVAGE_MATERIALS);
|
||||
Misc.spawnItemTowardsLocation(getPlayer(), anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed, ItemSpawnReason.SALVAGE_MATERIALS);
|
||||
|
||||
// BWONG BWONG BWONG - CLUNK!
|
||||
if (mcMMO.p.getGeneralConfig().getSalvageAnvilUseSoundsEnabled()) {
|
||||
|
||||
@@ -2,12 +2,13 @@ package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Smelting {
|
||||
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
return mcMMO.getModManager().isCustomOre(smelting.getType()) ? mcMMO.getModManager().getBlock(smelting.getType()).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(PrimarySkillType.SMELTING, smelting.getType());
|
||||
public static int getSmeltXP(@NotNull ItemStack smelting) {
|
||||
return ExperienceConfig.getInstance().getXp(PrimarySkillType.SMELTING, smelting.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class SmeltingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull Furnace furnace) {
|
||||
applyXpGain(Smelting.getResourceXp(furnaceSmeltEvent.getSource()), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
|
||||
applyXpGain(Smelting.getSmeltXP(furnaceSmeltEvent.getSource()), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
|
||||
|
||||
processDoubleSmelt(furnaceSmeltEvent, furnace);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.RuptureTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@@ -63,8 +64,11 @@ public class SwordsManager extends SkillManager {
|
||||
* @param target The defending entity
|
||||
*/
|
||||
public void processRupture(@NotNull LivingEntity target) {
|
||||
if(target.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) target.getMetadata(mcMMO.RUPTURE_META_KEY).get(0);
|
||||
if(!canUseRupture())
|
||||
return;
|
||||
|
||||
if(target.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) target.getMetadata(MetadataConstants.METADATA_KEY_RUPTURE).get(0);
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Rupture task ongoing for target " + target.toString());
|
||||
@@ -96,7 +100,7 @@ public class SwordsManager extends SkillManager {
|
||||
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
|
||||
|
||||
ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
|
||||
target.setMetadata(mcMMO.RUPTURE_META_KEY, ruptureTaskMeta);
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_RUPTURE, ruptureTaskMeta);
|
||||
|
||||
// if (mmoPlayer.useChatNotifications()) {
|
||||
// NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
|
||||
@@ -134,10 +138,6 @@ public class SwordsManager extends SkillManager {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getRuptureBleedTicks(boolean isTargetPlayer) {
|
||||
return mcMMO.p.getAdvancedConfig().getRuptureDurationSeconds(isTargetPlayer) / RuptureTask.DAMAGE_TICK_INTERVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Counter Attack ability
|
||||
*
|
||||
|
||||
@@ -10,10 +10,10 @@ import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@@ -475,7 +475,7 @@ public class TamingManager extends SkillManager {
|
||||
|
||||
private void applyMetaDataToCOTWEntity(LivingEntity summonedEntity) {
|
||||
//This helps identify the entity as being summoned by COTW
|
||||
mcMMO.getCompatibilityManager().getPersistentDataLayer().flagMetadata(MobMetaFlagType.COTW_SUMMONED_MOB, summonedEntity);
|
||||
mcMMO.getMetadataService().getMobMetadataService().flagMetadata(MobMetaFlagType.COTW_SUMMONED_MOB, summonedEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,10 +9,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@@ -110,10 +107,10 @@ public class UnarmedManager extends SkillManager {
|
||||
if(UserManager.getPlayer(defender) == null)
|
||||
return;
|
||||
|
||||
Item item = Misc.spawnItem(defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
||||
Item item = Misc.spawnItem(getPlayer(), defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
||||
|
||||
if (item != null && mcMMO.p.getAdvancedConfig().getDisarmProtected()) {
|
||||
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||
item.setMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||
}
|
||||
|
||||
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
|
||||
@@ -299,7 +299,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
xp += processTreeFellerXPGains(blockState, processedLogCount);
|
||||
|
||||
//Drop displaced block
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
|
||||
//Bonus Drops / Harvest lumber checks
|
||||
processHarvestLumber(blockState);
|
||||
@@ -307,7 +307,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
//Drop displaced non-woodcutting XP blocks
|
||||
|
||||
if(RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK);
|
||||
|
||||
if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
|
||||
if(mcMMO.p.getAdvancedConfig().isKnockOnWoodXPOrbEnabled()) {
|
||||
@@ -319,7 +319,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
}
|
||||
|
||||
} else {
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK, 1);
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
*
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
protected static void spawnHarvestLumberBonusDrops(@NotNull BlockState blockState) {
|
||||
Misc.spawnItemsFromCollection(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops(), ItemSpawnReason.BONUS_DROPS);
|
||||
protected void spawnHarvestLumberBonusDrops(@NotNull BlockState blockState) {
|
||||
Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), blockState.getBlock().getDrops(), ItemSpawnReason.BONUS_DROPS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.util.compat.layers.world.WorldCompatibilityLayer;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import org.bukkit.Material;
|
||||
@@ -34,9 +33,22 @@ public final class BlockUtils {
|
||||
*/
|
||||
public static void markDropsAsBonus(BlockState blockState, boolean triple) {
|
||||
if (triple)
|
||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(2, mcMMO.p));
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(2, mcMMO.p));
|
||||
else
|
||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(1, mcMMO.p));
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up some block metadata when a block breaks and the metadata is no longer needed
|
||||
* This also sets the blocks coords to false in our chunk store
|
||||
* @param block target block
|
||||
*/
|
||||
public static void cleanupBlockMetadata(Block block) {
|
||||
if(block.hasMetadata(MetadataConstants.METADATA_KEY_REPLANT)) {
|
||||
block.removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
|
||||
}
|
||||
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +57,7 @@ public final class BlockUtils {
|
||||
* @param amount amount of extra items to drop
|
||||
*/
|
||||
public static void markDropsAsBonus(BlockState blockState, int amount) {
|
||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, mcMMO.p));
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(amount, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +171,7 @@ public final class BlockUtils {
|
||||
* @return true if the block should affected by Giga Drill Breaker, false
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
||||
public static boolean affectedByGigaDrillBreaker(@NotNull BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.EXCAVATION, blockState.getBlockData()))
|
||||
return true;
|
||||
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
||||
@@ -171,7 +183,7 @@ public final class BlockUtils {
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
* @return true if the block is a log, false otherwise
|
||||
*/
|
||||
public static boolean hasWoodcuttingXP(BlockState blockState) {
|
||||
public static boolean hasWoodcuttingXP(@NotNull BlockState blockState) {
|
||||
return ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.WOODCUTTING, blockState.getBlockData());
|
||||
}
|
||||
|
||||
@@ -181,11 +193,11 @@ public final class BlockUtils {
|
||||
* @param blockState The {@link BlockState} of the block to check
|
||||
* @return true if the block is a leaf, false otherwise
|
||||
*/
|
||||
public static boolean isNonWoodPartOfTree(BlockState blockState) {
|
||||
public static boolean isNonWoodPartOfTree(@NotNull BlockState blockState) {
|
||||
return mcMMO.getMaterialMapStore().isTreeFellerDestructible(blockState.getType());
|
||||
}
|
||||
|
||||
public static boolean isNonWoodPartOfTree(Material material) {
|
||||
public static boolean isNonWoodPartOfTree(@NotNull Material material) {
|
||||
return mcMMO.getMaterialMapStore().isTreeFellerDestructible(material);
|
||||
}
|
||||
|
||||
@@ -285,15 +297,21 @@ public final class BlockUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isPartOfTree(Block rayCast) {
|
||||
return hasWoodcuttingXP(rayCast.getState()) || isNonWoodPartOfTree(rayCast.getType());
|
||||
public static boolean isPartOfTree(Block block) {
|
||||
return hasWoodcuttingXP(block.getState()) || isNonWoodPartOfTree(block.getType());
|
||||
}
|
||||
|
||||
public static boolean isWithinWorldBounds(@NotNull WorldCompatibilityLayer worldCompatibilityLayer, @NotNull Block block) {
|
||||
/**
|
||||
* Checks to see if a Block is within the world bounds
|
||||
* Prevent processing blocks from other plugins (or perhaps odd spigot anomalies) from sending blocks that can't exist within the world
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
public static boolean isWithinWorldBounds(@NotNull Block block) {
|
||||
World world = block.getWorld();
|
||||
|
||||
//World min height = inclusive | World max height = exclusive
|
||||
return block.getY() >= worldCompatibilityLayer.getMinWorldHeight(world) && block.getY() < worldCompatibilityLayer.getMaxWorldHeight(world);
|
||||
return block.getY() >= world.getMinHeight() && block.getY() < world.getMaxHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -370,7 +370,6 @@ public final class EventUtils {
|
||||
boolean isCancelled = event.isCancelled();
|
||||
|
||||
if (isCancelled) {
|
||||
|
||||
party.setLevel(party.getLevel() + levelsChanged);
|
||||
party.addXp(xpRemoved);
|
||||
}
|
||||
@@ -379,14 +378,18 @@ public final class EventUtils {
|
||||
}
|
||||
|
||||
public static boolean handleXpGainEvent(Player player, PrimarySkillType skill, float xpGained, XPGainReason xpGainReason) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
if(mmoPlayer == null)
|
||||
return true;
|
||||
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
boolean isCancelled = event.isCancelled();
|
||||
|
||||
if (!isCancelled) {
|
||||
UserManager.getPlayer(player).addXp(skill, event.getRawXpGained());
|
||||
UserManager.getPlayer(player).getProfile().registerXpGain(skill, event.getRawXpGained());
|
||||
mmoPlayer.addXp(skill, event.getRawXpGained());
|
||||
mmoPlayer.getProfile().registerXpGain(skill, event.getRawXpGained());
|
||||
}
|
||||
|
||||
return !isCancelled;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.treasure.EnchantmentWrapper;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasureBook;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -340,7 +341,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isSmeltable(ItemStack item) {
|
||||
return item != null && item.getType().isBlock() && MaterialUtils.isOre(item.getType());
|
||||
return item != null && Smelting.getSmeltXP(item) >= 1;
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack item) {
|
||||
@@ -420,6 +421,7 @@ public final class ItemUtils {
|
||||
case CHORUS_FLOWER:
|
||||
case POTATO:
|
||||
case BEETROOT:
|
||||
case BEETROOTS:
|
||||
case BEETROOT_SEEDS:
|
||||
case NETHER_WART:
|
||||
case BROWN_MUSHROOM:
|
||||
|
||||
@@ -206,16 +206,30 @@ public class MaterialMapStore {
|
||||
ores.add("gold_ore");
|
||||
ores.add("iron_ore");
|
||||
ores.add("lapis_ore");
|
||||
ores.add("lapis_lazuli_ore");
|
||||
ores.add("redstone_ore");
|
||||
ores.add("emerald_ore");
|
||||
ores.add("ancient_debris");
|
||||
ores.add("nether_gold_ore");
|
||||
ores.add("gilded_blackstone");
|
||||
|
||||
//1.17 Mining Ore Blocks
|
||||
ores.add("deepslate_redstone_ore");
|
||||
ores.add("deepslate_copper_ore");
|
||||
ores.add("deepslate_coal_ore");
|
||||
ores.add("deepslate_diamond_ore");
|
||||
ores.add("deepslate_emerald_ore");
|
||||
ores.add("deepslate_iron_ore");
|
||||
ores.add("deepslate_gold_ore");
|
||||
// ores.add("deepslate_lapis_lazuli_ore");
|
||||
ores.add("deepslate_lapis_ore");
|
||||
ores.add("copper_ore");
|
||||
}
|
||||
|
||||
private void fillIntendedTools() {
|
||||
intendedToolPickAxe.addAll(ores);
|
||||
|
||||
intendedToolPickAxe.add("lapis_lazuli_ore");
|
||||
intendedToolPickAxe.add("ice");
|
||||
intendedToolPickAxe.add("packed_ice");
|
||||
intendedToolPickAxe.add("blue_ice");
|
||||
@@ -307,10 +321,6 @@ public class MaterialMapStore {
|
||||
intendedToolPickAxe.add("stone_button");
|
||||
intendedToolPickAxe.add("stone_pressure_plate");
|
||||
intendedToolPickAxe.add("terracotta");
|
||||
intendedToolPickAxe.add("amethyst_bud");
|
||||
intendedToolPickAxe.add("amethyst_cluster");
|
||||
intendedToolPickAxe.add("block_of_amethyst");
|
||||
intendedToolPickAxe.add("budding_amethyst");
|
||||
intendedToolPickAxe.add("ancient_debris");
|
||||
intendedToolPickAxe.add("crying_obsidian");
|
||||
intendedToolPickAxe.add("glowing_obsidian"); //be
|
||||
@@ -395,6 +405,18 @@ public class MaterialMapStore {
|
||||
intendedToolPickAxe.add("waxed_cut_copper_stairs");
|
||||
intendedToolPickAxe.add("waxed_lightly_weathered_cut_copper_stairs");
|
||||
|
||||
//1.17 Mining (non-ores)
|
||||
intendedToolPickAxe.add("calcite");
|
||||
intendedToolPickAxe.add("smooth_basalt");
|
||||
intendedToolPickAxe.add("block_of_amethyst");
|
||||
intendedToolPickAxe.add("small_amethyst_bud");
|
||||
intendedToolPickAxe.add("medium_amethyst_bud");
|
||||
intendedToolPickAxe.add("large_amethyst_bud");
|
||||
intendedToolPickAxe.add("amethyst_cluster");
|
||||
intendedToolPickAxe.add("budding_amethyst");
|
||||
intendedToolPickAxe.add("deepslate");
|
||||
intendedToolPickAxe.add("cobbled_deepslate");
|
||||
intendedToolPickAxe.add("tuff");
|
||||
}
|
||||
|
||||
private void fillArmors() {
|
||||
@@ -986,6 +1008,8 @@ public class MaterialMapStore {
|
||||
treeFellerDestructibleWhiteList.add("dark_oak_leaves");
|
||||
treeFellerDestructibleWhiteList.add("jungle_leaves");
|
||||
treeFellerDestructibleWhiteList.add("spruce_leaves");
|
||||
treeFellerDestructibleWhiteList.add("azalea_leaves");
|
||||
treeFellerDestructibleWhiteList.add("flowering_azalea_leaves");
|
||||
treeFellerDestructibleWhiteList.add("nether_wart_block");
|
||||
treeFellerDestructibleWhiteList.add("warped_wart_block");
|
||||
treeFellerDestructibleWhiteList.add("brown_mushroom_block");
|
||||
@@ -1269,11 +1293,11 @@ public class MaterialMapStore {
|
||||
toolBlackList.add("sweet_berry_bush");
|
||||
}
|
||||
|
||||
public boolean isIntendedToolPickaxe(Material material) {
|
||||
public boolean isIntendedToolPickaxe(@NotNull Material material) {
|
||||
return intendedToolPickAxe.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isIntendedToolPickaxe(String string) {
|
||||
public boolean isIntendedToolPickaxe(@NotNull String string) {
|
||||
return intendedToolPickAxe.contains(string);
|
||||
}
|
||||
|
||||
|
||||
72
src/main/java/com/gmail/nossr50/util/MetadataConstants.java
Normal file
72
src/main/java/com/gmail/nossr50/util/MetadataConstants.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Stores our constants related to metadata
|
||||
*/
|
||||
public class MetadataConstants {
|
||||
/* Metadata Values
|
||||
* Take great care if you ever modify the value of these keys
|
||||
*/
|
||||
public static final @NotNull String METADATA_KEY_REPLANT = "mcMMO: Recently Replanted";
|
||||
public static final @NotNull String METADATA_KEY_EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
|
||||
public static final @NotNull String METADATA_KEY_FISH_HOOK_REF = "mcMMO: Fish Hook Tracker";
|
||||
public static final @NotNull String METADATA_KEY_DODGE_TRACKER = "mcMMO: Dodge Tracker";
|
||||
public static final @NotNull String METADATA_KEY_CUSTOM_DAMAGE = "mcMMO: Custom Damage";
|
||||
public static final @NotNull String METADATA_KEY_TRAVELING_BLOCK = "mcMMO: Traveling Block";
|
||||
public static final @NotNull String METADATA_KEY_PISTON_TRACKING = "mcMMO: Piston Tracking";
|
||||
public static final @NotNull String METADATA_KEY_TRACKED_TNT = "mcMMO: Tracked TNT";
|
||||
public static final @NotNull String METADATA_KEY_NAME_VISIBILITY = "mcMMO: Name Visibility";
|
||||
public static final @NotNull String METADATA_KEY_TRACKED_ITEM = "mcMMO: Tracked Item";
|
||||
public static final @NotNull String METADATA_KEY_INF_ARROW = "mcMMO: Infinite Arrow";
|
||||
public static final @NotNull String METADATA_KEY_TRACKED_ARROW = "mcMMO: Tracked Arrow";
|
||||
public static final @NotNull String METADATA_KEY_BOW_FORCE = "mcMMO: Bow Force";
|
||||
public static final @NotNull String METADATA_KEY_ARROW_DISTANCE = "mcMMO: Arrow Distance";
|
||||
public static final @NotNull String METADATA_KEY_BONUS_DROPS = "mcMMO: Double Drops";
|
||||
public static final @NotNull String METADATA_KEY_DISARMED_ITEM = "mcMMO: Disarmed Item";
|
||||
public static final @NotNull String METADATA_KEY_PLAYER_DATA = "mcMMO: Player Data";
|
||||
public static final @NotNull String METADATA_KEY_DATABASE_COMMAND = "mcMMO: Processing Database Command";
|
||||
public static final @NotNull String METADATA_KEY_FURNACE_UUID_MOST_SIG = "furnace_uuid_most_sig";
|
||||
public static final @NotNull String METADATA_KEY_FURNACE_UUID_LEAST_SIG = "furnace_uuid_least_sig";
|
||||
public static final @NotNull String METADATA_KEY_SUPER_ABILITY_BOOSTED_ITEM = "super_ability_boosted";
|
||||
public static final @NotNull String METADATA_KEY_MOB_SPAWNER_MOB = "mcmmo_mob_spawner_mob";
|
||||
public static final @NotNull String METADATA_KEY_EGG_MOB = "mcmmo_egg_mob";
|
||||
public static final @NotNull String METADATA_KEY_NETHER_PORTAL_MOB = "mcmmo_nethergate_mob";
|
||||
public static final @NotNull String METADATA_KEY_COTW_SUMMONED_MOB = "mcmmo_cotw_summoned_mob";
|
||||
public static final @NotNull String METADATA_KEY_PLAYER_BRED_MOB = "mcmmo_player_bred_mob";
|
||||
public static final @NotNull String METADATA_KEY_PLAYER_TAMED_MOB = "mcmmo_player_tamed_mob";
|
||||
public static final @NotNull String METADATA_KEY_VILLAGER_TRADE_ORIGIN_ITEM = "mcmmo_villager_trade_origin_item";
|
||||
public static final @NotNull String METADATA_KEY_EXPLOITED_ENDERMEN = "mcmmo_exploited_endermen";
|
||||
public static final @NotNull String METADATA_KEY_CUSTOM_NAME = "mcmmo_custom_name";
|
||||
public static final @NotNull String METADATA_KEY_OLD_NAME_KEY = "mcmmo_old_name";
|
||||
public static final @NotNull String METADATA_KEY_RUPTURE = "mcmmo_rupture";
|
||||
|
||||
public static final byte SIMPLE_FLAG_VALUE = (byte) 0x1;
|
||||
|
||||
public static final @NotNull ImmutableSet<String> MOB_METADATA_KEYS;
|
||||
|
||||
public static FixedMetadataValue MCMMO_METADATA_VALUE;
|
||||
|
||||
static {
|
||||
HashSet<String> temp = new HashSet<>();
|
||||
temp.add(MetadataConstants.METADATA_KEY_MOB_SPAWNER_MOB);
|
||||
temp.add(MetadataConstants.METADATA_KEY_EGG_MOB);
|
||||
temp.add(MetadataConstants.METADATA_KEY_NETHER_PORTAL_MOB);
|
||||
temp.add(MetadataConstants.METADATA_KEY_COTW_SUMMONED_MOB);
|
||||
temp.add(MetadataConstants.METADATA_KEY_PLAYER_BRED_MOB);
|
||||
temp.add(MetadataConstants.METADATA_KEY_PLAYER_TAMED_MOB);
|
||||
temp.add(MetadataConstants.METADATA_KEY_EXPLOITED_ENDERMEN);
|
||||
temp.add(MetadataConstants.METADATA_KEY_CUSTOM_NAME);
|
||||
temp.add(MetadataConstants.METADATA_KEY_RUPTURE);
|
||||
temp.add(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE);
|
||||
temp.add(MetadataConstants.METADATA_KEY_OLD_NAME_KEY);
|
||||
temp.add(MetadataConstants.METADATA_KEY_DODGE_TRACKER);
|
||||
|
||||
MOB_METADATA_KEYS = ImmutableSet.copyOf(temp);
|
||||
}
|
||||
}
|
||||
@@ -107,9 +107,9 @@ public final class Misc {
|
||||
return blockState.getLocation().add(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
public static void spawnItemsFromCollection(@NotNull Location location, @NotNull Collection<ItemStack> drops, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public static void spawnItemsFromCollection(@NotNull Player player, @NotNull Location location, @NotNull Collection<ItemStack> drops, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnItem(location, drop, itemSpawnReason);
|
||||
spawnItem(player, location, drop, itemSpawnReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +121,11 @@ public final class Misc {
|
||||
* @param drops collection to iterate over
|
||||
* @param sizeLimit the number of drops to process
|
||||
*/
|
||||
public static void spawnItemsFromCollection(@NotNull Location location, @NotNull Collection<ItemStack> drops, @NotNull ItemSpawnReason itemSpawnReason, int sizeLimit) {
|
||||
public static void spawnItemsFromCollection(@Nullable Player player, @NotNull Location location, @NotNull Collection<ItemStack> drops, @NotNull ItemSpawnReason itemSpawnReason, int sizeLimit) {
|
||||
ItemStack[] arrayDrops = drops.toArray(new ItemStack[0]);
|
||||
|
||||
for(int i = 0; i < sizeLimit-1; i++) {
|
||||
spawnItem(location, arrayDrops[i], itemSpawnReason);
|
||||
spawnItem(player, location, arrayDrops[i], itemSpawnReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +136,9 @@ public final class Misc {
|
||||
* @param is The items to drop
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void spawnItems(@NotNull Location location, @NotNull ItemStack is, int quantity, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public static void spawnItems(@Nullable Player player, @NotNull Location location, @NotNull ItemStack is, int quantity, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
spawnItem(location, is, itemSpawnReason);
|
||||
spawnItem(player, location, is, itemSpawnReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ public final class Misc {
|
||||
* @param itemSpawnReason the reason for the item drop
|
||||
* @return Dropped Item entity or null if invalid or cancelled
|
||||
*/
|
||||
public static @Nullable Item spawnItem(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public static @Nullable Item spawnItem(@Nullable Player player, @NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
if (itemStack.getType() == Material.AIR || location.getWorld() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason);
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason, player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -174,13 +174,13 @@ public final class Misc {
|
||||
* @param itemSpawnReason the reason for the item drop
|
||||
* @return Dropped Item entity or null if invalid or cancelled
|
||||
*/
|
||||
public static @Nullable Item spawnItemNaturally(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public static @Nullable Item spawnItemNaturally(@Nullable Player player, @NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
if (itemStack.getType() == Material.AIR || location.getWorld() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason);
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason, player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -198,9 +198,9 @@ public final class Misc {
|
||||
* @param speed the speed that the item should travel
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void spawnItemsTowardsLocation(@NotNull Location fromLocation, @NotNull Location toLocation, @NotNull ItemStack is, int quantity, double speed, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public static void spawnItemsTowardsLocation(@Nullable Player player, @NotNull Location fromLocation, @NotNull Location toLocation, @NotNull ItemStack is, int quantity, double speed, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
spawnItemTowardsLocation(fromLocation, toLocation, is, speed, itemSpawnReason);
|
||||
spawnItemTowardsLocation(player, fromLocation, toLocation, is, speed, itemSpawnReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public final class Misc {
|
||||
* @param speed the speed that the item should travel
|
||||
* @return Dropped Item entity or null if invalid or cancelled
|
||||
*/
|
||||
public static @Nullable Item spawnItemTowardsLocation(@NotNull Location fromLocation, @NotNull Location toLocation, @NotNull ItemStack itemToSpawn, double speed, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
public static @Nullable Item spawnItemTowardsLocation(@Nullable Player player, @NotNull Location fromLocation, @NotNull Location toLocation, @NotNull ItemStack itemToSpawn, double speed, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
if (itemToSpawn.getType() == Material.AIR) {
|
||||
return null;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public final class Misc {
|
||||
return null;
|
||||
|
||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(spawnLocation, clonedItem, itemSpawnReason);
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(spawnLocation, clonedItem, itemSpawnReason, player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
//Something cancelled the event so back out
|
||||
|
||||
@@ -54,8 +54,8 @@ public final class MobHealthbarUtils {
|
||||
/*
|
||||
* Store the name in metadata
|
||||
*/
|
||||
if(target.getMetadata(TransientMetadataTools.OLD_NAME_METAKEY).size() <= 0 && originalName != null)
|
||||
target.setMetadata(TransientMetadataTools.OLD_NAME_METAKEY, new OldName(originalName, plugin));
|
||||
if(target.getMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY).size() <= 0)
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY, new OldName(originalName, plugin));
|
||||
|
||||
if (oldName == null) {
|
||||
oldName = "";
|
||||
@@ -73,12 +73,12 @@ public final class MobHealthbarUtils {
|
||||
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
|
||||
|
||||
if (updateName) {
|
||||
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, oldName));
|
||||
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible));
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME, new FixedMetadataValue(mcMMO.p, oldName));
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, oldNameVisible));
|
||||
}
|
||||
else if (!target.hasMetadata(mcMMO.customNameKey)) {
|
||||
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, ""));
|
||||
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, false));
|
||||
else if (!target.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME)) {
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME, new FixedMetadataValue(mcMMO.p, ""));
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, false));
|
||||
}
|
||||
|
||||
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
|
||||
@@ -273,7 +273,7 @@ public class TransientEntityTracker {
|
||||
}
|
||||
|
||||
//Remove our metadata
|
||||
mcMMO.getCompatibilityManager().getPersistentDataLayer().removeMobFlags(livingEntity);
|
||||
mcMMO.getMetadataService().getMobMetadataService().removeMobFlags(livingEntity);
|
||||
|
||||
//Clean from trackers
|
||||
unregisterEntity(livingEntity);
|
||||
|
||||
@@ -5,44 +5,38 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TransientMetadataTools {
|
||||
public static final String OLD_NAME_METAKEY = TransientMetadataTools.OLD_NAME_METAKEY;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public TransientMetadataTools(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public void cleanAllLivingEntityMetadata(@NotNull LivingEntity livingEntity) {
|
||||
//Since its not written anywhere, apparently the GC won't touch objects with metadata still present on them
|
||||
if (livingEntity.hasMetadata(mcMMO.customNameKey)) {
|
||||
livingEntity.setCustomName(livingEntity.getMetadata(mcMMO.customNameKey).get(0).asString());
|
||||
livingEntity.removeMetadata(mcMMO.customNameKey, pluginRef);
|
||||
}
|
||||
|
||||
if(livingEntity.hasMetadata(OLD_NAME_METAKEY)) {
|
||||
livingEntity.removeMetadata(OLD_NAME_METAKEY, pluginRef);
|
||||
public void cleanLivingEntityMetadata(@NotNull LivingEntity entity) {
|
||||
//Since it's not written anywhere, apparently the GC won't touch objects with metadata still present on them
|
||||
if (entity.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME)) {
|
||||
entity.setCustomName(entity.getMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME).get(0).asString());
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME, pluginRef);
|
||||
}
|
||||
|
||||
//Involved in changing mob names to hearts
|
||||
if (livingEntity.hasMetadata(mcMMO.customVisibleKey)) {
|
||||
livingEntity.setCustomNameVisible(livingEntity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
||||
livingEntity.removeMetadata(mcMMO.customVisibleKey, pluginRef);
|
||||
if (entity.hasMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY)) {
|
||||
entity.setCustomNameVisible(entity.getMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY).get(0).asBoolean());
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, pluginRef);
|
||||
}
|
||||
|
||||
//Gets assigned to endermen, potentially doesn't get cleared before this point
|
||||
if(livingEntity.hasMetadata(mcMMO.travelingBlock)) {
|
||||
livingEntity.removeMetadata(mcMMO.travelingBlock, pluginRef);
|
||||
}
|
||||
|
||||
if(livingEntity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
livingEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, pluginRef);
|
||||
}
|
||||
|
||||
if(livingEntity.hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
|
||||
livingEntity.removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, pluginRef);
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK)) {
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
|
||||
}
|
||||
|
||||
//Cleanup mob metadata
|
||||
mcMMO.getCompatibilityManager().getPersistentDataLayer().removeMobFlags(livingEntity);
|
||||
mcMMO.getMetadataService().getMobMetadataService().removeMobFlags(entity);
|
||||
|
||||
//TODO: This loop has some redundancy, this whole method needs to be rewritten
|
||||
for(String key : MetadataConstants.MOB_METADATA_KEYS) {
|
||||
if(entity.hasMetadata(key)) {
|
||||
entity.removeMetadata(key, pluginRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,7 +24,7 @@ public class BitSetChunkStore implements ChunkStore {
|
||||
private transient boolean dirty = false;
|
||||
|
||||
public BitSetChunkStore(@NotNull World world, int cx, int cz) {
|
||||
this(world.getUID(), mcMMO.getCompatibilityManager().getWorldCompatibilityLayer().getMinWorldHeight(world), world.getMaxHeight(), cx, cz);
|
||||
this(world.getUID(), world.getMinHeight(), world.getMaxHeight(), cx, cz);
|
||||
}
|
||||
|
||||
private BitSetChunkStore(@NotNull UUID worldUid, int worldMin, int worldMax, int cx, int cz) {
|
||||
@@ -109,23 +108,23 @@ public class BitSetChunkStore implements ChunkStore {
|
||||
return (z * 16 + x) + (256 * (y + yOffset));
|
||||
}
|
||||
|
||||
private static int getWorldMin(@NotNull UUID worldUid, int storedWorldMin) {
|
||||
private static int getWorldMin(@NotNull UUID worldUid) {
|
||||
World world = Bukkit.getWorld(worldUid);
|
||||
|
||||
// Not sure how this case could come up, but might as well handle it gracefully. Loading a chunkstore for an unloaded world?
|
||||
if (world == null)
|
||||
return storedWorldMin;
|
||||
throw new RuntimeException("Cannot grab a minimum world height for an unloaded world");
|
||||
|
||||
return mcMMO.getCompatibilityManager().getWorldCompatibilityLayer().getMinWorldHeight(world);
|
||||
return world.getMinHeight();
|
||||
}
|
||||
|
||||
private static int getWorldMax(@NotNull UUID worldUid, int storedWorldMax)
|
||||
private static int getWorldMax(@NotNull UUID worldUid)
|
||||
{
|
||||
World world = Bukkit.getWorld(worldUid);
|
||||
|
||||
// Not sure how this case could come up, but might as well handle it gracefully. Loading a chunkstore for an unloaded world?
|
||||
if (world == null)
|
||||
return storedWorldMax;
|
||||
throw new RuntimeException("Cannot grab a maximum world height for an unloaded world");
|
||||
|
||||
return world.getMaxHeight();
|
||||
}
|
||||
@@ -171,8 +170,8 @@ public class BitSetChunkStore implements ChunkStore {
|
||||
in.readFully(temp);
|
||||
BitSet stored = BitSet.valueOf(temp);
|
||||
|
||||
int currentWorldMin = getWorldMin(worldUid, worldMin);
|
||||
int currentWorldMax = getWorldMax(worldUid, worldMax);
|
||||
int currentWorldMin = getWorldMin(worldUid);
|
||||
int currentWorldMax = getWorldMax(worldUid);
|
||||
|
||||
// The order in which the world height update code occurs here is important, the world max truncate math only holds up if done before adjusting for min changes
|
||||
// Lop off extra data if world max has shrunk
|
||||
@@ -273,8 +272,8 @@ public class BitSetChunkStore implements ChunkStore {
|
||||
|
||||
public @NotNull BitSetChunkStore convert()
|
||||
{
|
||||
int currentWorldMin = getWorldMin(worldUid, 0);
|
||||
int currentWorldMax = getWorldMax(worldUid, worldMax);
|
||||
int currentWorldMin = getWorldMin(worldUid);
|
||||
int currentWorldMax = getWorldMax(worldUid);
|
||||
|
||||
BitSetChunkStore converted = new BitSetChunkStore(worldUid, currentWorldMin, currentWorldMax, cx, cz);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
@@ -110,7 +111,7 @@ public final class CommandUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(mcMMO.playerDataKey);
|
||||
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA);
|
||||
|
||||
if (!hasPlayerDataKey) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user