Merge remote-tracking branch 'origin/master'

This commit is contained in:
Momshroom 2024-05-21 02:05:22 -05:00
commit 5386817faf
267 changed files with 5745 additions and 4136 deletions

View File

@ -1,6 +1,112 @@
Version 2.2.007
Fixed bug where Green Thumb did not replant if seed was in the off hand
Version 2.2.013
Modified the RNG for dropping non-ore blocks from Blast Mining to yield about 50% of what was destroyed
(API) Deprecated com.gmail.nossr50.mcMMO.getPlaceStore
(API) Added com.gmail.nossr50.mcMMO.getUserBlockTracker
(API) Added com.gmail.nossr50.mcMMO.getChunkManager
(API) Added new methods to com.gmail.nossr50.util.blockmeta.UserBlockTracker for easier readability
(API) Deprecated the old poorly named methods in UserBlockTracker
(Codebase) Cleaned up and organized unit tests relating to UserBlockTracker
NOTES:
Not planning to delete the deprecated methods in UserBlockTracker anytime soon, as nothing has really changed other than the names
Version 2.2.012
Fixed a bug where Daze would cause an exception in older game versions (1.20.4 and older)
Version 2.2.011
Fixed bug where some potions on older versions (1.20.4 and older) were not brewable (night vision extended, etc)
Improved logging for Alchemy potion look up (see notes)
NOTES:
Added detailed logging when multiple configured potions match an ItemStack.
This will help identify issues with potion configuration.
Version 2.2.010
Fixed being unable to load REGEN potion type on new versions of Paper/Spigot 1.20.6
Fixed some potions not gaining XP when brewed (Level 2 potions, etc)
BrewingStands will now remember who owns them, this persists across restarts (see notes)
Fixed rare NPE in mcMMO events when player data was unable to be retrieved
Fixed a NPE that could happen when damaging armor with Axes
Fixed a bug where Alchemy brewing would be cancelled if the player died
(API) Added getMcMMOPlayer() to McMMOPlayerSkillEvent
(API) Added new ctor McMMOPlayerSkillEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType)
(API) Deprecated ctor McMMOPlayerSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Added ctor McMMOPlayerAbilityEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Deprecated ctor McMMOPlayerAbilityEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Deprecated ctor McMMOPlayerAbilityActivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Added ctor McMMOPlayerAbilityActivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Deprecated ctor McMMOPlayerCatalysisEvent(org.bukkit.entity.Player, double)
(API) Added ctor McMMOPlayerCatalysisEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, double)
(API) Deprecated util method EventUtils.callPlayerAbilityActivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Added util method EventUtils.callPlayerAbilityActivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Deprecated ctor McMMOPlayerFishingEvent(org.bukkit.entity.Player)
(API) Added ctor McMMOPlayerFishingEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer)
(API) Deprecated ctor McMMOPlayerFishingTreasureEvent.McMMOPlayerFishingTreasureEvent(org.bukkit.entity.Player, org.bukkit.inventory.ItemStack, int)
(API) Added ctor McMMOPlayerFishingTreasureEvent.McMMOPlayerFishingTreasureEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, org.bukkit.inventory.ItemStack, int)
(API) Deprecated ctor McMMOPlayerMagicHunterEvent(org.bukkit.entity.Player, org.bukkit.inventory.ItemStack, int, java.util.Map<org.bukkit.enchantments.Enchantment,java.lang.Integer>)
(API) Added ctor McMMOPlayerMagicHunterEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, org.bukkit.inventory.ItemStack, int, java.util.Map<org.bukkit.enchantments.Enchantment,java.lang.Integer>)
(API) Deprecated ctor McMMOPlayerAbilityDeactivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Added ctor McMMOPlayerAbilityDeactivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
(API) Deprecated util method EventUtils.callAbilityDeactivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SuperAbilityType)
(API) Added util method EventUtils.callAbilityDeactivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SuperAbilityType)
(API) Deprecated util EventUtils.callSubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SubSkillType)
(API) Added util EventUtils.callSubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SubSkillType)
(API) Deprecated ctor SubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SubSkillType)
(API) Added ctor SubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SubSkillType)
(API) Deprecated ctor SubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SubSkillType, double)
(API) Added ctor SubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SubSkillType, double)
(API) Deprecated ctor SubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill)
(API) Added ctor SubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill)
(API) Deprecated ctor AlchemyBrewCheckTask(org.bukkit.entity.Player, org.bukkit.block.BrewingStand)
(API) Added ctor AlchemyBrewCheckTask(org.bukkit.block.BrewingStand)
NOTES:
You can now use hoppers and brewing stands and not have to worry about having to re-interact with the brewing stand over and over again
Ownership of a brewing stand is whoever last interacted with it, this persists across restarts
This is not an exhaustive list of API changes in this update, but most of the important ones should be documented here.
Version 2.2.009
Fixed a bug that prevented mcMMO from loading on MC versions older than 1.20.6
Dramatically increased the base XP for Alchemy again (see notes)
NOTES:
Alchemy leveling still felt too slow, so I've increased it again. You can either delete experience.yml to get the new values or adjust them manually.
If you haven't updated mcMMO since 2.2.006 or older you don't need to do anything to get these new values.
The new default values are...
Potion_Brewing:
Stage_1: 666
Stage_2: 1111
Stage_3: 1750
Stage_4: 2250
Version 2.2.008
Fixed alchemy potions not upgrading correctly (This will only affect new potions made, see notes)
Fixed a bug where alchemy potions had italicized names
Fixed a bug where messages were not being sent to the action bar in 1.20.6
(SQL) Fixed bug that broke /mccooldowns and /archery in some circumstances
Fixed some exceptions that could happen with parties disabled (thanks IAISI)
NOTES:
mcMMO-exclusive Potions (haste, etc) made on version 2.2.007 of mcMMO will not upgrade correctly, you'll just have to make new ones. Sorry for the inconvenience.
Alchemy potions will now be brewed as type "Mundane" behind the scenes, this used to be Uncraftable/Water. This led to some issues. So I've changed it to be Mundane.
Version 2.2.007
Compatibility with the 1.20.5 / 1.20.6 MC Update
Fixed bug where Alchemy was not brewing certain potions (haste, etc)
Tree Feller no longer restricts how many saplings can drop
Tree Feller now drops leaves 25% of the time (up from 10%)
Alchemy XP has been DRAMATICALLY increased, it was extremely grindy by default
Alchemy experience values in experience.yml are now found under 'Experience_Values.Alchemy.Potion_Brewing'
Fixed bug where the probability of success of Graceful Roll was not being calculated correctly
Fixed bug where Green Thumb did not replant if seed was in the off hand
Added armadillo to combat experience in experience.yml
NOTES:
While fixing various Alchemy bugs, I noticed Alchemy leveled SUPER slow, I have increased it dramatically. Feel free to change it back by modifying the new values in experience.yml
I did my best to keep mcMMO compatible with older versions of Minecraft for this update.
This update to MC was quite large, with breaking changes to a lot of code relating to Alchemy, and some other things.
I expect there to be bugs, please report them on GitHub or Discord, but preferably GitHub.
I will be working on fixing these bugs as they come in, so please be patient.
Version 2.2.006
Added new config custom_item_support.yml
Added support for hex color codes in the locale file, uses the format &#RRGGBB (see notes)

121
pom.xml
View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.2.007-SNAPSHOT</version>
<version>2.2.013-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>
@ -75,16 +75,17 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.5</version>
<configuration>
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
<trimStackTrace>false</trimStackTrace>
<excludedGroups>skip</excludedGroups>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.5</version>
<configuration>
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
@ -95,12 +96,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M6</version>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.13.0</version>
<configuration>
<release>17</release>
<compilerArgs>
@ -112,6 +113,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/package.xml</descriptor>
@ -130,7 +132,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.5.3</version>
<configuration>
<artifactSet>
<includes>
@ -140,23 +142,22 @@
<include>org.bstats:bstats-base</include>
<include>org.bstats:bstats-bukkit</include>
<include>net.kyori:adventure-api</include>
<include>net.kyori:adventure-text-serializer-gson</include>
<include>net.kyori:adventure-platform-bukkit</include>
<include>net.kyori:adventure-platform-api</include>
<include>net.kyori:adventure-platform-viaversion</include>
<include>net.kyori:adventure-platform-facet</include>
<include>net.kyori:adventure-nbt</include>
<include>net.kyori:adventure-key</include>
<include>net.kyori:adventure-nbt</include>
<include>net.kyori:adventure-platform-api</include>
<include>net.kyori:adventure-platform-bukkit</include>
<include>net.kyori:adventure-platform-facet</include>
<include>net.kyori:adventure-platform-viaversion</include>
<include>net.kyori:adventure-text-serializer-bungeecord</include>
<include>net.kyori:adventure-text-serializer-gson</include>
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
<include>net.kyori:adventure-text-serializer-json</include>
<include>net.kyori:adventure-text-serializer-json-legacy-impl</include>
<include>net.kyori:adventure-text-serializer-legacy</include>
<include>net.kyori:examination-api</include>
<include>net.kyori:examination-string</include>
<include>net.kyori:adventure-text-serializer-legacy</include>
<include>net.kyori:adventure-text-serializer-gson</include>
<include>net.kyori:adventure-text-serializer-json</include>
<include>net.kyori:adventure-text-serializer-bungeecord</include>
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
<include>net.kyori:adventure-text-serializer-json-legacy-impl</include>
<include>net.kyori:option</include>
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
<include>co.aikar:acf-bukkit</include>
<include>com.tcoded:FoliaLib</include>
</includes>
@ -222,6 +223,11 @@
</pluginRepositories>
<repositories>
<!-- Protocol Lib Repository -->
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
@ -254,8 +260,11 @@
<id>devmart-other</id>
<url>https://nexuslite.gcnt.net/repos/other/</url>
</repository>
<!-- ... -->
<!-- ... -->
<!-- MockBukkit -->
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
@ -265,6 +274,12 @@
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@ -290,57 +305,57 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-json</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-json-legacy-impl</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-key</artifactId>
<version>4.15.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-api</artifactId>
<version>4.3.2</version>
<version>4.3.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.2</version>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-facet</artifactId>
<version>4.3.2</version>
<version>4.3.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-viaversion</artifactId>
<version>4.3.2</version>
<version>4.3.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
@ -350,18 +365,18 @@
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>2.0.0-M1</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -397,36 +412,36 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<version>5.11.0-M2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.6.1</version>
<version>5.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.6.1</version>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>10.1.0-M17</version>
<version>10.1.24</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<version>24.1.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.1-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
<version>33.2.0-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
<scope>compile</scope>
</dependency>
<dependency>
@ -435,5 +450,29 @@
<version>0.3.1</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-core</artifactId>-->
<!-- <version>2.22.1</version> &lt;!&ndash; Make sure this version matches the other log4j dependencies &ndash;&gt;-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-api</artifactId>-->
<!-- <version>2.22.1</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
<!-- <version>2.22.1</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.github.seeseemelk</groupId>-->
<!-- <artifactId>MockBukkit-v1.19</artifactId>-->
<!-- <version>LATEST</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
</dependencies>
</project>

View File

@ -1143,14 +1143,10 @@ public final class ExperienceAPI {
* @param blockStates the blocks to reward XP for
* @param mcMMOPlayer the target player
*/
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer)
{
for(BlockState bs : blockStates)
{
for(PrimarySkillType skillType : PrimarySkillType.values())
{
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
{
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) {
for(BlockState bs : blockStates) {
for(PrimarySkillType skillType : PrimarySkillType.values()) {
if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
}
}
@ -1163,12 +1159,9 @@ public final class ExperienceAPI {
* @param mcMMOPlayer the target player
* @param skillType target primary skill
*/
public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType)
{
for(BlockState bs : blockStates)
{
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
{
public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
for(BlockState bs : blockStates) {
if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
}
}
@ -1179,12 +1172,9 @@ public final class ExperienceAPI {
* @param blockState The target blockstate
* @param mcMMOPlayer The target player
*/
public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer)
{
for(PrimarySkillType skillType : PrimarySkillType.values())
{
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
{
public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) {
for(PrimarySkillType skillType : PrimarySkillType.values()) {
if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
}
}
@ -1196,10 +1186,8 @@ public final class ExperienceAPI {
* @param mcMMOPlayer The target player
* @param skillType target primary skill
*/
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType)
{
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
{
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
}
}

View File

@ -109,8 +109,7 @@ public final class PartyAPI {
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else {
if(mcMMO.p.getPartyManager().isPartyFull(player, party))
{
if (mcMMO.p.getPartyManager().isPartyFull(player, party)) {
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
return;
}
@ -124,8 +123,7 @@ public final class PartyAPI {
* 0 or less for no size limit
* @return the max party size on this server
*/
public static int getMaxPartySize()
{
public static int getMaxPartySize() {
return mcMMO.p.getGeneralConfig().getPartyMaxSize();
}

View File

@ -200,14 +200,11 @@ public class McImportCommand implements CommandExecutor {
String skillName = "UNIDENTIFIED";
if (materialName.contains("ORE")) {
skillName = "Mining";
}
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
} else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
skillName = "Woodcutting";
}
else if (materialName.contains("GRASS") || materialName.contains("SHORT_GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
} else if (materialName.contains("GRASS") || materialName.contains("SHORT_GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
skillName = "Herbalism";
}
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
} else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
skillName = "Excavation";
}
@ -222,8 +219,7 @@ public class McImportCommand implements CommandExecutor {
if (skillName.equals("Mining")) {
skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
}
else if (skillName.equals("Woodcutting")) {
} else if (skillName.equals("Woodcutting")) {
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
}
}
@ -239,20 +235,15 @@ public class McImportCommand implements CommandExecutor {
String toolType = "UNIDENTIFIED";
if (materialName.contains("PICKAXE")) {
toolType = "Pickaxes";
}
else if (materialName.contains("AXE")) {
} else if (materialName.contains("AXE")) {
toolType = "Axes";
}
else if (materialName.contains("BOW")) {
} else if (materialName.contains("BOW")) {
toolType = "Bows";
}
else if (materialName.contains("HOE")) {
} else if (materialName.contains("HOE")) {
toolType = "Hoes";
}
else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
} else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
toolType = "Shovels";
}
else if (materialName.contains("SWORD")) {
} else if (materialName.contains("SWORD")) {
toolType = "Swords";
}
@ -279,14 +270,11 @@ public class McImportCommand implements CommandExecutor {
String toolType = "UNIDENTIFIED";
if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
toolType = "Boots";
}
else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
} else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
toolType = "Chestplates";
}
else if (materialName.contains("HELM") || materialName.contains("HAT")) {
} else if (materialName.contains("HELM") || materialName.contains("HAT")) {
toolType = "Helmets";
}
else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
} else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
toolType = "Leggings";
}

View File

@ -37,16 +37,14 @@ public class XprateCommand implements TabExecutor {
if (mcMMO.p.isXPEventEnabled()) {
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
{
if (mcMMO.p.getAdvancedConfig().useTitlesForXPEvent()) {
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Stop"),
LocaleLoader.getString("Commands.Event.Stop.Subtitle"),
10, 10*20, 20);
}
if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
{
if (mcMMO.p.getGeneralConfig().broadcastEventMessages()) {
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
}
@ -72,34 +70,29 @@ public class XprateCommand implements TabExecutor {
if (CommandUtils.shouldDisableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(false);
}
else if (CommandUtils.shouldEnableToggle(args[1])) {
} else if (CommandUtils.shouldEnableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(true);
}
else {
} else {
return false;
}
int newXpRate = Integer.parseInt(args[0]);
if(newXpRate < 0)
{
if (newXpRate < 0) {
sender.sendMessage(ChatColor.RED+LocaleLoader.getString("Commands.NegativeNumberWarn"));
return true;
}
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
{
if (mcMMO.p.getAdvancedConfig().useTitlesForXPEvent()) {
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"),
LocaleLoader.getString("Commands.Event.XP", newXpRate),
10, 10*20, 20);
}
if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
{
if (mcMMO.p.getGeneralConfig().broadcastEventMessages()) {
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
}

View File

@ -30,8 +30,7 @@ public class AddxpCommand extends ExperienceCommand {
return;
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
}
else {
} else {
profile.addXp(skill, value);
profile.scheduleAsyncSave();
}

View File

@ -49,15 +49,13 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null;
}
if (skill != null && SkillTools.isChildSkill(skill))
{
if (skill != null && SkillTools.isChildSkill(skill)) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true;
}
//Profile not loaded
if(UserManager.getPlayer(sender.getName()) == null)
{
if (UserManager.getPlayer(sender.getName()) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -82,8 +80,7 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null;
}
if (skill != null && SkillTools.isChildSkill(skill))
{
if (skill != null && SkillTools.isChildSkill(skill)) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true;
}
@ -110,8 +107,7 @@ public abstract class ExperienceCommand implements TabExecutor {
}
editValues(null, profile, skill, value, isSilent(args));
}
else {
} else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value, isSilent(args));
}
@ -159,8 +155,7 @@ public abstract class ExperienceCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), playerName));
}
}
@ -174,8 +169,7 @@ public abstract class ExperienceCommand implements TabExecutor {
if (player != null) {
handlePlayerMessageAll(player, value, isSilent);
}
}
else {
} else {
handleCommand(player, profile, skill, value);
if (player != null) {

View File

@ -48,8 +48,7 @@ public class SkillresetCommand implements TabExecutor {
if (args[0].equalsIgnoreCase("all")) {
skill = null;
}
else {
} else {
skill = mcMMO.p.getSkillTools().matchSkill(args[0]);
}
@ -68,8 +67,7 @@ public class SkillresetCommand implements TabExecutor {
if (args[1].equalsIgnoreCase("all")) {
skill = null;
}
else {
} else {
skill = mcMMO.p.getSkillTools().matchSkill(args[1]);
}
@ -93,8 +91,7 @@ public class SkillresetCommand implements TabExecutor {
}
editValues(null, profile, skill);
}
else {
} else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
}
@ -156,8 +153,7 @@ public class SkillresetCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), playerName));
}
}
@ -171,8 +167,7 @@ public class SkillresetCommand implements TabExecutor {
if (player != null) {
handlePlayerMessageAll(player);
}
}
else {
} else {
handleCommand(player, profile, skill);
if (player != null) {

View File

@ -12,8 +12,7 @@ import org.jetbrains.annotations.NotNull;
public class PartyChangePasswordCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}

View File

@ -90,8 +90,7 @@ public class PartyCommand implements TabExecutor {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(mcMMOPlayer == null)
{
if (mcMMOPlayer == null) {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -207,8 +206,7 @@ public class PartyCommand implements TabExecutor {
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Not Loaded
if(mcMMOPlayer == null)
{
if (mcMMOPlayer == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of();
}

View File

@ -19,8 +19,7 @@ public class PartyCreateCommand implements CommandExecutor {
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}

View File

@ -23,8 +23,7 @@ public class PartyInfoCommand implements CommandExecutor {
switch (args.length) {
case 0:
case 1:
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -70,8 +69,7 @@ public class PartyInfoCommand implements CommandExecutor {
if (isUnlockedFeature(party, partyFeature)) {
unlockedPartyFeatures.add(partyFeature.getLocaleString());
}
else {
} else {
lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString());
}
}

View File

@ -20,8 +20,7 @@ import java.util.Locale;
public class PartyItemShareCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -50,11 +49,9 @@ public class PartyItemShareCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[2])) {
toggle = true;
}
else if (CommandUtils.shouldDisableToggle(args[2])) {
} else if (CommandUtils.shouldDisableToggle(args[2])) {
toggle = false;
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true;
}

View File

@ -34,8 +34,7 @@ public class PartyJoinCommand implements CommandExecutor {
Player player = (Player) sender;
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -62,8 +61,7 @@ public class PartyJoinCommand implements CommandExecutor {
return true;
}
if(mcMMO.p.getPartyManager().isPartyFull(player, targetParty))
{
if (mcMMO.p.getPartyManager().isPartyFull(player, targetParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}

View File

@ -18,8 +18,7 @@ public class PartyLockCommand implements CommandExecutor {
case 1:
if (args[0].equalsIgnoreCase("lock")) {
togglePartyLock(sender, true);
}
else if (args[0].equalsIgnoreCase("unlock")) {
} else if (args[0].equalsIgnoreCase("unlock")) {
togglePartyLock(sender, false);
}
@ -33,11 +32,9 @@ public class PartyLockCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[1])) {
togglePartyLock(sender, true);
}
else if (CommandUtils.shouldDisableToggle(args[1])) {
} else if (CommandUtils.shouldDisableToggle(args[1])) {
togglePartyLock(sender, false);
}
else {
} else {
sendUsageStrings(sender);
}
@ -55,8 +52,7 @@ public class PartyLockCommand implements CommandExecutor {
}
private void togglePartyLock(CommandSender sender, boolean lock) {
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}

View File

@ -30,20 +30,15 @@ public enum PartySubcommandType {
if (commandName.equalsIgnoreCase("?")) {
return HELP;
}
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
} else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
return QUIT;
}
else if (commandName.equalsIgnoreCase("leader")) {
} else if (commandName.equalsIgnoreCase("leader")) {
return OWNER;
}
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
} else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
return XPSHARE;
}
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
} else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
return ITEMSHARE;
}
else if (commandName.equalsIgnoreCase("ally")) {
} else if (commandName.equalsIgnoreCase("ally")) {
return ALLIANCE;
}

View File

@ -17,8 +17,7 @@ import org.jetbrains.annotations.NotNull;
public class PartyXpShareCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}

View File

@ -37,8 +37,7 @@ public class PartyAllianceCommand implements TabExecutor {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}

View File

@ -21,8 +21,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
}

View File

@ -21,8 +21,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -56,8 +55,7 @@ public class PtpAcceptCommand implements CommandExecutor {
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true;
}
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
} else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true;
}

View File

@ -45,8 +45,7 @@ public class PtpCommand implements TabExecutor {
Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return true;
}
@ -59,8 +58,7 @@ public class PtpCommand implements TabExecutor {
return true;
}
if(UserManager.getPlayer((Player) sender) == null)
{
if (UserManager.getPlayer((Player) sender) == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -171,8 +169,7 @@ public class PtpCommand implements TabExecutor {
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return;
}
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(player, targetWorld)) {
} else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(player, targetWorld)) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return;
}
@ -228,14 +225,12 @@ public class PtpCommand implements TabExecutor {
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
if(UserManager.getPlayer(targetPlayer) == null)
{
if (UserManager.getPlayer(targetPlayer) == null) {
targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
if(UserManager.getPlayer(teleportingPlayer) == null)
{
if (UserManager.getPlayer(teleportingPlayer) == null) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
@ -250,8 +245,7 @@ public class PtpCommand implements TabExecutor {
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(teleportingPlayer, new TeleportationWarmup(mcMMOPlayer, mcMMOTarget), 20 * warmup);
}
else {
} else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}

View File

@ -21,8 +21,7 @@ public class PtpToggleCommand implements CommandExecutor {
if (ptpRecord.isEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
}

View File

@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.runnables.commands.McRankCommandAsyncTask;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@ -85,8 +85,7 @@ public class McrankCommand implements TabExecutor {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if(mcMMOPlayer == null)
{
if (mcMMOPlayer == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return;
}
@ -111,7 +110,7 @@ public class McrankCommand implements TabExecutor {
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
mcMMO.p.getFoliaLib().getImpl().runAsync(new McrankCommandAsyncTask(playerName, sender, useBoard, useChat));
mcMMO.p.getFoliaLib().getImpl().runAsync(new McRankCommandAsyncTask(playerName, sender, useBoard, useChat));
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {

View File

@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.runnables.commands.McTopCommandAsyncTask;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@ -115,7 +115,7 @@ public class MctopCommand implements TabExecutor {
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
mcMMO.p.getFoliaLib().getImpl().runAsync(new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat));
mcMMO.p.getFoliaLib().getImpl().runAsync(new McTopCommandAsyncTask(page, skill, sender, useBoard, useChat));
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {

View File

@ -29,7 +29,7 @@ public class AcrobaticsCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// ACROBATICS_DODGE
if (canDodge) {
String[] dodgeStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ACROBATICS_DODGE);
final String[] dodgeStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ACROBATICS_DODGE);
dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1];
}
@ -54,9 +54,8 @@ public class AcrobaticsCommand extends SkillCommand {
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
if(abstractSubSkill != null)
{
String[] rollStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
if (abstractSubSkill != null) {
String[] rollStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ACROBATICS_ROLL);
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollStrings[1]) : ""));

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
@ -30,14 +29,7 @@ public class AlchemyCommand extends SkillCommand {
}
protected String[] calculateAbilityDisplayValues(Player player) {
//TODO: Needed?
if(UserManager.getPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
}
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
AlchemyManager alchemyManager = mmoPlayer.getAlchemyManager();
String[] displayValues = new String[2];
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
@ -59,7 +51,7 @@ public class AlchemyCommand extends SkillCommand {
// ALCHEMY_CONCOCTIONS
if (canConcoctions) {
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
AlchemyManager alchemyManager = mmoPlayer.getAlchemyManager();
tier = alchemyManager.getTier();
ingredientCount = alchemyManager.getIngredients().size();
ingredientList = alchemyManager.getIngredientList();

View File

@ -33,14 +33,14 @@ public class ArcheryCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// ARCHERY_ARROW_RETRIEVAL
if (canRetrieve) {
String[] retrieveStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
String[] retrieveStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
// ARCHERY_DAZE
if (canDaze) {
String[] dazeStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ARCHERY_DAZE);
String[] dazeStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ARCHERY_DAZE);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
}

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
@ -38,7 +37,7 @@ public class AxesCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// ARMOR IMPACT
if (canImpact) {
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage();
impactDamage = mmoPlayer.getAxesManager().getImpactDurabilityDamage();
}
// AXE MASTERY
@ -48,7 +47,7 @@ public class AxesCommand extends SkillCommand {
// CRITICAL HIT
if (canCritical) {
String[] criticalHitStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.AXES_CRITICAL_STRIKES);
String[] criticalHitStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.AXES_CRITICAL_STRIKES);
critChance = criticalHitStrings[0];
critChanceLucky = criticalHitStrings[1];
}

View File

@ -1,9 +1,7 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@ -42,7 +40,6 @@ public class CrossbowsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if (mmoPlayer == null) {
return messages;
}

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
@ -45,7 +44,7 @@ public class ExcavationCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
ExcavationManager excavationManager = mmoPlayer.getExcavationManager();
if (canGigaDrill) {
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.Probability;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
@ -50,7 +49,7 @@ public class FishingCommand extends SkillCommand {
@Override
protected void dataCalculations(Player player, float skillValue) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = mmoPlayer.getFishingManager();
// TREASURE HUNTER
if (canTreasureHunt) {

View File

@ -49,13 +49,13 @@ public class HerbalismCommand extends SkillCommand {
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
if (canTripleDrop) {
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_VERDANT_BOUNTY);
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_VERDANT_BOUNTY);
tripleDropChance = tripleDropStrings[0];
tripleDropChanceLucky = tripleDropStrings[1];
}
@ -76,21 +76,21 @@ public class HerbalismCommand extends SkillCommand {
if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_GREEN_THUMB);
greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1];
}
// HYLIAN LUCK
if (hasHylianLuck) {
String[] hylianLuckStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
String[] hylianLuckStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_HYLIAN_LUCK);
hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1];
}
// SHROOM THUMB
if (canShroomThumb) {
String[] shroomThumbStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.HERBALISM_SHROOM_THUMB);
String[] shroomThumbStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_SHROOM_THUMB);
shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1];
}

View File

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

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@ -45,7 +44,7 @@ public class MiningCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = mmoPlayer.getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier();
@ -57,14 +56,14 @@ public class MiningCommand extends SkillCommand {
// Mastery TRIPLE DROPS
if (canTripleDrop) {
String[] masteryTripleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.MINING_MOTHER_LODE);
String[] masteryTripleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.MINING_MOTHER_LODE);
tripleDropChance = masteryTripleDropStrings[0];
tripleDropChanceLucky = masteryTripleDropStrings[1];
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.MINING_DOUBLE_DROPS);
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.MINING_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}

View File

@ -26,15 +26,12 @@ public class MmoInfoCommand implements TabExecutor {
/*
* Only allow players to use this command
*/
if(commandSender instanceof Player player)
{
if (commandSender instanceof Player player) {
if (args == null || args.length < 1 || args[0] == null || args[0].isEmpty())
return false;
if(Permissions.mmoinfo(player))
{
if(args[0].equalsIgnoreCase( "???"))
{
if (Permissions.mmoinfo(player)) {
if (args[0].equalsIgnoreCase( "???")) {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
@ -57,8 +54,7 @@ public class MmoInfoCommand implements TabExecutor {
}
public SubSkillType matchSubSkill(String name) {
for(SubSkillType subSkillType : SubSkillType.values())
{
for(SubSkillType subSkillType : SubSkillType.values()) {
if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(name)
|| subSkillType.name().equalsIgnoreCase(name))
return subSkillType;
@ -74,8 +70,7 @@ public class MmoInfoCommand implements TabExecutor {
return ImmutableList.of();
}
private void displayInfo(Player player, SubSkillType subSkillType)
{
private void displayInfo(Player player, SubSkillType subSkillType) {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillType.getLocaleName()));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@ -68,7 +67,7 @@ public class RepairCommand extends SkillCommand {
// SUPER REPAIR
if (canSuperRepair) {
String[] superRepairStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.REPAIR_SUPER_REPAIR);
String[] superRepairStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.REPAIR_SUPER_REPAIR);
superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1];
}
@ -94,7 +93,7 @@ public class RepairCommand extends SkillCommand {
List<String> messages = new ArrayList<>();
if (canArcaneForge) {
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
RepairManager repairManager = mmoPlayer.getRepairManager();
messages.add(getStatMessage(false, true,
SubSkillType.REPAIR_ARCANE_FORGING,

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
@ -38,7 +37,7 @@ public class SalvageCommand extends SkillCommand {
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
SalvageManager salvageManager = mmoPlayer.getSalvageManager();
if (canScrapCollector) {
messages.add(getStatMessage(false, true,

View File

@ -34,6 +34,7 @@ public abstract class SkillCommand implements TabExecutor {
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
protected McMMOPlayer mmoPlayer;
private final CommandExecutor skillGuideCommand;
@ -53,9 +54,9 @@ public abstract class SkillCommand implements TabExecutor {
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
mmoPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
if (mmoPlayer == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
@ -63,7 +64,7 @@ public abstract class SkillCommand implements TabExecutor {
if (args.length == 0) {
boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = PerksUtils.handleActivationPerks(player, 0, 0) != 0;
float skillValue = mcMMOPlayer.getSkillLevel(skill);
float skillValue = mmoPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
if (mcMMO.p.getAdvancedConfig().doesSkillCommandSendBlankLines())
@ -75,7 +76,7 @@ public abstract class SkillCommand implements TabExecutor {
dataCalculations(player, skillValue);
sendSkillCommandHeader(mcMMO.p.getSkillTools().getLocalizedSkillName(skill),
player, mcMMOPlayer, (int) skillValue);
player, mmoPlayer, (int) skillValue);
//Make JSON text components
List<Component> subskillTextComponents = getTextComponents(player);
@ -87,8 +88,7 @@ public abstract class SkillCommand implements TabExecutor {
TextComponentFactory.sendPlayerSubSkillList(player, subskillTextComponents);
/*for(TextComponent tc : subskillTextComponents)
{
/*for(TextComponent tc : subskillTextComponents) {
player.spigot().sendMessage(new TextComponent[]{tc, new TextComponent(": TESTING")});
}*/
@ -148,8 +148,7 @@ public abstract class SkillCommand implements TabExecutor {
// send header
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
if(!SkillTools.isChildSkill(skill))
{
if (!SkillTools.isChildSkill(skill)) {
/*
* NON-CHILD SKILLS
*/
@ -174,10 +173,8 @@ public abstract class SkillCommand implements TabExecutor {
StringBuilder parentMessage = new StringBuilder();
for(int i = 0; i < parentList.size(); i++)
{
if(i+1 < parentList.size())
{
for(int i = 0; i < parentList.size(); i++) {
if (i+1 < parentList.size()) {
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", mcMMO.p.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i))));
parentMessage.append(ChatColor.GRAY).append(", ");
} else {
@ -236,11 +233,9 @@ public abstract class SkillCommand implements TabExecutor {
int length;
if(abilityLengthCap <= 0)
{
if (abilityLengthCap <= 0) {
length = 2 + (int) (skillValue / abilityLengthVar);
}
else {
} else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
}
@ -253,20 +248,17 @@ public abstract class SkillCommand implements TabExecutor {
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
}
protected String getStatMessage(SubSkillType subSkillType, String... vars)
{
protected String getStatMessage(SubSkillType subSkillType, String... vars) {
return getStatMessage(false, false, subSkillType, vars);
}
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars)
{
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) {
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
if (isCustom)
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars));
else
{
else {
String[] mergedList = NotificationManager.addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
return LocaleLoader.getString(templateKey, mergedList);
}

View File

@ -77,8 +77,7 @@ public class SkillGuideCommand implements CommandExecutor {
while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add("");
}
else {
} else {
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
}
}

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@ -34,7 +33,7 @@ public class SmeltingCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
burnTimeModifier = String.valueOf(mmoPlayer.getSmeltingManager().getFuelEfficiencyMultiplier());
}
// FLUX MINING
@ -46,7 +45,7 @@ public class SmeltingCommand extends SkillCommand {
// SECOND SMELT
if (canSecondSmelt) {
String[] secondSmeltStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.SMELTING_SECOND_SMELT);
String[] secondSmeltStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.SMELTING_SECOND_SMELT);
str_secondSmeltChance = secondSmeltStrings[0];
str_secondSmeltChanceLucky = secondSmeltStrings[1];
}
@ -81,7 +80,7 @@ public class SmeltingCommand extends SkillCommand {
if (canUnderstandTheArt) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
String.valueOf(mmoPlayer.getSmeltingManager().getVanillaXpMultiplier())));
}
return messages;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
@ -39,7 +38,7 @@ public class SwordsCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// SWORDS_COUNTER_ATTACK
if (canCounter) {
String[] counterStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.SWORDS_COUNTER_ATTACK);
String[] counterStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.SWORDS_COUNTER_ATTACK);
counterChance = counterStrings[0];
counterChanceLucky = counterStrings[1];
}
@ -102,10 +101,9 @@ public class SwordsCommand extends SkillCommand {
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
if(SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_STAB))
{
if (SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_STAB)) {
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage())));
String.valueOf(mmoPlayer.getSwordsManager().getStabDamage())));
}
if (SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {

View File

@ -35,7 +35,7 @@ public class TamingCommand extends SkillCommand {
@Override
protected void dataCalculations(Player player, float skillValue) {
if (canGore) {
String[] goreStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.TAMING_GORE);
String[] goreStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.TAMING_GORE);
goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1];
}

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.text.TextComponentFactory;
@ -32,10 +30,6 @@ public class TridentsCommand extends SkillCommand {
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if (mmoPlayer == null) {
return messages;
}
if (SkillUtils.canUseSubskill(player, TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
messages.add(getStatMessage(TRIDENTS_TRIDENTS_LIMIT_BREAK,

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
@ -40,7 +39,7 @@ public class UnarmedCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// UNARMED_ARROW_DEFLECT
if (canDeflect) {
String[] deflectStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.UNARMED_ARROW_DEFLECT);
String[] deflectStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.UNARMED_ARROW_DEFLECT);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
}
@ -54,19 +53,19 @@ public class UnarmedCommand extends SkillCommand {
// UNARMED_DISARM
if (canDisarm) {
String[] disarmStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.UNARMED_DISARM);
String[] disarmStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.UNARMED_DISARM);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
}
// IRON ARM
if (canIronArm) {
ironArmBonus = UserManager.getPlayer(player).getUnarmedManager().getSteelArmStyleDamage();
ironArmBonus = mmoPlayer.getUnarmedManager().getSteelArmStyleDamage();
}
// IRON GRIP
if (canIronGrip) {
String[] ironGripStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.UNARMED_IRON_GRIP);
String[] ironGripStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.UNARMED_IRON_GRIP);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}

View File

@ -41,7 +41,7 @@ public class WoodcuttingCommand extends SkillCommand {
//Clean Cuts
if (canTripleDrop) {
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.WOODCUTTING_CLEAN_CUTS);
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.WOODCUTTING_CLEAN_CUTS);
tripleDropChance = tripleDropStrings[0];
tripleDropChanceLucky = tripleDropStrings[1];
}
@ -55,7 +55,7 @@ public class WoodcuttingCommand extends SkillCommand {
}
private void setDoubleDropClassicChanceStrings(Player player) {
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}

View File

@ -504,8 +504,7 @@ public class AdvancedConfig extends BukkitConfig {
*/
/*public ChatColor getJSONStatHoverElementColor(StatType statType, boolean isPrefix)
{
/*public ChatColor getJSONStatHoverElementColor(StatType statType, boolean isPrefix) {
String keyAddress = isPrefix ? "Prefix" : "Value";
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Color";
@ -517,50 +516,41 @@ public class AdvancedConfig extends BukkitConfig {
*
* @return the ChatColor for this element
*/
/*public ChatColor getJSONStatHoverDetailsColor()
{
/*public ChatColor getJSONStatHoverDetailsColor() {
String keyLocation = "Style.JSON.Hover.Details.Header.Color";
return getChatColorFromKey(keyLocation);
}
public boolean isJSONDetailsHeaderBold()
{
public boolean isJSONDetailsHeaderBold() {
return config.getBoolean("Style.JSON.Hover.Details.Header.Bold");
}
public boolean isJSONDetailsHeaderItalic()
{
public boolean isJSONDetailsHeaderItalic() {
return config.getBoolean("Style.JSON.Hover.Details.Header.Italics");
}
public boolean isJSONDetailsHeaderUnderlined()
{
public boolean isJSONDetailsHeaderUnderlined() {
return config.getBoolean("Style.JSON.Hover.Details.Header.Underlined");
}
public ChatColor getJSONStatHoverDescriptionColor()
{
public ChatColor getJSONStatHoverDescriptionColor() {
String keyLocation = "Style.JSON.Hover.Details.Description.Color";
return getChatColorFromKey(keyLocation);
}
public boolean isJSONDetailsDescriptionBold()
{
public boolean isJSONDetailsDescriptionBold() {
return config.getBoolean("Style.JSON.Hover.Details.Description.Bold");
}
public boolean isJSONDetailsDescriptionItalic()
{
public boolean isJSONDetailsDescriptionItalic() {
return config.getBoolean("Style.JSON.Hover.Details.Description.Italics");
}
public boolean isJSONDetailsDescriptionUnderlined()
{
public boolean isJSONDetailsDescriptionUnderlined() {
return config.getBoolean("Style.JSON.Hover.Details.Description.Underlined");
}
public ChatColor getJSONActionBarColor(NotificationType notificationType)
{
public ChatColor getJSONActionBarColor(NotificationType notificationType) {
return getChatColor(config.getString("Style.JSON.Notification."+notificationType.toString()+".Color"));
}*/
private ChatColor getChatColorFromKey(String keyLocation) {
@ -580,22 +570,19 @@ public class AdvancedConfig extends BukkitConfig {
return ChatColor.WHITE;
}
/*public boolean isJSONStatHoverElementBold(StatType statType, boolean isPrefix)
{
/*public boolean isJSONStatHoverElementBold(StatType statType, boolean isPrefix) {
String keyAddress = isPrefix ? "Prefix" : "Value";
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Bold";
return config.getBoolean(keyLocation);
}
public boolean isJSONStatHoverElementItalic(StatType statType, boolean isPrefix)
{
public boolean isJSONStatHoverElementItalic(StatType statType, boolean isPrefix) {
String keyAddress = isPrefix ? "Prefix" : "Value";
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Italics";
return config.getBoolean(keyLocation);
}
public boolean isJSONStatHoverElementUnderlined(StatType statType, boolean isPrefix)
{
public boolean isJSONStatHoverElementUnderlined(StatType statType, boolean isPrefix) {
String keyAddress = isPrefix ? "Prefix" : "Value";
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Underline";
return config.getBoolean(keyLocation);

View File

@ -4,31 +4,40 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.VisibleForTesting;
import java.io.File;
import java.util.List;
@Deprecated
public abstract class LegacyConfigLoader {
protected final File configFile;
protected final @NotNull File configFile;
protected final @NotNull File dataFolder;
protected String fileName;
protected @NotNull String fileName;
protected YamlConfiguration config;
public LegacyConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) {
public LegacyConfigLoader(@NotNull String relativePath, @NotNull String fileName, @NotNull File dataFolder) {
this.fileName = fileName;
this.dataFolder = dataFolder;
configFile = new File(dataFolder, relativePath + File.separator + fileName);
loadFile();
}
public LegacyConfigLoader(String fileName, @NotNull File dataFolder) {
public LegacyConfigLoader(@NotNull String fileName, @NotNull File dataFolder) {
this.fileName = fileName;
this.dataFolder = dataFolder;
configFile = new File(dataFolder, fileName);
loadFile();
}
@VisibleForTesting
public LegacyConfigLoader(@NotNull File file) {
this.fileName = file.getName();
this.dataFolder = file.getParentFile();
configFile = new File(dataFolder, fileName);
loadFile();
}
@Deprecated
public LegacyConfigLoader(String relativePath, String fileName) {
this.fileName = fileName;

View File

@ -467,7 +467,7 @@ public class ExperienceConfig extends BukkitConfig {
/* Alchemy */
public double getPotionXP(PotionStage stage) {
return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D);
return config.getDouble("Experience_Values.Alchemy.Potion_Brewing.Stage_" + stage.toNumerical(), 10D);
}
/* Archery */

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.config.mods;
import com.gmail.nossr50.config.LegacyConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
import com.gmail.nossr50.mcMMO;
import org.apache.commons.lang.ClassUtils;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -30,7 +29,7 @@ public class CustomEntityLegacyConfig extends LegacyConfigLoader {
String className = config.getString(entityName + ".Class", "");
try {
clazz = ClassUtils.getClass(className);
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
mcMMO.p.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
mcMMO.p.getLogger().warning("This custom entity may not function properly.");

View File

@ -3,21 +3,29 @@ package com.gmail.nossr50.config.skills.alchemy;
import com.gmail.nossr50.config.LegacyConfigLoader;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.ItemUtils;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.*;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.VisibleForTesting;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.gmail.nossr50.util.ItemUtils.setItemName;
import static com.gmail.nossr50.util.PotionUtil.*;
public class PotionConfig extends LegacyConfigLoader {
private static PotionConfig instance;
private final List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<>();
@ -28,30 +36,34 @@ public class PotionConfig extends LegacyConfigLoader {
private final List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<>();
private final List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<>();
private final Map<String, AlchemyPotion> potionMap = new HashMap<>();
/**
* Map of potion names to AlchemyPotion objects.
*/
private final Map<String, AlchemyPotion> alchemyPotions = new HashMap<>();
private PotionConfig() {
public PotionConfig() {
super("potions.yml");
loadKeys();
}
public static PotionConfig getInstance() {
if (instance == null) {
instance = new PotionConfig();
}
return instance;
@VisibleForTesting
PotionConfig(File file) {
super(file);
}
@Override
protected void loadKeys() {
}
public void loadPotions() {
loadConcoctions();
loadPotionMap();
}
private void loadConcoctions() {
ConfigurationSection concoctionSection = config.getConfigurationSection("Concoctions");
@VisibleForTesting
void loadConcoctions() {
final ConfigurationSection concoctionSection = config.getConfigurationSection("Concoctions");
// Load the ingredients for each tier
loadConcoctionsTier(concoctionsIngredientsTierOne, concoctionSection.getStringList("Tier_One_Ingredients"));
loadConcoctionsTier(concoctionsIngredientsTierTwo, concoctionSection.getStringList("Tier_Two_Ingredients"));
loadConcoctionsTier(concoctionsIngredientsTierThree, concoctionSection.getStringList("Tier_Three_Ingredients"));
@ -71,7 +83,7 @@ public class PotionConfig extends LegacyConfigLoader {
}
private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredientStrings) {
if (ingredientStrings != null && ingredientStrings.size() > 0) {
if (ingredientStrings != null && !ingredientStrings.isEmpty()) {
for (String ingredientString : ingredientStrings) {
ItemStack ingredient = loadIngredient(ingredientString);
@ -85,23 +97,24 @@ public class PotionConfig extends LegacyConfigLoader {
/**
* Find the Potions configuration section and load all defined potions.
*/
private void loadPotionMap() {
int loadPotionMap() {
ConfigurationSection potionSection = config.getConfigurationSection("Potions");
int pass = 0;
int fail = 0;
int potionsLoaded = 0;
int failures = 0;
for (String potionName : potionSection.getKeys(false)) {
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(potionName));
if (potion != null) {
potionMap.put(potionName, potion);
pass++;
alchemyPotions.put(potionName, potion);
potionsLoaded++;
} else {
fail++;
failures++;
}
}
LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
mcMMO.p.getLogger().info("Loaded " + potionsLoaded + " Alchemy potions, skipped " + failures + ".");
return potionsLoaded;
}
/**
@ -114,37 +127,70 @@ public class PotionConfig extends LegacyConfigLoader {
*/
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
try {
final String key = potion_section.getName();
final ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
boolean extended = false;
boolean upgraded = false;
String name = potion_section.getString("Name");
if (name != null) {
name = ChatColor.translateAlternateColorCodes('&', name);
if (potionData != null) {
extended = potionData.getBoolean("Extended", false);
upgraded = potionData.getBoolean("Upgraded", false);
}
PotionData data;
if (!potion_section.contains("PotionData")) { // Backwards config compatability
short dataValue = Short.parseShort(potion_section.getName());
Potion potion = Potion.fromDamage(dataValue);
data = new PotionData(potion.getType(), potion.hasExtendedDuration(), potion.getLevel() == 2);
Material material;
final String materialString = potion_section.getString("Material", null);
if (materialString != null) {
material = ItemUtils.exhaustiveMaterialLookup(materialString);
if (material == null) {
mcMMO.p.getLogger().warning("PotionConfig: Failed to parse material for potion " + key + ": " + materialString);
mcMMO.p.getLogger().warning("PotionConfig: Defaulting to POTION");
material = Material.POTION;
}
} else {
ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
data = new PotionData(PotionType.valueOf(potionData.getString("PotionType", "WATER")), potionData.getBoolean("Extended", false), potionData.getBoolean("Upgraded", false));
mcMMO.p.getLogger().warning("PotionConfig: Missing Material config entry for potion " + key + "," +
" from configuration section: " + potion_section + ", defaulting to POTION");
material = Material.POTION;
}
Material material = Material.POTION;
String mat = potion_section.getString("Material", null);
if (mat != null) {
material = Material.valueOf(mat);
final ItemStack itemStack = new ItemStack(material, 1);
final PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
if (potionMeta == null) {
mcMMO.p.getLogger().severe("PotionConfig: Failed to get PotionMeta for " + key + ", from configuration section:" +
" " + potion_section);
return null;
}
List<String> lore = new ArrayList<>();
// extended and upgraded seem to be mutually exclusive
if (extended && upgraded) {
mcMMO.p.getLogger().warning("Potion " + key + " has both Extended and Upgraded set to true," +
" defaulting to Extended.");
upgraded = false;
}
String potionTypeStr = potionData.getString("PotionType", null);
if (potionTypeStr == null) {
mcMMO.p.getLogger().severe("PotionConfig: Missing PotionType for " + key + ", from configuration section:" +
" " + potion_section);
return null;
}
// This works via side effects
// TODO: Redesign later, side effects are stupid
if(!setPotionType(potionMeta, potionTypeStr, upgraded, extended)) {
mcMMO.p.getLogger().severe("PotionConfig: Failed to set parameters of potion for " + key + ": " + potionTypeStr);
return null;
}
final List<String> lore = new ArrayList<>();
if (potion_section.contains("Lore")) {
for (String line : potion_section.getStringList("Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
potionMeta.setLore(lore);
List<PotionEffect> effects = new ArrayList<>();
if (potion_section.contains("Effects")) {
for (String effect : potion_section.getStringList("Effects")) {
String[] parts = effect.split(" ");
@ -154,9 +200,9 @@ public class PotionConfig extends LegacyConfigLoader {
int duration = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;
if (type != null) {
effects.add(new PotionEffect(type, duration, amplifier));
potionMeta.addCustomEffect(new PotionEffect(type, duration, amplifier), true);
} else {
mcMMO.p.getLogger().warning("Failed to parse effect for potion " + name + ": " + effect);
mcMMO.p.getLogger().severe("PotionConfig: Failed to parse effect for potion " + key + ": " + effect);
}
}
}
@ -165,25 +211,59 @@ public class PotionConfig extends LegacyConfigLoader {
if (potion_section.contains("Color")) {
color = Color.fromRGB(potion_section.getInt("Color"));
} else {
color = this.generateColor(effects);
color = this.generateColor(potionMeta.getCustomEffects());
}
potionMeta.setColor(color);
Map<ItemStack, String> children = new HashMap<>();
final Map<ItemStack, String> children = new HashMap<>();
if (potion_section.contains("Children")) {
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
ItemStack ingredient = loadIngredient(child);
if (ingredient != null) {
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
} else {
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
mcMMO.p.getLogger().severe("PotionConfig: Failed to parse child for potion " + key + ": " + child);
}
}
}
// Set the name of the potion
setPotionDisplayName(potion_section, potionMeta);
// TODO: Might not need to .setItemMeta
itemStack.setItemMeta(potionMeta);
return new AlchemyPotion(potion_section.getName(), itemStack, children);
} catch (Exception e) {
mcMMO.p.getLogger().warning("PotionConfig: Failed to load Alchemy potion: " + potion_section.getName());
e.printStackTrace();
return null;
}
}
return new AlchemyPotion(material, data, name, lore, effects, color, children);
} catch (Exception e) {
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
return null;
private boolean setPotionType(PotionMeta potionMeta, String potionTypeStr, boolean upgraded, boolean extended) {
final PotionType potionType = matchPotionType(potionTypeStr, upgraded, extended);
if (potionType == null) {
mcMMO.p.getLogger().severe("PotionConfig: Failed to parse potion type for: " + potionTypeStr);
return false;
}
// set base
setBasePotionType(potionMeta, potionType, extended, upgraded);
// Legacy only
setUpgradedAndExtendedProperties(potionType, potionMeta, upgraded, extended);
return true;
}
private void setPotionDisplayName(ConfigurationSection section, PotionMeta potionMeta) {
// If a potion doesn't have any custom effects, there is no reason to override the vanilla name
if (potionMeta.getCustomEffects().isEmpty()) {
return;
}
final String configuredName = section.getString("Name", null);
if (configuredName != null) {
setItemName(potionMeta, configuredName);
}
}
@ -210,43 +290,63 @@ public class PotionConfig extends LegacyConfigLoader {
return null;
}
/**
* Get the ingredients for the given tier.
* @param tier Tier to get ingredients for.
* @return List of ingredients for the given tier.
*/
public List<ItemStack> getIngredients(int tier) {
switch (tier) {
case 8:
return concoctionsIngredientsTierEight;
case 7:
return concoctionsIngredientsTierSeven;
case 6:
return concoctionsIngredientsTierSix;
case 5:
return concoctionsIngredientsTierFive;
case 4:
return concoctionsIngredientsTierFour;
case 3:
return concoctionsIngredientsTierThree;
case 2:
return concoctionsIngredientsTierTwo;
case 1:
default:
return concoctionsIngredientsTierOne;
}
return switch (tier) {
case 8 -> concoctionsIngredientsTierEight;
case 7 -> concoctionsIngredientsTierSeven;
case 6 -> concoctionsIngredientsTierSix;
case 5 -> concoctionsIngredientsTierFive;
case 4 -> concoctionsIngredientsTierFour;
case 3 -> concoctionsIngredientsTierThree;
case 2 -> concoctionsIngredientsTierTwo;
default -> concoctionsIngredientsTierOne;
};
}
/**
* Check if the given ItemStack is a valid potion.
* @param item ItemStack to be checked.
* @return True if the given ItemStack is a valid potion, false otherwise.
*/
public boolean isValidPotion(ItemStack item) {
return getPotion(item) != null;
}
/**
* Get the AlchemyPotion that corresponds to the given name.
* @param name Name of the potion to be checked.
* @return AlchemyPotion that corresponds to the given name.
*/
public AlchemyPotion getPotion(String name) {
return potionMap.get(name);
return alchemyPotions.get(name);
}
/**
* Get the AlchemyPotion that corresponds to the given ItemStack.
*
* @param item ItemStack to be checked.
*
* @return AlchemyPotion that corresponds to the given ItemStack.
*/
public AlchemyPotion getPotion(ItemStack item) {
for (AlchemyPotion potion : potionMap.values()) {
if (potion.isSimilar(item)) {
return potion;
final List<AlchemyPotion> potionList = alchemyPotions.values()
.stream()
.filter(potion -> potion.isSimilarPotion(item))
.toList();
if(potionList.size() > 1) {
mcMMO.p.getLogger().severe("Multiple potions defined in config have matched this potion, for mcMMO to behave" +
" properly there should only be one match found.");
mcMMO.p.getLogger().severe("Potion ItemStack:" + item.toString());
mcMMO.p.getLogger().severe("Alchemy Potions from config matching this item: "
+ potionList.stream().map(AlchemyPotion::toString).collect(Collectors.joining(", ")));
}
}
return null;
return potionList.isEmpty() ? null : potionList.get(0);
}
public Color generateColor(List<PotionEffect> effects) {
@ -278,5 +378,4 @@ public class PotionConfig extends LegacyConfigLoader {
}
return Color.fromRGB(red / colors.size(), green / colors.size(), blue / colors.size());
}
}

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.treasure.*;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EnchantmentUtils;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.PotionUtil;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -13,12 +14,13 @@ import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import static com.gmail.nossr50.util.PotionUtil.matchPotionType;
public class FishingTreasureConfig extends BukkitConfig {
public static final String FILENAME = "fishing_treasures.yml";
@ -204,30 +206,40 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (materialName.contains("POTION")) {
// Update for 1.20.5
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
reason.add("Potion format for " + FILENAME + " has changed");
continue;
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
if (itemMeta == null) {
mcMMO.p.getLogger().severe("Item meta when adding potion to fishing treasure was null, contact the mcMMO devs!");
if (potionMeta == null) {
mcMMO.p.getLogger().severe("FishingConfig: Item meta when adding potion to fishing treasure was null," +
" contact the mcMMO devs!");
reason.add("FishingConfig: Item meta when adding potion to fishing treasure was null");
continue;
}
PotionType potionType = null;
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
String potionTypeStr;
potionTypeStr = config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER");
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
final PotionType potionType = matchPotionType(potionTypeStr, extended, upgraded);
if (potionType == null) {
reason.add("FishingConfig: Could not derive potion type from: " + potionTypeStr +", " + extended + ", " + upgraded);
continue;
}
// Set the base potion type
// NOTE: Upgraded/Extended are ignored in 1.20.5 and later
PotionUtil.setBasePotionType(potionMeta, potionType, upgraded, extended);
if (customName != null) {
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
potionMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
}
if (config.contains(type + "." + treasureName + ".Lore")) {
@ -235,9 +247,9 @@ public class FishingTreasureConfig extends BukkitConfig {
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
itemMeta.setLore(lore);
potionMeta.setLore(lore);
}
item.setItemMeta(itemMeta);
item.setItemMeta(potionMeta);
}
} else if (material == Material.ENCHANTED_BOOK) {
//If any whitelisted enchants exist we use whitelist-based matching
@ -355,7 +367,8 @@ public class FishingTreasureConfig extends BukkitConfig {
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
if (enchantment == null) {
mcMMO.p.getLogger().warning("Skipping invalid enchantment in " + FILENAME + ": " + enchantmentName);
mcMMO.p.getLogger().info("Skipping invalid enchantment in '" + FILENAME + "', named:"
+ enchantmentName);
continue;
}

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.PotionUtil;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -14,7 +15,6 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import java.io.IOException;
@ -165,22 +165,33 @@ public class TreasureConfig extends BukkitConfig {
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
reason.add("Potion format for " + FILENAME + " has changed");
continue;
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
PotionType potionType = null;
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
if (potionMeta == null) {
mcMMO.p.getLogger().severe("Item meta when adding potion to treasure was null, contact the mcMMO devs!");
reason.add("Item meta when adding potion to treasure was null, contact the mcMMO devs!");
continue;
}
String potionTypeStr;
potionTypeStr = config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER");
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
PotionType potionType = PotionUtil.matchPotionType(potionTypeStr, extended, upgraded);
if (potionType == null) {
reason.add("Could not derive potion type from: " + potionTypeStr +", " + extended + ", " + upgraded);
continue;
}
// Set the base potion type
// NOTE: extended/upgraded are ignored in 1.20.5 and later
PotionUtil.setBasePotionType(potionMeta, potionType, extended, upgraded);
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
potionMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
}
if (config.contains(type + "." + treasureName + ".Lore")) {
@ -188,9 +199,9 @@ public class TreasureConfig extends BukkitConfig {
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
itemMeta.setLore(lore);
potionMeta.setLore(lore);
}
item.setItemMeta(itemMeta);
item.setItemMeta(potionMeta);
}
} else if (material != null) {
item = new ItemStack(material, amount, data);

View File

@ -253,68 +253,26 @@ public class FlatFileDataProcessor {
}
public static @NotNull ExpectedType getExpectedValueType(int dataIndex) throws IndexOutOfBoundsException {
switch(dataIndex) {
case USERNAME_INDEX:
return ExpectedType.STRING;
case 2: //Assumption: Used to be for something, no longer used
case 3: //Assumption: Used to be for something, no longer used
case 23: //Assumption: Used to be used for something, no longer used
case 33: //Assumption: Used to be used for something, no longer used
case HEALTHBAR:
case LEGACY_LAST_LOGIN:
return ExpectedType.IGNORED;
case SKILLS_MINING:
case SKILLS_REPAIR:
case SKILLS_UNARMED:
case SKILLS_HERBALISM:
case SKILLS_EXCAVATION:
case SKILLS_ARCHERY:
case SKILLS_SWORDS:
case SKILLS_AXES:
case SKILLS_WOODCUTTING:
case SKILLS_ACROBATICS:
case SKILLS_TAMING:
case SKILLS_FISHING:
case SKILLS_ALCHEMY:
case SKILLS_CROSSBOWS:
case SKILLS_TRIDENTS:
case COOLDOWN_BERSERK:
case COOLDOWN_GIGA_DRILL_BREAKER:
case COOLDOWN_TREE_FELLER:
case COOLDOWN_GREEN_TERRA:
case COOLDOWN_SERRATED_STRIKES:
case COOLDOWN_SKULL_SPLITTER:
case COOLDOWN_SUPER_BREAKER:
case COOLDOWN_BLAST_MINING:
case SCOREBOARD_TIPS:
case COOLDOWN_CHIMAERA_WING:
case COOLDOWN_SUPER_SHOTGUN:
case COOLDOWN_TRIDENTS:
case COOLDOWN_ARCHERY:
return ExpectedType.INTEGER;
case EXP_MINING:
case EXP_WOODCUTTING:
case EXP_REPAIR:
case EXP_UNARMED:
case EXP_HERBALISM:
case EXP_EXCAVATION:
case EXP_ARCHERY:
case EXP_SWORDS:
case EXP_AXES:
case EXP_ACROBATICS:
case EXP_TAMING:
case EXP_FISHING:
case EXP_ALCHEMY:
case EXP_CROSSBOWS:
case EXP_TRIDENTS:
return ExpectedType.FLOAT;
case UUID_INDEX:
return ExpectedType.UUID;
case OVERHAUL_LAST_LOGIN:
return ExpectedType.LONG;
}
throw new IndexOutOfBoundsException();
return switch (dataIndex) {
case USERNAME_INDEX -> ExpectedType.STRING; //Assumption: Used to be for something, no longer used
//Assumption: Used to be for something, no longer used
//Assumption: Used to be used for something, no longer used
//Assumption: Used to be used for something, no longer used
case 2, 3, 23, 33, HEALTHBAR, LEGACY_LAST_LOGIN -> ExpectedType.IGNORED;
case SKILLS_MINING, SKILLS_REPAIR, SKILLS_UNARMED, SKILLS_HERBALISM, SKILLS_EXCAVATION, SKILLS_ARCHERY,
SKILLS_SWORDS, SKILLS_AXES, SKILLS_WOODCUTTING, SKILLS_ACROBATICS, SKILLS_TAMING, SKILLS_FISHING,
SKILLS_ALCHEMY, SKILLS_CROSSBOWS, SKILLS_TRIDENTS, SKILLS_MACES, COOLDOWN_BERSERK,
COOLDOWN_GIGA_DRILL_BREAKER, COOLDOWN_TREE_FELLER, COOLDOWN_GREEN_TERRA, COOLDOWN_SERRATED_STRIKES,
COOLDOWN_SKULL_SPLITTER, COOLDOWN_SUPER_BREAKER, COOLDOWN_BLAST_MINING, SCOREBOARD_TIPS,
COOLDOWN_CHIMAERA_WING, COOLDOWN_SUPER_SHOTGUN, COOLDOWN_TRIDENTS, COOLDOWN_ARCHERY, COOLDOWN_MACES ->
ExpectedType.INTEGER;
case EXP_MINING, EXP_WOODCUTTING, EXP_REPAIR, EXP_UNARMED, EXP_HERBALISM, EXP_EXCAVATION, EXP_ARCHERY,
EXP_SWORDS, EXP_AXES, EXP_ACROBATICS, EXP_TAMING, EXP_FISHING, EXP_ALCHEMY, EXP_CROSSBOWS,
EXP_TRIDENTS, EXP_MACES -> ExpectedType.FLOAT;
case UUID_INDEX -> ExpectedType.UUID;
case OVERHAUL_LAST_LOGIN -> ExpectedType.LONG;
default -> throw new IndexOutOfBoundsException();
};
}
public @NotNull List<FlatFileDataContainer> getFlatFileDataContainers() {
@ -342,7 +300,7 @@ public class FlatFileDataProcessor {
//We add a trailing : as it is needed for some reason (is it?)
//TODO: Is the trailing ":" actually necessary?
String fromSplit = org.apache.commons.lang.StringUtils.join(splitData, ":") + ":";
String fromSplit = org.apache.commons.lang3.StringUtils.join(splitData, ":") + ":";
stringBuilder.append(fromSplit).append("\r\n");
}

View File

@ -87,8 +87,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
public static final int COOLDOWN_SUPER_SHOTGUN = 49;
public static final int COOLDOWN_TRIDENTS = 50;
public static final int COOLDOWN_ARCHERY = 51;
public static final int EXP_MACES = 52;
public static final int SKILLS_MACES = 53;
public static final int COOLDOWN_MACES = 54;
//Update this everytime new data is added
public static final int DATA_ENTRY_COUNT = COOLDOWN_ARCHERY + 1;
public static final int DATA_ENTRY_COUNT = COOLDOWN_MACES + 1;
FlatFileDatabaseManager(@NotNull File usersFile, @NotNull Logger logger, long purgeTime, int startingLevel, boolean testing) {
this.usersFile = usersFile;
@ -149,8 +152,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
// If they're still around, rewrite them to the file.
if (!powerless) {
writer.append(line).append("\r\n");
}
else {
} else {
purgedUsers++;
}
}
@ -231,7 +233,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
if (rewrite) {
// Rewrite their data with a valid time
character[OVERHAUL_LAST_LOGIN] = Long.toString(lastPlayed);
String newLine = org.apache.commons.lang.StringUtils.join(character, ":");
String newLine = org.apache.commons.lang3.StringUtils.join(character, ":");
writer.append(newLine).append("\r\n");
} else {
writer.append(line).append("\r\n");
@ -478,6 +480,18 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.CROSSBOWS))).append(":");
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.TRIDENTS))).append(":");
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.TRIDENTS))).append(":");
// public static final int COOLDOWN_SUPER_SHOTGUN = 49;
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.SUPER_SHOTGUN))).append(":");
// public static final int COOLDOWN_TRIDENTS = 50;
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.TRIDENTS_SUPER_ABILITY))).append(":");
// public static final int COOLDOWN_ARCHERY = 51;
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.EXPLOSIVE_SHOT))).append(":");
// public static final int EXP_MACES = 52;
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.MACES))).append(":");
// public static final int SKILLS_MACES = 53;
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.MACES))).append(":");
// public static final int COOLDOWN_MACES = 54;
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.MACES_SUPER_ABILITY))).append(":");
appendable.append("\r\n");
}
@ -890,7 +904,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
}
character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME_INDEX]).toString();
line = org.apache.commons.lang.StringUtils.join(character, ":") + ":";
line = org.apache.commons.lang3.StringUtils.join(character, ":") + ":";
}
i++;
@ -987,6 +1001,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
List<PlayerStat> alchemy = new ArrayList<>();
List<PlayerStat> crossbows = new ArrayList<>();
List<PlayerStat> tridents = new ArrayList<>();
List<PlayerStat> maces = new ArrayList<>();
BufferedReader in = null;
String playerName = null;
@ -1022,6 +1037,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
powerLevel += putStat(woodcutting, playerName, skills.get(PrimarySkillType.WOODCUTTING));
powerLevel += putStat(crossbows, playerName, skills.get(PrimarySkillType.CROSSBOWS));
powerLevel += putStat(tridents, playerName, skills.get(PrimarySkillType.TRIDENTS));
powerLevel += putStat(maces, playerName, skills.get(PrimarySkillType.MACES));
putStat(powerLevels, playerName, powerLevel);
}
@ -1059,6 +1075,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
alchemy.sort(c);
crossbows.sort(c);
tridents.sort(c);
maces.sort(c);
powerLevels.sort(c);
playerStatHash.put(PrimarySkillType.MINING, mining);
@ -1076,6 +1093,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
playerStatHash.put(PrimarySkillType.ALCHEMY, alchemy);
playerStatHash.put(PrimarySkillType.CROSSBOWS, crossbows);
playerStatHash.put(PrimarySkillType.TRIDENTS, tridents);
playerStatHash.put(PrimarySkillType.MACES, maces);
return LeaderboardStatus.UPDATED;
}
@ -1239,6 +1257,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.ALCHEMY, EXP_ALCHEMY, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.CROSSBOWS, EXP_CROSSBOWS, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.TRIDENTS, EXP_TRIDENTS, username);
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.MACES, EXP_MACES, username);
// Taming - Unused
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SUPER_BREAKER, COOLDOWN_SUPER_BREAKER, username);
@ -1254,6 +1273,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.BLAST_MINING, COOLDOWN_BLAST_MINING, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SUPER_SHOTGUN, COOLDOWN_SUPER_SHOTGUN, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.TRIDENTS_SUPER_ABILITY, COOLDOWN_TRIDENTS, username);
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.MACES_SUPER_ABILITY, COOLDOWN_MACES, username);
UUID uuid;
try {
@ -1343,6 +1363,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ALCHEMY, SKILLS_ALCHEMY, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.CROSSBOWS, SKILLS_CROSSBOWS, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.TRIDENTS, SKILLS_TRIDENTS, username);
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.MACES, SKILLS_MACES, username);
return skills;
}

View File

@ -169,7 +169,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "taming = 0 AND mining = 0 AND woodcutting = 0 AND repair = 0 "
+ "AND unarmed = 0 AND herbalism = 0 AND excavation = 0 AND "
+ "archery = 0 AND swords = 0 AND axes = 0 AND acrobatics = 0 "
+ "AND fishing = 0 AND alchemy = 0 AND crossbows = 0 AND tridents = 0;");
+ "AND fishing = 0 AND alchemy = 0 AND crossbows = 0 AND tridents = 0 AND maces = 0;");
statement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "experience`.`user_id` = `s`.`user_id`)");
statement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "huds`.`user_id` = `s`.`user_id`)");
@ -291,7 +291,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ?, total = ? WHERE user_id = ?");
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ?, maces = ?, total = ? WHERE user_id = ?");
statement.setInt(1, profile.getSkillLevel(PrimarySkillType.TAMING));
statement.setInt(2, profile.getSkillLevel(PrimarySkillType.MINING));
statement.setInt(3, profile.getSkillLevel(PrimarySkillType.REPAIR));
@ -307,11 +307,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(13, profile.getSkillLevel(PrimarySkillType.ALCHEMY));
statement.setInt(14, profile.getSkillLevel(PrimarySkillType.CROSSBOWS));
statement.setInt(15, profile.getSkillLevel(PrimarySkillType.TRIDENTS));
statement.setInt(16, profile.getSkillLevel(PrimarySkillType.MACES));
int total = 0;
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS)
total += profile.getSkillLevel(primarySkillType);
statement.setInt(16, total);
statement.setInt(17, id);
statement.setInt(17, total);
statement.setInt(18, id);
success &= (statement.executeUpdate() != 0);
statement.close();
if (!success) {
@ -323,7 +324,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ? WHERE user_id = ?");
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ?, maces = ? WHERE user_id = ?");
statement.setInt(1, profile.getSkillXpLevel(PrimarySkillType.TAMING));
statement.setInt(2, profile.getSkillXpLevel(PrimarySkillType.MINING));
statement.setInt(3, profile.getSkillXpLevel(PrimarySkillType.REPAIR));
@ -339,7 +340,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(13, profile.getSkillXpLevel(PrimarySkillType.ALCHEMY));
statement.setInt(14, profile.getSkillXpLevel(PrimarySkillType.CROSSBOWS));
statement.setInt(15, profile.getSkillXpLevel(PrimarySkillType.TRIDENTS));
statement.setInt(16, id);
statement.setInt(16, profile.getSkillXpLevel(PrimarySkillType.MACES));
statement.setInt(17, id);
success &= (statement.executeUpdate() != 0);
statement.close();
if (!success) {
@ -350,7 +352,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?"
+ ", herbalism = ?, excavation = ?, swords = ?"
+ ", axes = ?, blast_mining = ?, chimaera_wing = ?, crossbows = ?, tridents = ? WHERE user_id = ?");
+ ", axes = ?, blast_mining = ?, chimaera_wing = ?, crossbows = ?"
+ ", tridents = ?, maces = ? WHERE user_id = ?");
statement.setLong(1, profile.getAbilityDATS(SuperAbilityType.SUPER_BREAKER));
statement.setLong(2, profile.getAbilityDATS(SuperAbilityType.TREE_FELLER));
statement.setLong(3, profile.getAbilityDATS(SuperAbilityType.BERSERK));
@ -362,7 +365,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setLong(9, profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS));
statement.setLong(10, profile.getAbilityDATS(SuperAbilityType.SUPER_SHOTGUN));
statement.setLong(11, profile.getAbilityDATS(SuperAbilityType.TRIDENTS_SUPER_ABILITY));
statement.setInt(12, id);
statement.setLong(12, profile.getAbilityDATS(SuperAbilityType.MACES_SUPER_ABILITY));
statement.setInt(13, id);
success = (statement.executeUpdate() != 0);
statement.close();
if (!success) {
@ -648,9 +652,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement = connection.prepareStatement(
"SELECT " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, s.crossbows, s.tridents, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, e.crossbows, e.tridents, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, c.crossbows, c.tridents, " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, s.crossbows, s.tridents, s.maces, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, e.crossbows, e.tridents, e.maces, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, c.crossbows, c.tridents, c.maces, " +
"h.mobhealthbar, h.scoreboardtips, u.uuid, u.`user` "
+ "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
@ -922,6 +926,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`chimaera_wing` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`crossbows` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`tridents` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`maces` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
tryClose(createStatement);
@ -950,6 +955,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`tridents` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`maces` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`total` int(10) unsigned NOT NULL DEFAULT "+totalLevel+","
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
@ -1017,20 +1023,24 @@ public final class SQLDatabaseManager implements DatabaseManager {
tryClose(connection);
}
String skills = "skills";
String crossbows = "crossbows";
String tridents = "tridents";
String experience = "experience";
String cooldowns = "cooldowns";
final String skills = "skills";
final String crossbows = "crossbows";
final String tridents = "tridents";
final String maces = "maces";
final String experience = "experience";
final String cooldowns = "cooldowns";
updateStructure(skills, crossbows, String.valueOf(32));
updateStructure(skills, tridents, String.valueOf(32));
updateStructure(skills, maces, String.valueOf(32));
updateStructure(experience, crossbows, String.valueOf(10));
updateStructure(experience, tridents, String.valueOf(10));
updateStructure(experience, maces, String.valueOf(10));
updateStructure(cooldowns, crossbows, String.valueOf(10));
updateStructure(cooldowns, tridents, String.valueOf(10));
updateStructure(cooldowns, maces, String.valueOf(10));
}
private void updateStructure(String tableName, String columnName, String columnSize) {
@ -1213,15 +1223,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
Map<UniqueDataType, Integer> uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
MobHealthbarType mobHealthbarType;
UUID uuid;
int scoreboardTipsShown;
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query
// changes (a new skill is added)
final int OFFSET_XP = 15;
final int OFFSET_DATS = 28;
final int OFFSET_OTHER = 41;
final int OFFSET_XP = 16;
final int OFFSET_DATS = 29;
final int OFFSET_OTHER = 42;
skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1));
skills.put(PrimarySkillType.MINING, result.getInt(OFFSET_SKILLS + 2));
@ -1238,6 +1247,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
skills.put(PrimarySkillType.ALCHEMY, result.getInt(OFFSET_SKILLS + 13));
skills.put(PrimarySkillType.CROSSBOWS, result.getInt(OFFSET_SKILLS + 14));
skills.put(PrimarySkillType.TRIDENTS, result.getInt(OFFSET_SKILLS + 15));
skills.put(PrimarySkillType.MACES, result.getInt(OFFSET_SKILLS + 16));
skillsXp.put(PrimarySkillType.TAMING, result.getFloat(OFFSET_XP + 1));
skillsXp.put(PrimarySkillType.MINING, result.getFloat(OFFSET_XP + 2));
@ -1254,6 +1264,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
skillsXp.put(PrimarySkillType.ALCHEMY, result.getFloat(OFFSET_XP + 13));
skillsXp.put(PrimarySkillType.CROSSBOWS, result.getFloat(OFFSET_XP + 14));
skillsXp.put(PrimarySkillType.TRIDENTS, result.getFloat(OFFSET_XP + 15));
skillsXp.put(PrimarySkillType.MACES, result.getFloat(OFFSET_XP + 16));
// Taming - Unused - result.getInt(OFFSET_DATS + 1)
skillsDATS.put(SuperAbilityType.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2));
@ -1262,6 +1273,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
skillsDATS.put(SuperAbilityType.BERSERK, result.getInt(OFFSET_DATS + 5));
skillsDATS.put(SuperAbilityType.GREEN_TERRA, result.getInt(OFFSET_DATS + 6));
skillsDATS.put(SuperAbilityType.GIGA_DRILL_BREAKER, result.getInt(OFFSET_DATS + 7));
skillsDATS.put(SuperAbilityType.EXPLOSIVE_SHOT, result.getInt(OFFSET_DATS + 8));
// Archery - Unused - result.getInt(OFFSET_DATS + 8)
skillsDATS.put(SuperAbilityType.SERRATED_STRIKES, result.getInt(OFFSET_DATS + 9));
skillsDATS.put(SuperAbilityType.SKULL_SPLITTER, result.getInt(OFFSET_DATS + 10));
@ -1270,6 +1282,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
uniqueData.put(UniqueDataType.CHIMAERA_WING_DATS, result.getInt(OFFSET_DATS + 13));
skillsDATS.put(SuperAbilityType.SUPER_SHOTGUN, result.getInt(OFFSET_DATS + 14));
skillsDATS.put(SuperAbilityType.TRIDENTS_SUPER_ABILITY, result.getInt(OFFSET_DATS + 15));
skillsDATS.put(SuperAbilityType.MACES_SUPER_ABILITY, result.getInt(OFFSET_DATS + 16));
try {
scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);

View File

@ -56,67 +56,29 @@ public class FlatFileDataUtil {
* @return the "zero" initialized data corresponding to the index
*/
public static @NotNull String getZeroInitialisedData(int index, int startingLevel) throws IndexOutOfBoundsException {
switch(index) {
case USERNAME_INDEX:
return LEGACY_INVALID_OLD_USERNAME; //We'll keep using this value for legacy compatibility reasons (not sure if needed but don't care)
case 2: //Assumption: Used to be for something, no longer used
case 3: //Assumption: Used to be for something, no longer used
case 23: //Assumption: Used to be used for something, no longer used
case 33: //Assumption: Used to be used for something, no longer used
case LEGACY_LAST_LOGIN:
case HEALTHBAR:
return "IGNORED";
case SKILLS_MINING:
case SKILLS_REPAIR:
case SKILLS_UNARMED:
case SKILLS_HERBALISM:
case SKILLS_EXCAVATION:
case SKILLS_ARCHERY:
case SKILLS_SWORDS:
case SKILLS_AXES:
case SKILLS_WOODCUTTING:
case SKILLS_ACROBATICS:
case SKILLS_TAMING:
case SKILLS_FISHING:
case SKILLS_ALCHEMY:
case SKILLS_CROSSBOWS:
case SKILLS_TRIDENTS:
return String.valueOf(startingLevel);
case OVERHAUL_LAST_LOGIN:
return String.valueOf(-1L);
case COOLDOWN_BERSERK:
case COOLDOWN_GIGA_DRILL_BREAKER:
case COOLDOWN_TREE_FELLER:
case COOLDOWN_GREEN_TERRA:
case COOLDOWN_SERRATED_STRIKES:
case COOLDOWN_SKULL_SPLITTER:
case COOLDOWN_SUPER_BREAKER:
case COOLDOWN_BLAST_MINING:
case COOLDOWN_SUPER_SHOTGUN:
case COOLDOWN_TRIDENTS:
case COOLDOWN_ARCHERY:
case SCOREBOARD_TIPS:
case COOLDOWN_CHIMAERA_WING:
case EXP_MINING:
case EXP_WOODCUTTING:
case EXP_REPAIR:
case EXP_UNARMED:
case EXP_HERBALISM:
case EXP_EXCAVATION:
case EXP_ARCHERY:
case EXP_SWORDS:
case EXP_AXES:
case EXP_ACROBATICS:
case EXP_TAMING:
case EXP_FISHING:
case EXP_ALCHEMY:
case EXP_CROSSBOWS:
case EXP_TRIDENTS:
return "0";
case UUID_INDEX:
//TODO: Add UUID recovery? Might not even be worth it.
return switch (index) {
case USERNAME_INDEX ->
LEGACY_INVALID_OLD_USERNAME; //We'll keep using this value for legacy compatibility reasons (not sure if needed but don't care)
//Assumption: Used to be for something, no longer used
//Assumption: Used to be for something, no longer used
//Assumption: Used to be used for something, no longer used
//Assumption: Used to be used for something, no longer used
case 2, 3, 23, 33, LEGACY_LAST_LOGIN, HEALTHBAR -> "IGNORED";
case SKILLS_MINING, SKILLS_REPAIR, SKILLS_UNARMED, SKILLS_HERBALISM, SKILLS_EXCAVATION, SKILLS_ARCHERY,
SKILLS_SWORDS, SKILLS_AXES, SKILLS_WOODCUTTING, SKILLS_ACROBATICS, SKILLS_TAMING, SKILLS_FISHING,
SKILLS_ALCHEMY, SKILLS_CROSSBOWS, SKILLS_TRIDENTS, SKILLS_MACES -> String.valueOf(startingLevel);
case OVERHAUL_LAST_LOGIN -> String.valueOf(-1L);
case COOLDOWN_BERSERK, COOLDOWN_GIGA_DRILL_BREAKER, COOLDOWN_TREE_FELLER, COOLDOWN_GREEN_TERRA,
COOLDOWN_SERRATED_STRIKES, COOLDOWN_SKULL_SPLITTER, COOLDOWN_SUPER_BREAKER, COOLDOWN_BLAST_MINING,
COOLDOWN_SUPER_SHOTGUN, COOLDOWN_TRIDENTS, COOLDOWN_ARCHERY, COOLDOWN_MACES, SCOREBOARD_TIPS, COOLDOWN_CHIMAERA_WING,
EXP_MINING, EXP_WOODCUTTING, EXP_REPAIR, EXP_UNARMED, EXP_HERBALISM, EXP_EXCAVATION, EXP_ARCHERY,
EXP_SWORDS, EXP_AXES, EXP_ACROBATICS, EXP_TAMING, EXP_FISHING, EXP_ALCHEMY, EXP_CROSSBOWS,
EXP_TRIDENTS, EXP_MACES -> "0";
case UUID_INDEX ->
throw new IndexOutOfBoundsException(); //TODO: Add UUID recovery? Might not even be worth it.
}
default -> throw new IndexOutOfBoundsException();
};
throw new IndexOutOfBoundsException();
}
}

View File

@ -14,8 +14,7 @@ public enum DatabaseType {
if (typeName.equalsIgnoreCase("file")) {
return FLATFILE;
}
else if (typeName.equalsIgnoreCase("mysql")) {
} else if (typeName.equalsIgnoreCase("mysql")) {
return SQL;
}

View File

@ -33,8 +33,7 @@ public class SkillXpGain implements Delayed {
public int compareTo(SkillXpGain other) {
if (this.expiryTime < other.expiryTime) {
return -1;
}
else if (this.expiryTime > other.expiryTime) {
} else if (this.expiryTime > other.expiryTime) {
return 1;
}
return 0;

View File

@ -8,10 +8,8 @@ public class McMMOUrl {
public static final String urlSpigot = "https://spigot.mcmmo.org";
public static final String urlTranslate = "https://translate.mcmmo.org/";
public static String getUrl(McMMOWebLinks webLinks)
{
switch(webLinks)
{
public static String getUrl(McMMOWebLinks webLinks) {
switch(webLinks) {
case WIKI:
return urlWiki;
case PATREON:

View File

@ -11,20 +11,16 @@ public enum McMMOWebLinks {
HELP_TRANSLATE,
WIKI;
public String getUrl()
{
public String getUrl() {
return McMMOUrl.getUrl(this);
}
public String getNiceTitle()
{
public String getNiceTitle() {
return StringUtils.getCapitalized(toString());
}
public String getLocaleDescription()
{
switch (this)
{
public String getLocaleDescription() {
switch (this) {
case WEBSITE:
return LocaleLoader.getString( "JSON.URL.Website");
case DISCORD:

View File

@ -8,8 +8,7 @@ import org.bukkit.metadata.FixedMetadataValue;
*/
public class OldName extends FixedMetadataValue {
public OldName(String oldName, mcMMO plugin)
{
public OldName(String oldName, mcMMO plugin) {
super(plugin, oldName);
}

View File

@ -15,17 +15,13 @@ public enum ItemShareType {
public static ItemShareType getShareType(ItemStack itemStack) {
if (ItemUtils.isMobDrop(itemStack)) {
return LOOT;
}
else if (ItemUtils.isMiningDrop(itemStack)) {
} else if (ItemUtils.isMiningDrop(itemStack)) {
return MINING;
}
else if (ItemUtils.isHerbalismDrop(itemStack)) {
} else if (ItemUtils.isHerbalismDrop(itemStack)) {
return HERBALISM;
}
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
} else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
return WOODCUTTING;
}
else if (ItemUtils.isMiscDrop(itemStack)) {
} else if (ItemUtils.isMiscDrop(itemStack)) {
return MISC;
}

View File

@ -85,12 +85,10 @@ public class Party {
return onlineMembers;
}
public List<Player> getVisibleMembers(Player player)
{
public List<Player> getVisibleMembers(Player player) {
ArrayList<Player> visibleMembers = new ArrayList<>();
for(Player p : onlineMembers)
{
for(Player p : onlineMembers) {
if (player.canSee(p))
visibleMembers.add(p);
}

View File

@ -14,8 +14,7 @@ public enum ShareMode {
catch (IllegalArgumentException ex) {
if (string.equalsIgnoreCase("even")) {
return EQUAL;
}
else if (CommandUtils.shouldDisableToggle(string)) {
} else if (CommandUtils.shouldDisableToggle(string)) {
return NONE;
}

View File

@ -32,6 +32,7 @@ import com.gmail.nossr50.skills.crossbows.CrossbowsManager;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.maces.MacesManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.SalvageManager;
@ -71,6 +72,9 @@ import java.util.EnumMap;
import java.util.Map;
import java.util.UUID;
import static com.gmail.nossr50.util.EventUtils.callPlayerAbilityActivateEvent;
import static java.util.Objects.requireNonNull;
public class McMMOPlayer implements Identified {
private final @NotNull Identity identity;
@ -119,6 +123,8 @@ public class McMMOPlayer implements Identified {
private PrimarySkillType lastSkillShownScoreboard = PrimarySkillType.values()[0];
public McMMOPlayer(Player player, PlayerProfile profile) {
requireNonNull(player, "player cannot be null");
requireNonNull(profile, "profile cannot be null");
this.playerName = player.getName();
UUID uuid = player.getUniqueId();
identity = Identity.identity(uuid);
@ -220,6 +226,9 @@ public class McMMOPlayer implements Identified {
case WOODCUTTING:
skillManagers.put(primarySkillType, new WoodcuttingManager(this));
break;
case MACES:
skillManagers.put(primarySkillType, new MacesManager(this));
break;
default:
throw new InvalidSkillException("The skill named has no manager! Contact the devs!");
}
@ -241,8 +250,7 @@ public class McMMOPlayer implements Identified {
this.lastSkillShownScoreboard = primarySkillType;
}
public void processPostXpEvent(PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource)
{
public void processPostXpEvent(PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource) {
//Check if they've reached the power level cap just now
if (hasReachedPowerLevelCap()) {
NotificationManager.sendPlayerInformationChatOnly(player, "LevelCap.PowerLevel", String.valueOf(mcMMO.p.getGeneralConfig().getPowerLevelCap()));
@ -263,19 +271,16 @@ public class McMMOPlayer implements Identified {
updateXPBar(primarySkillType, plugin);
}
public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType, int skillLevel)
{
public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType, int skillLevel) {
RankUtils.executeSkillUnlockNotifications(plugin, this, primarySkillType, skillLevel);
}
public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin)
{
public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin) {
//XP BAR UPDATES
experienceBarManager.updateExperienceBar(primarySkillType, plugin);
}
public double getProgressInCurrentSkillLevel(PrimarySkillType primarySkillType)
{
public double getProgressInCurrentSkillLevel(PrimarySkillType primarySkillType) {
if (SkillTools.isChildSkill(primarySkillType)) {
return 1.0D;
}
@ -313,6 +318,10 @@ public class McMMOPlayer implements Identified {
return (TridentsManager) skillManagers.get(PrimarySkillType.TRIDENTS);
}
public MacesManager getMacesManager() {
return (MacesManager) skillManagers.get(PrimarySkillType.MACES);
}
public ExcavationManager getExcavationManager() {
return (ExcavationManager) skillManagers.get(PrimarySkillType.EXCAVATION);
}
@ -739,11 +748,11 @@ public class McMMOPlayer implements Identified {
* Players & Profiles
*/
public Player getPlayer() {
public @NotNull Player getPlayer() {
return player;
}
public PlayerProfile getProfile() {
public @NotNull PlayerProfile getProfile() {
return profile;
}
@ -893,8 +902,7 @@ public class McMMOPlayer implements Identified {
//TODO: This is hacky and temporary solution until skills are move to the new system
//Potential problems with this include skills with two super abilities (ie mining)
if(!RankUtils.hasUnlockedSubskill(player, subSkillType))
{
if (!RankUtils.hasUnlockedSubskill(player, subSkillType)) {
int diff = RankUtils.getSuperAbilityUnlockRequirement(superAbilityType) - getSkillLevel(primarySkillType);
//Inform the player they are not yet skilled enough
@ -917,7 +925,7 @@ public class McMMOPlayer implements Identified {
return;
}
if (EventUtils.callPlayerAbilityActivateEvent(player, primarySkillType).isCancelled()) {
if (callPlayerAbilityActivateEvent(this, primarySkillType).isCancelled()) {
return;
}
@ -928,8 +936,7 @@ public class McMMOPlayer implements Identified {
int ticks;
//Ability cap of 0 or below means no cap
if(abilityLengthCap > 0)
{
if (abilityLengthCap > 0) {
ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, getSkillLevel(primarySkillType)) / abilityLengthVar), superAbilityType.getMaxLength());
} else {
ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(primarySkillType) / abilityLengthVar), superAbilityType.getMaxLength());

View File

@ -135,8 +135,7 @@ public class PlayerProfile {
+ " resulted in failure. "+saveAttempts+" have been made so far.");
}
if(saveAttempts < 10)
{
if (saveAttempts < 10) {
saveAttempts++;
//Back out of async saving if we detect a server shutdown, this is not always going to be caught
@ -372,8 +371,7 @@ public class PlayerProfile {
for (PrimarySkillType parentSkill : parentSkills) {
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
}
}
else {
} else {
skillsXp.put(skill, skillsXp.get(skill) + xp);
}
}

View File

@ -9,11 +9,9 @@ public enum ModConfigType {
public static ModConfigType getModConfigType(String materialName) {
if (materialName.contains("HELM") || (materialName.contains("CHEST") && !materialName.contains("CHESTNUT")) || materialName.contains("LEGS") || materialName.contains("LEGGINGS") || materialName.contains("BOOT")) {
return ARMOR;
}
else if (materialName.contains("PICKAXE") || materialName.contains("AXE") || (materialName.contains("BOW") && !materialName.contains("BOWL")) || materialName.contains("HOE") || materialName.contains("SHOVEL") || materialName.contains("SWORD")) {
} else if (materialName.contains("PICKAXE") || materialName.contains("AXE") || (materialName.contains("BOW") && !materialName.contains("BOWL")) || materialName.contains("HOE") || materialName.contains("SHOVEL") || materialName.contains("SWORD")) {
return TOOLS;
}
else if (materialName.contains("LOG") || materialName.contains("LEAVES") || materialName.contains("FLOWER") || materialName.contains("PLANT") || materialName.contains("CROP") || materialName.contains("ORE") || materialName.contains("DIRT") || materialName.contains("SAND") || materialName.contains("GRASS")) {
} else if (materialName.contains("LOG") || materialName.contains("LEAVES") || materialName.contains("FLOWER") || materialName.contains("PLANT") || materialName.contains("CROP") || materialName.contains("ORE") || materialName.contains("DIRT") || materialName.contains("SAND") || materialName.contains("GRASS")) {
return BLOCKS;
}

View File

@ -20,6 +20,7 @@ public enum PrimarySkillType {
EXCAVATION,
FISHING,
HERBALISM,
MACES,
MINING,
REPAIR,
SALVAGE,

View File

@ -57,6 +57,9 @@ public enum SubSkillType {
HERBALISM_HYLIAN_LUCK,
HERBALISM_SHROOM_THUMB,
/* Maces */
MACES_MACES_LIMIT_BREAK(10),
/* Mining */
MINING_BIGGER_BOMBS(1),
MINING_BLAST_MINING(8),
@ -125,18 +128,15 @@ public enum SubSkillType {
* If our SubSkillType has more than 1 rank define it
* @param numRanks The number of ranks our SubSkillType has
*/
SubSkillType(int numRanks)
{
SubSkillType(int numRanks) {
this.numRanks = numRanks;
}
SubSkillType()
{
SubSkillType() {
this.numRanks = 0;
}
public int getNumRanks()
{
public int getNumRanks() {
return numRanks;
}
@ -167,8 +167,7 @@ public enum SubSkillType {
* Get the string representation of the permission node for this subskill
* @return the permission node for this subskill
*/
public String getPermissionNodeAddress()
{
public String getPermissionNodeAddress() {
//TODO: This could be optimized
return "mcmmo.ability." + getParentSkill().toString().toLowerCase(Locale.ENGLISH) + "." + getConfigName(toString()).toLowerCase(Locale.ENGLISH);
}
@ -198,12 +197,10 @@ public enum SubSkillType {
* Split the string up so we can capitalize each part
*/
String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex);
if(subskillNameWithoutPrefix.contains("_"))
{
if (subskillNameWithoutPrefix.contains("_")) {
String[] splitStrings = subskillNameWithoutPrefix.split("_");
for(String string : splitStrings)
{
for(String string : splitStrings) {
endResult.append(StringUtils.getCapitalized(string));
}
} else {
@ -225,8 +222,7 @@ public enum SubSkillType {
* Returns the name of the parent skill from the Locale file
* @return The parent skill as defined in the locale
*/
public String getParentNiceNameLocale()
{
public String getParentNiceNameLocale() {
return LocaleLoader.getString(StringUtils.getCapitalized(getParentSkill().toString())+".SkillName");
}
@ -235,8 +231,7 @@ public enum SubSkillType {
* @param subSkillType target subskill
* @return the "nice" name without spaces
*/
public String getNiceNameNoSpaces(SubSkillType subSkillType)
{
public String getNiceNameNoSpaces(SubSkillType subSkillType) {
return getConfigName(subSkillType.toString());
}
@ -260,18 +255,15 @@ public enum SubSkillType {
return subStringIndex;
}
public String getLocaleKeyRoot()
{
public String getLocaleKeyRoot() {
return StringUtils.getCapitalized(getParentSkill().toString())+".SubSkill."+getConfigName(toString());
}
public String getLocaleName()
{
public String getLocaleName() {
return getFromLocaleSubAddress(".Name");
}
public String getLocaleDescription()
{
public String getLocaleDescription() {
return getFromLocaleSubAddress(".Description");
}
@ -281,13 +273,11 @@ public enum SubSkillType {
public String getLocaleStatExtraDescription() { return getFromLocaleSubAddress(".Stat.Extra"); }
public String getLocaleKeyStatExtraDescription() { return getLocaleKeyFromSubAddress(".Stat.Extra"); }
public String getLocaleStat(String... vars)
{
public String getLocaleStat(String... vars) {
return LocaleLoader.getString("Ability.Generic.Template", (Object[]) vars);
}
public String getCustomLocaleStat(String... vars)
{
public String getCustomLocaleStat(String... vars) {
return LocaleLoader.getString("Ability.Generic.Template.Custom", (Object[]) vars);
}
@ -295,8 +285,7 @@ public enum SubSkillType {
return LocaleLoader.getString(getLocaleKeyRoot() + s);
}
private String getLocaleKeyFromSubAddress(String s)
{
private String getLocaleKeyFromSubAddress(String s) {
return getLocaleKeyRoot() + s;
}
}

View File

@ -72,19 +72,26 @@ public enum SuperAbilityType {
"Swords.Skills.SS.Other.Off",
"Swords.SubSkill.SerratedStrikes.Name"),
SUPER_SHOTGUN(
null,
null,
"Crossbows.Skills.SSG.Other.On",
"Crossbows.Skills.SSG.Refresh",
null,
"Crossbows.SubSkill.SuperShotgun.Name"),
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder"),
TRIDENTS_SUPER_ABILITY(
"Tridents.Skills.TA.On",
"Tridents.Skills.TA.Off",
"Tridents.Skills.TA.Other.On",
"Tridents.Skills.TA.Refresh",
"Tridents.Skills.TA.Other.Off",
"Tridents.SubSkill.TridentAbility.Name"),
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder"),
MACES_SUPER_ABILITY(
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder",
"Placeholder"),
/**
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
@ -199,16 +206,15 @@ public enum SuperAbilityType {
public boolean getPermissions(Player player) {
return switch (this) {
case BERSERK -> Permissions.berserk(player);
case EXPLOSIVE_SHOT -> Permissions.explosiveShot(player);
case BLAST_MINING -> Permissions.remoteDetonation(player);
case GIGA_DRILL_BREAKER -> Permissions.gigaDrillBreaker(player);
case GREEN_TERRA -> Permissions.greenTerra(player);
case SERRATED_STRIKES -> Permissions.serratedStrikes(player);
case SKULL_SPLITTER -> Permissions.skullSplitter(player);
case SUPER_BREAKER -> Permissions.superBreaker(player);
case SUPER_SHOTGUN -> Permissions.superShotgun(player);
case TREE_FELLER -> Permissions.treeFeller(player);
case TRIDENTS_SUPER_ABILITY -> Permissions.tridentsSuper(player);
// TODO: once implemented, return permissions for the following abilities
case EXPLOSIVE_SHOT, TRIDENTS_SUPER_ABILITY, SUPER_SHOTGUN, MACES_SUPER_ABILITY -> false;
};
}

View File

@ -13,7 +13,8 @@ public enum ToolType {
SWORD("Swords.Ability.Lower", "Swords.Ability.Ready"),
CROSSBOW("Crossbows.Ability.Lower", "Crossbows.Ability.Ready"),
BOW("Archery.Ability.Lower", "Archery.Ability.Ready"),
TRIDENTS("Tridents.Ability.Lower", "Tridents.Ability.Ready");
TRIDENTS("Tridents.Ability.Lower", "Tridents.Ability.Ready"),
MACES("Maces.Ability.Lower", "Maces.Ability.Ready");
private final String lowerTool;
private final String raiseTool;
@ -45,6 +46,8 @@ public enum ToolType {
return ItemUtils.isCrossbow(itemStack);
case TRIDENTS:
return ItemUtils.isTrident(itemStack);
case MACES:
return ItemUtils.isMace(itemStack);
case FISTS:
return itemStack.getType() == Material.AIR;

View File

@ -1,167 +1,149 @@
package com.gmail.nossr50.datatypes.skills.alchemy;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import org.bukkit.Color;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.PotionUtil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import static com.gmail.nossr50.util.PotionUtil.samePotionType;
import static java.util.Objects.requireNonNull;
public class AlchemyPotion {
private final Material material;
private PotionData data;
private String name;
private List<String> lore;
private List<PotionEffect> effects;
private Color color;
private Map<ItemStack, String> children;
private final @NotNull String potionConfigName;
private final @NotNull ItemStack potionItemStack;
private final @NotNull Map<ItemStack, String> alchemyPotionChildren;
public AlchemyPotion(Material material, PotionData data, String name, List<String> lore, List<PotionEffect> effects, Color color, Map<ItemStack, String> children) {
this.material = material;
this.data = data;
this.lore = lore;
this.name = name;
this.effects = effects;
this.children = children;
this.color = color;
public AlchemyPotion(@NotNull String potionConfigName, @NotNull ItemStack potionItemStack,
@NotNull Map<ItemStack, String> alchemyPotionChildren) {
this.potionConfigName = requireNonNull(potionConfigName, "potionConfigName cannot be null");
this.potionItemStack = requireNonNull(potionItemStack, "potionItemStack cannot be null");
this.alchemyPotionChildren = requireNonNull(alchemyPotionChildren, "alchemyPotionChildren cannot be null");
}
public String toString() {
return "AlchemyPotion{" + data + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
public @NotNull ItemStack toItemStack(int amount) {
final ItemStack clone = potionItemStack.clone();
clone.setAmount(Math.max(1, amount));
return clone;
}
public ItemStack toItemStack(int amount) {
ItemStack potion = new ItemStack(material, amount);
PotionMeta meta = (PotionMeta) potion.getItemMeta();
meta.setBasePotionData(data);
if (this.getName() != null) {
meta.setDisplayName(this.getName());
public @NotNull Map<ItemStack, String> getAlchemyPotionChildren() {
return alchemyPotionChildren;
}
if (this.getLore() != null && !this.getLore().isEmpty()) {
meta.setLore(this.getLore());
}
if (!this.getEffects().isEmpty()) {
for (PotionEffect effect : this.getEffects()) {
meta.addCustomEffect(effect, true);
}
}
if (this.getColor() != null) {
meta.setColor(this.getColor());
}
potion.setItemMeta(meta);
return potion;
}
public Material getMaterial() {
return material;
}
public Potion toPotion(int amount) {
return Potion.fromItemStack(this.toItemStack(amount));
}
public PotionData getData() {
return data;
}
public void setData(PotionData data) {
this.data = data;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getLore() {
return lore;
}
public void setLore(List<String> lore) {
this.lore = lore;
}
public List<PotionEffect> getEffects() {
return effects;
}
public void setEffects(List<PotionEffect> effects) {
this.effects = effects;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public Map<ItemStack, String> getChildren() {
return children;
}
public void setChildren(Map<ItemStack, String> children) {
this.children = children;
}
public AlchemyPotion getChild(ItemStack ingredient) {
if (!children.isEmpty()) {
for (Entry<ItemStack, String> child : children.entrySet()) {
public @Nullable AlchemyPotion getChild(@NotNull ItemStack ingredient) {
if (!alchemyPotionChildren.isEmpty()) {
for (Entry<ItemStack, String> child : alchemyPotionChildren.entrySet()) {
if (ingredient.isSimilar(child.getKey())) {
return PotionConfig.getInstance().getPotion(child.getValue());
return mcMMO.p.getPotionConfig().getPotion(child.getValue());
}
}
}
return null;
}
public boolean isSimilar(ItemStack item) {
if (item.getType() != material) {
public boolean isSimilarPotion(@NotNull ItemStack otherPotion) {
requireNonNull(otherPotion, "otherPotion cannot be null");
if (otherPotion.getType() != potionItemStack.getType()) {
return false;
}
if (!item.hasItemMeta()) {
// no potion meta, no match
if (!otherPotion.hasItemMeta()) {
return false;
}
PotionMeta meta = (PotionMeta) item.getItemMeta();
PotionData that = meta.getBasePotionData();
if (data.getType() != that.getType()) {
/*
* Compare custom effects on both potions.
*/
final PotionMeta otherPotionMeta = (PotionMeta) otherPotion.getItemMeta();
// compare custom effects on both potions, this has to be done in two traversals
// comparing thisPotionMeta -> otherPotionMeta and otherPotionMeta -> thisPotionMeta
if (hasDifferingCustomEffects(getAlchemyPotionMeta(), otherPotionMeta)
|| hasDifferingCustomEffects(otherPotionMeta, getAlchemyPotionMeta())) {
return false;
}
if (data.isExtended() != that.isExtended()) {
if (!samePotionType(getAlchemyPotionMeta(), otherPotionMeta)) {
return false;
}
if (data.isUpgraded() != that.isUpgraded()) {
// Legacy only comparison, compare PotionData
if (!PotionUtil.isPotionDataEqual(getAlchemyPotionMeta(), otherPotionMeta)) {
return false;
}
for (PotionEffect effect : effects) {
if (!meta.hasCustomEffect(effect.getType())) {
/*
* If one potion has lore and the other does not, then they are not the same potion.
* If both have lore, compare the lore.
* If neither have lore, they may be the same potion.
*/
if (!otherPotionMeta.hasLore() && getAlchemyPotionMeta().hasLore()
|| !getAlchemyPotionMeta().hasLore() && otherPotionMeta.hasLore()) {
return false;
}
return !otherPotionMeta.hasLore() || !getAlchemyPotionMeta().hasLore()
|| otherPotionMeta.getLore().equals(getAlchemyPotionMeta().getLore());
}
private boolean hasDifferingCustomEffects(PotionMeta potionMeta, PotionMeta otherPotionMeta) {
for (int i = 0; i < potionMeta.getCustomEffects().size(); i++) {
var effect = potionMeta.getCustomEffects().get(i);
// One has an effect the other does not, they are not the same potion
if (!otherPotionMeta.hasCustomEffect(effect.getType())) {
return true;
}
var otherEffect = otherPotionMeta.getCustomEffects().get(i);
// Amplifier or duration are not equal, they are not the same potion
if (effect.getAmplifier() != otherEffect.getAmplifier()
|| effect.getDuration() != otherEffect.getDuration()) {
return true;
}
}
if (!meta.hasLore() && !lore.isEmpty()) {
return false;
}
if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) {
return false;
public PotionMeta getAlchemyPotionMeta() {
return (PotionMeta) potionItemStack.getItemMeta();
}
if (!meta.hasDisplayName() && name != null) {
return false;
public boolean isSplash() {
return potionItemStack.getType() == Material.SPLASH_POTION;
}
return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
public boolean isLingering() {
return potionItemStack.getType() == Material.LINGERING_POTION;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AlchemyPotion that = (AlchemyPotion) o;
return Objects.equals(potionConfigName, that.potionConfigName) && Objects.equals(potionItemStack, that.potionItemStack) && Objects.equals(alchemyPotionChildren, that.alchemyPotionChildren);
}
@Override
public int hashCode() {
return Objects.hash(potionConfigName, potionItemStack, alchemyPotionChildren);
}
@Override
public String toString() {
return "AlchemyPotion{" +
"potionConfigName='" + potionConfigName + '\'' +
", potionItemStack=" + potionItemStack +
", alchemyPotionChildren=" + alchemyPotionChildren +
'}';
}
}

View File

@ -1,11 +1,10 @@
package com.gmail.nossr50.datatypes.skills.alchemy;
import org.bukkit.Material;
import org.bukkit.potion.PotionData;
import com.gmail.nossr50.util.PotionUtil;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType;
import java.util.List;
import static com.gmail.nossr50.util.PotionUtil.*;
public enum PotionStage {
FIVE(5),
@ -35,35 +34,36 @@ public enum PotionStage {
}
public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
PotionStage potionStage = getPotionStage(output);
if (!isWaterBottle(input) && getPotionStage(input) == potionStage) {
potionStage = PotionStage.FIVE;
PotionStage outputPotionStage = getPotionStage(output);
PotionStage inputPotionStage = getPotionStage(input);
if (!isWaterBottle(input) && inputPotionStage == outputPotionStage) {
outputPotionStage = PotionStage.FIVE;
}
return potionStage;
return outputPotionStage;
}
private static boolean isWaterBottle(AlchemyPotion input) {
return input.getData().getType() == PotionType.WATER;
private static boolean isWaterBottle(AlchemyPotion alchemyPotion) {
return isPotionTypeWater(alchemyPotion.getAlchemyPotionMeta());
}
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
PotionData data = alchemyPotion.getData();
List<PotionEffect> effects = alchemyPotion.getEffects();
final PotionMeta potionMeta = alchemyPotion.getAlchemyPotionMeta();
int stage = 1;
// Check if potion has an effect of any sort
if (data.getType().getEffectType() != null || !effects.isEmpty()) {
if (!potionMeta.getCustomEffects().isEmpty()
|| PotionUtil.hasBasePotionEffects(potionMeta)) {
stage++;
}
// Check if potion has a glowstone dust amplifier
// Else check if the potion has a custom effect with an amplifier added by mcMMO
if (data.isUpgraded()) {
if (isStrong(potionMeta)) {
stage++;
} else if(!effects.isEmpty()) {
for (PotionEffect effect : effects){
} else if (!potionMeta.getCustomEffects().isEmpty()) {
for (PotionEffect effect : potionMeta.getCustomEffects()){
if (effect.getAmplifier() > 0){
stage++;
break;
@ -72,12 +72,12 @@ public enum PotionStage {
}
// Check if potion has a redstone dust amplifier
if (data.isExtended()) {
if (isLong(potionMeta)) {
stage++;
}
// Check if potion has a gunpowder amplifier
if (alchemyPotion.getMaterial() == Material.SPLASH_POTION || alchemyPotion.getMaterial() == Material.LINGERING_POTION) {
if (alchemyPotion.isSplash() || alchemyPotion.isLingering()) {
stage++;
}

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.datatypes.skills.subskills;
import com.gmail.nossr50.config.CoreSkillsConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Rank;
@ -17,8 +18,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S
protected String configKeyPrimary;
protected SubSkillType subSkillType;
public AbstractSubSkill(String configKeySubSkill, String configKeyPrimary, SubSkillType subSkillType)
{
public AbstractSubSkill(String configKeySubSkill, String configKeyPrimary, SubSkillType subSkillType) {
this.configKeySubSkill = configKeySubSkill;
this.configKeyPrimary = configKeyPrimary;
this.subSkillType = subSkillType;
@ -48,13 +48,13 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S
/**
* Prints detailed info about this subskill to the player
*
* @param player the target player
* @param mmoPlayer the target player
*/
@Override
public void printInfo(Player player) {
public void printInfo(McMMOPlayer mmoPlayer) {
/* DEFAULT SETTINGS PRINT THE BARE MINIMUM */
//TextComponentFactory.sendPlayerUrlHeader(player);
final Player player = mmoPlayer.getPlayer();
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", getConfigKeyName()));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@ -13,7 +12,6 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.Probability;
import com.gmail.nossr50.util.random.ProbabilityUtil;
import com.gmail.nossr50.util.skills.PerksUtils;
@ -26,7 +24,6 @@ import net.kyori.adventure.text.TextComponent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SoundCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
@ -68,25 +65,25 @@ public class Roll extends AcrobaticsSubSkill {
return false;
if (entityDamageEvent.getCause() == EntityDamageEvent.DamageCause.FALL) {//Grab the player
McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
McMMOPlayer mmoPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
if (mcMMOPlayer == null)
if (mmoPlayer == null)
return false;
/*
* Check for success
*/
Player player = (Player) ((EntityDamageEvent) event).getEntity();
if (canRoll(player)) {
entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getFinalDamage()));
if (canRoll(mmoPlayer)) {
entityDamageEvent.setDamage(rollCheck(mmoPlayer, entityDamageEvent.getFinalDamage()));
if (entityDamageEvent.getFinalDamage() == 0) {
entityDamageEvent.setCancelled(true);
return true;
}
} else if(mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.ACROBATICS)) {
} else if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(mmoPlayer.getPlayer(), PrimarySkillType.ACROBATICS)) {
//Give XP Anyways
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, ((EntityDamageEvent) event).getFinalDamage(), false), XPGainReason.PVE);
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(mmoPlayer, ((EntityDamageEvent) event).getFinalDamage(), false), XPGainReason.PVE);
}
}
@ -118,26 +115,25 @@ public class Roll extends AcrobaticsSubSkill {
* Adds detailed stats specific to this skill
*
* @param componentBuilder target component builder
* @param player target player
* @param mmoPlayer target player
*/
@Override
public void addStats(TextComponent.Builder componentBuilder, Player player) {
public void addStats(TextComponent.Builder componentBuilder, McMMOPlayer mmoPlayer) {
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
/* Values related to the player */
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
float skillValue = mmoPlayer.getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(mmoPlayer.getPlayer(), getPrimarySkill());
String[] rollStrings = ProbabilityUtil.getRNGDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
String[] rollStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ACROBATICS_ROLL);
rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1];
/*
* Graceful is double the odds of a normal roll
*/
Probability probability = getRollProbability(player);
Probability gracefulProbability = Probability.ofPercent(probability.getValue() * 2);
Probability probability = getRollProbability(mmoPlayer);
Probability gracefulProbability = Probability.ofValue(probability.getValue() * 2);
String[] gracefulRollStrings = ProbabilityUtil.getRNGDisplayValues(gracefulProbability);
gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1];
@ -160,8 +156,7 @@ public class Roll extends AcrobaticsSubSkill {
//Advanced
//Lucky Notice
if(isLucky)
{
if (isLucky) {
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.JWrapper.Perks.Header")));
componentBuilder.append(Component.newline());
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.JWrapper.Perks.Lucky", "33")));
@ -170,8 +165,8 @@ public class Roll extends AcrobaticsSubSkill {
}
@NotNull
private Probability getRollProbability(Player player) {
return ProbabilityUtil.getSubSkillProbability(SubSkillType.ACROBATICS_ROLL, player);
private Probability getRollProbability(McMMOPlayer mmoPlayer) {
return ProbabilityUtil.getSubSkillProbability(SubSkillType.ACROBATICS_ROLL, mmoPlayer);
}
@Override
@ -189,8 +184,9 @@ public class Roll extends AcrobaticsSubSkill {
return true;
}
private boolean canRoll(Player player) {
return RankUtils.hasUnlockedSubskill(player, SubSkillType.ACROBATICS_ROLL) && Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL);
private boolean canRoll(McMMOPlayer mmoPlayer) {
return RankUtils.hasUnlockedSubskill(mmoPlayer.getPlayer(), SubSkillType.ACROBATICS_ROLL)
&& Permissions.isSubSkillEnabled(mmoPlayer.getPlayer(), SubSkillType.ACROBATICS_ROLL);
}
/**
@ -200,43 +196,41 @@ public class Roll extends AcrobaticsSubSkill {
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
@VisibleForTesting
public double rollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage) {
public double rollCheck(McMMOPlayer mmoPlayer, double damage) {
int skillLevel = mmoPlayer.getSkillLevel(getPrimarySkill());
int skillLevel = mcMMOPlayer.getSkillLevel(getPrimarySkill());
if (player.isSneaking()) {
return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel);
if (mmoPlayer.getPlayer().isSneaking()) {
return gracefulRollCheck(mmoPlayer, damage, skillLevel);
}
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.p.getAdvancedConfig().getRollDamageThreshold());
if (!isFatal(player, modifiedDamage)
&& ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.ACROBATICS_ROLL, player)) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text");
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
//player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
if (!isFatal(mmoPlayer, modifiedDamage)
&& ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.ACROBATICS_ROLL, mmoPlayer)) {
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text");
SoundManager.sendCategorizedSound(mmoPlayer.getPlayer(), mmoPlayer.getPlayer().getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
//mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
//if (!SkillUtils.cooldownExpired((long) mcMMOmmoPlayer.getPlayer().getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if (!isExploiting(mmoPlayer) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(mmoPlayer, damage, true), XPGainReason.PVE);
//}
addFallLocation(player);
addFallLocation(mmoPlayer);
return modifiedDamage;
}
else if (!isFatal(player, damage)) {
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
} else if (!isFatal(mmoPlayer, damage)) {
//if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if (!isExploiting(mmoPlayer) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(mmoPlayer, damage, false), XPGainReason.PVE);
//}
}
addFallLocation(player);
addFallLocation(mmoPlayer);
return damage;
}
private int getActivationChance(McMMOPlayer mcMMOPlayer) {
return PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill());
private int getActivationChance(McMMOPlayer mmoPlayer) {
return PerksUtils.handleLuckyPerks(mmoPlayer, getPrimarySkill());
}
/**
@ -245,37 +239,35 @@ public class Roll extends AcrobaticsSubSkill {
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
private double gracefulRollCheck(McMMOPlayer mmoPlayer, double damage, int skillLevel) {
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.p.getAdvancedConfig().getRollDamageThreshold() * 2);
Probability gracefulProbability = getGracefulProbability(player);
final Probability gracefulProbability = getGracefulProbability(mmoPlayer);
if (!isFatal(player, modifiedDamage)
if (!isFatal(mmoPlayer, modifiedDamage)
//TODO: Graceful isn't sending out an event
&& ProbabilityUtil.isStaticSkillRNGSuccessful(PrimarySkillType.ACROBATICS, player, gracefulProbability))
{
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
&& ProbabilityUtil.isStaticSkillRNGSuccessful(PrimarySkillType.ACROBATICS, mmoPlayer, gracefulProbability)) {
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
SoundManager.sendCategorizedSound(mmoPlayer.getPlayer(), mmoPlayer.getPlayer().getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
if (!isExploiting(mmoPlayer) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(mmoPlayer, damage, true), XPGainReason.PVE);
addFallLocation(player);
addFallLocation(mmoPlayer);
return modifiedDamage;
}
else if (!isFatal(player, damage)) {
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
} else if (!isFatal(mmoPlayer, damage)) {
if (!isExploiting(mmoPlayer) && mmoPlayer.getAcrobaticsManager().canGainRollXP())
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(mmoPlayer, damage, false), XPGainReason.PVE);
addFallLocation(player);
addFallLocation(mmoPlayer);
}
return damage;
}
@NotNull
public static Probability getGracefulProbability(Player player) {
double gracefulOdds = ProbabilityUtil.getSubSkillProbability(SubSkillType.ACROBATICS_ROLL, player).getValue() * 2;
return Probability.ofPercent(gracefulOdds);
public static Probability getGracefulProbability(McMMOPlayer mmoPlayer) {
double gracefulOdds = ProbabilityUtil.getSubSkillProbability(SubSkillType.ACROBATICS_ROLL, mmoPlayer).getValue() * 2;
return Probability.ofValue(gracefulOdds);
}
/**
@ -284,24 +276,21 @@ public class Roll extends AcrobaticsSubSkill {
*
* @return true if exploits are detected, false otherwise
*/
private boolean isExploiting(Player player) {
private boolean isExploiting(McMMOPlayer mmoPlayer) {
if (!ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
return false;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (ItemUtils.hasItemInEitherHand(player, Material.ENDER_PEARL) || player.isInsideVehicle()) {
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
if (ItemUtils.hasItemInEitherHand(mmoPlayer.getPlayer(), Material.ENDER_PEARL) || mmoPlayer.getPlayer().isInsideVehicle()) {
if (mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
}
return true;
}
if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
{
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
if (mmoPlayer.getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(mmoPlayer))) {
if (mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
}
return true;
@ -310,14 +299,14 @@ public class Roll extends AcrobaticsSubSkill {
return false; //NOT EXPLOITING
}
private float calculateRollXP(Player player, double damage, boolean isRoll) {
private float calculateRollXP(McMMOPlayer mmoPlayer, double damage, boolean isRoll) {
//Clamp Damage to account for insane DRs
damage = Math.min(20, damage);
ItemStack boots = player.getInventory().getBoots();
ItemStack boots = mmoPlayer.getPlayer().getInventory().getBoots();
float xp = (float) (damage * (isRoll ? ExperienceConfig.getInstance().getRollXPModifier() : ExperienceConfig.getInstance().getFallXPModifier()));
if (boots != null && boots.containsEnchantment(Enchantment.PROTECTION_FALL)) {
if (boots != null && boots.containsEnchantment(mcMMO.p.getEnchantmentMapper().getFeatherFalling())) {
xp *= ExperienceConfig.getInstance().getFeatherFallXPModifier();
}
@ -328,8 +317,8 @@ public class Roll extends AcrobaticsSubSkill {
return Math.max(damage - damageThreshold, 0.0);
}
private boolean isFatal(Player player, double damage) {
return player.getHealth() - damage <= 0;
private boolean isFatal(McMMOPlayer mmoPlayer, double damage) {
return mmoPlayer.getPlayer().getHealth() - damage <= 0;
}
/**
@ -345,103 +334,50 @@ public class Roll extends AcrobaticsSubSkill {
/**
* Prints detailed info about this subskill to the player
*
* @param player the target player
* @param mmoPlayer the target player
*/
@Override
public void printInfo(Player player) {
public void printInfo(McMMOPlayer mmoPlayer) {
//Header
super.printInfo(player);
super.printInfo(mmoPlayer);
//Start the description string.
//player.sendMessage(getDescription());
//Player stats
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Stats",
LocaleLoader.getString("Acrobatics.SubSkill.Roll.Stats", getStats(player))));
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.MmoInfo.Stats",
LocaleLoader.getString("Acrobatics.SubSkill.Roll.Stats", getStats(mmoPlayer))));
//Mechanics
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mechanics"));
player.sendMessage(getMechanics());
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mechanics"));
mmoPlayer.getPlayer().sendMessage(getMechanics());
}
/**
* Returns a collection of strings about how a skill works
* Used in the MMO Info command
*
* @return
*/
@Override
public String getMechanics() {
//Vars passed to locale
//0 = chance to roll at half max level
//1 = chance to roll with grace at half max level
//2 = level where maximum bonus is reached
//3 = additive chance to succeed per level
//4 = damage threshold when rolling
//5 = damage threshold when rolling with grace
//6 = half of level where maximum bonus is reached
/*
Roll:
# ChanceMax: Maximum chance of rolling when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level or higher, the roll chance will not go higher than <ChanceMax>
# DamageThreshold: The max damage a player can negate with a roll
ChanceMax: 100.0
MaxBonusLevel: 100
DamageThreshold: 7.0
*/
return "Under Construction: This will work in a future update.";
//
// double rollChanceHalfMax, graceChanceHalfMax, damageThreshold, chancePerLevel;
//
// //Chance to roll at half max skill
// RandomChanceSkill rollHalfMaxSkill = new RandomChanceSkill(null, subSkillType);
// int halfMaxSkillValue = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL)/2;
// rollHalfMaxSkill.setSkillLevel(halfMaxSkillValue);
//
// //Chance to graceful roll at full skill
// RandomChanceSkill rollGraceHalfMaxSkill = new RandomChanceSkill(null, subSkillType);
// rollGraceHalfMaxSkill.setSkillLevel(halfMaxSkillValue * 2); //Double the effective odds
//
// //Chance to roll per level
// RandomChanceSkill rollOneSkillLevel = new RandomChanceSkill(null, subSkillType);
// rollGraceHalfMaxSkill.setSkillLevel(1); //Level 1 skill
//
// //Chance Stat Calculations
// rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
// graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
// damageThreshold = mcMMO.p.getAdvancedConfig().getRollDamageThreshold();
//
// chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
//
// double maxLevel = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
//
// return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2,halfMaxSkillValue);
}
/**
* Get an array of various stats for a player
*
* @param player target player
* @param mmoPlayer target player
* @return stat array for target player for this skill
*/
@Override
public Double[] getStats(Player player)
{
double playerChanceRoll = ProbabilityUtil.getSubSkillProbability(subSkillType, player).getValue();
public Double[] getStats(McMMOPlayer mmoPlayer) {
double playerChanceRoll = ProbabilityUtil.getSubSkillProbability(subSkillType, mmoPlayer).getValue();
double playerChanceGrace = playerChanceRoll * 2;
double gracefulOdds = ProbabilityUtil.getSubSkillProbability(subSkillType, player).getValue() * 2;
double gracefulOdds = ProbabilityUtil.getSubSkillProbability(subSkillType, mmoPlayer).getValue() * 2;
return new Double[]{ playerChanceRoll, playerChanceGrace };
}
public void addFallLocation(@NotNull Player player)
{
UserManager.getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
public void addFallLocation(@NotNull McMMOPlayer mmoPlayer) {
mmoPlayer.getAcrobaticsManager().addLocationToFallMap(getBlockLocation(mmoPlayer));
}
public @NotNull Location getBlockLocation(@NotNull Player player)
{
return player.getLocation().getBlock().getLocation();
public @NotNull Location getBlockLocation(@NotNull McMMOPlayer mmoPlayer) {
return mmoPlayer.getPlayer().getLocation().getBlock().getLocation();
}
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.datatypes.skills.subskills.interfaces;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.entity.Player;
@ -19,10 +20,10 @@ public interface SubSkill extends Skill {
/**
* Get an array of various stats for a player
* @param player target player
* @param mmoPlayer target player
* @return stat array for target player for this skill
*/
Double[] getStats(Player player);
Double[] getStats(McMMOPlayer mmoPlayer);
/**
* Checks if a player has permission to use this skill
@ -59,9 +60,9 @@ public interface SubSkill extends Skill {
/**
* Adds detailed stats specific to this skill
* @param componentBuilder target component builder
* @param player owner of this skill
* @param mmoPlayer owner of this skill
*/
void addStats(TextComponent.Builder componentBuilder, Player player);
void addStats(TextComponent.Builder componentBuilder, McMMOPlayer mmoPlayer);
/**
* Whether this subskill is enabled
@ -71,7 +72,7 @@ public interface SubSkill extends Skill {
/**
* Prints detailed info about this subskill to the player
* @param player the target player
* @param mmoPlayer the target player
*/
void printInfo(Player player);
void printInfo(McMMOPlayer mmoPlayer);
}

View File

@ -18,8 +18,7 @@ abstract public class McMMOScoreboardEvent extends Event {
private final ScoreboardEventReason scoreboardEventReason;
public McMMOScoreboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason)
{
public McMMOScoreboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
this.scoreboardEventReason = scoreboardEventReason;
this.targetBoard = targetBoard;
this.currentBoard = currentBoard;

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.events.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
@ -7,19 +8,35 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
import static java.util.Objects.requireNonNull;
/**
* Generic event for mcMMO skill handling.
*/
public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected @NotNull PrimarySkillType skill;
protected int skillLevel;
protected McMMOPlayer mmoPlayer;
@Deprecated(forRemoval = true, since = "2.2.010")
protected McMMOPlayerSkillEvent(@NotNull Player player, @NotNull PrimarySkillType skill) {
super(player);
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
requireNonNull(mmoPlayer, "Player not found in UserManager," +
"contact the dev and tell them to use the constructor for" +
" McMMOPlayerSkillEvent(McMMOPlayer, PrimarySkillType) instead");
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
}
protected McMMOPlayerSkillEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType) {
super(mmoPlayer.getPlayer());
requireNonNull(mmoPlayer, "mmoPlayer cannot be null");
requireNonNull(primarySkillType, "primarySkillType cannot be null");
this.skill = primarySkillType;
this.skillLevel = mmoPlayer.getSkillLevel(primarySkillType);
}
/**
* @return The skill involved in this event
*/
@ -37,6 +54,15 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
/**
* Returns the {@link McMMOPlayer} associated with this event.
*
* @return The {@link McMMOPlayer} associated with this event.
*/
public @NotNull McMMOPlayer getMcMMOPlayer() {
return mmoPlayer;
}
@Override
public @NotNull HandlerList getHandlers() {
return handlers;

View File

@ -1,14 +1,24 @@
package com.gmail.nossr50.events.skills.abilities;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import java.util.Objects;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
private boolean cancelled;
@Deprecated(forRemoval = true, since = "2.2.010")
public McMMOPlayerAbilityActivateEvent(Player player, PrimarySkillType skill) {
super(player, skill);
super(Objects.requireNonNull(UserManager.getPlayer(player)), skill);
cancelled = false;
}
public McMMOPlayerAbilityActivateEvent(McMMOPlayer mmoPlayer, PrimarySkillType skill) {
super(mmoPlayer, skill);
cancelled = false;
}

View File

@ -1,10 +1,20 @@
package com.gmail.nossr50.events.skills.abilities;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import static java.util.Objects.requireNonNull;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
public McMMOPlayerAbilityDeactivateEvent(Player player, PrimarySkillType skill) {
super(player, skill);
@Deprecated(forRemoval = true, since = "2.2.010")
public McMMOPlayerAbilityDeactivateEvent(@NotNull Player player, @NotNull PrimarySkillType skill) {
this(requireNonNull(UserManager.getPlayer(player)), skill);
}
public McMMOPlayerAbilityDeactivateEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType skill) {
super(mmoPlayer, skill);
}
}

View File

@ -1,16 +1,38 @@
package com.gmail.nossr50.events.skills.abilities;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import java.util.Objects;
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
private final SuperAbilityType ability;
/**
* Create a new McMMOPlayerAbilityEvent.
*
* @param player The player involved in this event
* @param skill The skill involved in this event
* @deprecated Use {@link #McMMOPlayerAbilityEvent(McMMOPlayer, PrimarySkillType)} instead
*/
@Deprecated(forRemoval = true, since = "2.2.010")
protected McMMOPlayerAbilityEvent(Player player, PrimarySkillType skill) {
super(player, skill);
super(Objects.requireNonNull(UserManager.getPlayer(player)), skill);
ability = mcMMO.p.getSkillTools().getSuperAbility(skill);
}
/**
* Create a new McMMOPlayerAbilityEvent.
* @param mmoPlayer The McMMOPlayer involved in this event
* @param skill The skill involved in this event
*/
protected McMMOPlayerAbilityEvent(McMMOPlayer mmoPlayer, PrimarySkillType skill) {
super(mmoPlayer, skill);
ability = mcMMO.p.getSkillTools().getSuperAbility(skill);
}

View File

@ -1,24 +1,36 @@
package com.gmail.nossr50.events.skills.alchemy;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.jetbrains.annotations.NotNull;
import static java.util.Objects.requireNonNull;
public class McMMOPlayerBrewEvent extends McMMOPlayerSkillEvent implements Cancellable {
private final BlockState brewingStand;
private boolean cancelled;
@Deprecated(forRemoval = true, since = "2.2.010")
public McMMOPlayerBrewEvent(Player player, BlockState brewingStand) {
super(player, PrimarySkillType.ALCHEMY);
super(requireNonNull(UserManager.getPlayer(player)), PrimarySkillType.ALCHEMY);
this.brewingStand = brewingStand;
cancelled = false;
}
public McMMOPlayerBrewEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull BlockState brewingStand) {
super(mmoPlayer, PrimarySkillType.ALCHEMY);
this.brewingStand = requireNonNull(brewingStand);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}

View File

@ -1,17 +1,28 @@
package com.gmail.nossr50.events.skills.alchemy;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import static java.util.Objects.requireNonNull;
public class McMMOPlayerCatalysisEvent extends McMMOPlayerSkillEvent implements Cancellable {
private double speed;
private boolean cancelled;
@Deprecated(forRemoval = true, since = "2.2.010")
public McMMOPlayerCatalysisEvent(Player player, double speed) {
super(player, PrimarySkillType.ALCHEMY);
super(requireNonNull(UserManager.getPlayer(player)), PrimarySkillType.ALCHEMY);
this.speed = speed;
cancelled = false;
}
public McMMOPlayerCatalysisEvent(McMMOPlayer mmoPlayer, double speed) {
super(mmoPlayer, PrimarySkillType.ALCHEMY);
this.speed = speed;
cancelled = false;
}

View File

@ -1,15 +1,23 @@
package com.gmail.nossr50.events.skills.fishing;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
@Deprecated(forRemoval = true, since = "2.2.010")
protected McMMOPlayerFishingEvent(Player player) {
super(player, PrimarySkillType.FISHING);
super(UserManager.getPlayer(player), PrimarySkillType.FISHING);
cancelled = false;
}
protected McMMOPlayerFishingEvent(McMMOPlayer mmoPlayer) {
super(mmoPlayer, PrimarySkillType.FISHING);
cancelled = false;
}

View File

@ -1,23 +1,34 @@
package com.gmail.nossr50.events.skills.fishing;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static java.util.Objects.requireNonNull;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
private ItemStack treasure;
private int xp;
@Deprecated(forRemoval = true, since = "2.2.010")
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
super(player);
this(requireNonNull(UserManager.getPlayer(player)), treasure, xp);
}
public McMMOPlayerFishingTreasureEvent(@NotNull McMMOPlayer mmoPlayer, @Nullable ItemStack treasure, int xp) {
super(mmoPlayer);
this.treasure = treasure;
this.xp = xp;
}
public ItemStack getTreasure() {
public @Nullable ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
public void setTreasure(@Nullable ItemStack item) {
this.treasure = item;
}

View File

@ -1,20 +1,32 @@
package com.gmail.nossr50.events.skills.fishing;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private final Map<Enchantment, Integer> enchants;
import static java.util.Objects.requireNonNull;
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
super(player, treasure, xp);
this.enchants = enchants;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private final Map<Enchantment, Integer> enchants = new HashMap<>();
@Deprecated(forRemoval = true, since = "2.2.010")
public McMMOPlayerMagicHunterEvent(@NotNull Player player, @NotNull ItemStack treasure, int xp, @NotNull Map<Enchantment, Integer> enchants) {
this(requireNonNull(UserManager.getPlayer(player)), treasure, xp, enchants);
}
public Map<Enchantment, Integer> getEnchantments() {
public McMMOPlayerMagicHunterEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull ItemStack treasure, int xp, @NotNull Map<Enchantment, Integer> enchants) {
super(mmoPlayer, treasure, xp);
requireNonNull(enchants, "enchants cannot be null");
this.enchants.putAll(enchants);
}
public @NotNull Map<Enchantment, Integer> getEnchantments() {
return enchants;
}
}

View File

@ -1,11 +1,16 @@
package com.gmail.nossr50.events.skills.secondaryabilities;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.jetbrains.annotations.NotNull;
import static java.util.Objects.requireNonNull;
public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable {
private SubSkillType subSkillType;
@ -16,9 +21,20 @@ public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable
* Only skills using the old system will fire this event
* @param player target player
* @param subSkillType target subskill
* @deprecated Use {@link #SubSkillEvent(McMMOPlayer, SubSkillType)} instead
*/
public SubSkillEvent(Player player, SubSkillType subSkillType) {
super(player, mcMMO.p.getSkillTools().getPrimarySkillBySubSkill(subSkillType));
@Deprecated(forRemoval = true, since = "2.2.010")
public SubSkillEvent(@NotNull Player player, @NotNull SubSkillType subSkillType) {
this(requireNonNull(UserManager.getPlayer(player)), subSkillType);
}
/**
* Only skills using the old system will fire this event
* @param mmoPlayer target player
* @param subSkillType target subskill
*/
public SubSkillEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkillType) {
super(mmoPlayer, mcMMO.p.getSkillTools().getPrimarySkillBySubSkill(subSkillType));
this.subSkillType = subSkillType;
}
@ -28,15 +44,30 @@ public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable
* @param subSkillType target subskill
* @param resultModifier a value multiplied against the final result of the dice roll, typically between 0-1.0
*/
public SubSkillEvent(Player player, SubSkillType subSkillType, double resultModifier) {
@Deprecated(forRemoval = true, since = "2.2.010")
public SubSkillEvent(@NotNull Player player, @NotNull SubSkillType subSkillType, double resultModifier) {
this(requireNonNull(UserManager.getPlayer(player)), subSkillType, resultModifier);
}
/**
* Only skills using the old system will fire this event
* @param player target player
* @param subSkillType target subskill
* @param resultModifier a value multiplied against the final result of the dice roll, typically between 0-1.0
*/
public SubSkillEvent(@NotNull McMMOPlayer player, @NotNull SubSkillType subSkillType, double resultModifier) {
super(player, mcMMO.p.getSkillTools().getPrimarySkillBySubSkill(subSkillType));
this.subSkillType = subSkillType;
this.subSkillType = requireNonNull(subSkillType, "subSkillType cannot be null");
this.resultModifier = resultModifier;
}
public SubSkillEvent(Player player, AbstractSubSkill abstractSubSkill)
{
super(player, abstractSubSkill.getPrimarySkill());
@Deprecated(forRemoval = true, since = "2.2.010")
public SubSkillEvent(@NotNull Player player, @NotNull AbstractSubSkill abstractSubSkill) {
this(requireNonNull(UserManager.getPlayer(player)), abstractSubSkill);
}
public SubSkillEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull AbstractSubSkill abstractSubSkill) {
super(mmoPlayer, abstractSubSkill.getPrimarySkill());
}
public double getResultModifier() {

View File

@ -47,8 +47,7 @@ public class BlockListener implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onBlockDropItemEvent(BlockDropItemEvent event)
{
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))
@ -84,8 +83,7 @@ public class BlockListener implements Listener {
//If there are more than one block in the item list we can't really trust it and will back out of rewarding bonus drops
if (blockCount <= 1) {
for(Item item : event.getItems())
{
for(Item item : event.getItems()) {
ItemStack is = new ItemStack(item.getItemStack());
if (is.getAmount() <= 0)
@ -186,8 +184,7 @@ public class BlockListener implements Listener {
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{
public void onEntityBlockFormEvent(EntityBlockFormEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
@ -207,8 +204,7 @@ public class BlockListener implements Listener {
* Does not monitor stuff like a falling block replacing a liquid
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFormEvent(BlockFormEvent event)
{
public void onBlockFormEvent(BlockFormEvent event) {
World world = event.getBlock().getWorld();
/* WORLD BLACKLIST CHECK */
@ -266,8 +262,7 @@ public class BlockListener implements Listener {
if (blockState.getType() == Repair.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.REPAIR)) {
mcMMOPlayer.getRepairManager().placedAnvilCheck();
}
else if (blockState.getType() == Salvage.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SALVAGE)) {
} else if (blockState.getType() == Salvage.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SALVAGE)) {
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
}
}
@ -310,7 +305,7 @@ public class BlockListener implements Listener {
// Minecraft is dumb, the events still throw when a plant "grows" higher than the max block height. Even though no new block is created
if (BlockUtils.isWithinWorldBounds(block)) {
mcMMO.getPlaceStore().setFalse(block);
mcMMO.getUserBlockTracker().setEligible(block);
}
}
@ -334,8 +329,7 @@ public class BlockListener implements Listener {
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer())) {
BlockUtils.cleanupBlockMetadata(block);
return;
@ -400,19 +394,18 @@ public class BlockListener implements Listener {
else if (BlockUtils.affectedBySuperBreaker(blockState)
&& (ItemUtils.isPickaxe(heldItem) || ItemUtils.isHoe(heldItem))
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.MINING)
&& !mcMMO.getPlaceStore().isTrue(blockState)) {
&& !mcMMO.getUserBlockTracker().isIneligible(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState);
}
/* WOOD CUTTING */
else if (BlockUtils.hasWoodcuttingXP(blockState) && ItemUtils.isAxe(heldItem)
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getUserBlockTracker().isIneligible(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState);
}
else {
} else {
//Check for XP
woodcuttingManager.processWoodcuttingBlockXP(blockState);
@ -422,7 +415,10 @@ public class BlockListener implements Listener {
}
/* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
else if (BlockUtils.affectedByGigaDrillBreaker(blockState)
&& ItemUtils.isShovel(heldItem)
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.EXCAVATION)
&& !mcMMO.getUserBlockTracker().isIneligible(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState);
@ -450,8 +446,7 @@ public class BlockListener implements Listener {
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -463,8 +458,7 @@ public class BlockListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -478,8 +472,7 @@ public class BlockListener implements Listener {
if (herbalismManager.processHylianLuck(blockState)) {
blockState.update(true);
event.setCancelled(true);
}
else if (blockState.getType() == Material.FLOWER_POT) {
} else if (blockState.getType() == Material.FLOWER_POT) {
blockState.setType(Material.AIR);
blockState.update(true);
event.setCancelled(true);
@ -513,8 +506,7 @@ public class BlockListener implements Listener {
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -529,8 +521,7 @@ public class BlockListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Profile not loaded
if(mcMMOPlayer == null)
{
if (mcMMOPlayer == null) {
return;
}
@ -544,17 +535,13 @@ public class BlockListener implements Listener {
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && Permissions.treeFeller(player)) {
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState)
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState)
|| mcMMO.getMaterialMapStore().isGlass(blockState.getType())
|| blockState.getType() == Material.SNOW
|| BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
@ -596,8 +583,7 @@ public class BlockListener implements Listener {
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -615,8 +601,7 @@ public class BlockListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -633,14 +618,12 @@ public class BlockListener implements Listener {
if (mcMMOPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
blockState.update(true);
}
}
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
} else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
if (EventUtils.simulateBlockBreak(block, player) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player)) {
} else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player)) {
event.setInstaBreak(true);
if (blockState.getType().getKey().getKey().contains("glass")) {
@ -649,8 +632,7 @@ public class BlockListener implements Listener {
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
}
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player)) {
} else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player)) {
event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
@ -662,8 +644,7 @@ public class BlockListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -680,23 +661,19 @@ public class BlockListener implements Listener {
//TODO: Convert into locale strings
private void debugStickDump(Player player, BlockState blockState) {
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
if(UserManager.getPlayer(player).isDebugMode())
{
if(mcMMO.getPlaceStore().isTrue(blockState))
if (UserManager.getPlayer(player).isDebugMode()) {
if (mcMMO.getUserBlockTracker().isIneligible(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else
{
else {
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
}
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (WorldGuardManager.getInstance().hasMainFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region");
else
@ -708,19 +685,16 @@ public class BlockListener implements Listener {
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region");
}
if(blockState instanceof Furnace furnace)
{
if(mcMMO.getSmeltingTracker().isFurnaceOwned(furnace))
{
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
OfflinePlayer furnacePlayer = mcMMO.getSmeltingTracker().getFurnaceOwner(furnace);
if(furnacePlayer != null)
{
player.sendMessage("[mcMMO DEBUG] This furnace is owned by player "+furnacePlayer.getName());
if (blockState instanceof Furnace || blockState instanceof BrewingStand) {
if (ContainerMetadataUtils.isContainerOwned(blockState)) {
player.sendMessage("[mcMMO DEBUG] This container has a registered owner");
final OfflinePlayer furnacePlayer = ContainerMetadataUtils.getContainerOwner(blockState);
if (furnacePlayer != null) {
player.sendMessage("[mcMMO DEBUG] This container is owned by player "+furnacePlayer.getName());
}
}
else
player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner");
player.sendMessage("[mcMMO DEBUG] This container does not have a registered owner");
}
if (ExperienceConfig.getInstance().isExperienceBarsEnabled())

View File

@ -12,7 +12,8 @@ public class ChunkListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
List<LivingEntity> matchingEntities = mcMMO.getTransientEntityTracker().getAllTransientEntitiesInChunk(event.getChunk());
List<LivingEntity> matchingEntities
= mcMMO.getTransientEntityTracker().getAllTransientEntitiesInChunk(event.getChunk());
for(LivingEntity livingEntity : matchingEntities) {
mcMMO.getTransientEntityTracker().removeSummon(livingEntity, null, false);
}

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.metadata.MobMetaFlagType;
import com.gmail.nossr50.metadata.MobMetadataService;
import com.gmail.nossr50.runnables.TravelingBlockMetaCleanup;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.crossbows.Crossbows;
@ -45,11 +44,11 @@ import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import org.jetbrains.annotations.NotNull;
import static com.gmail.nossr50.util.MobMetadataUtils.*;
public class EntityListener implements Listener {
private final mcMMO pluginRef;
private final @NotNull MobMetadataService mobMetadataService;
/**
* We can use this {@link NamespacedKey} for {@link Enchantment} comparisons to
@ -59,7 +58,6 @@ public class EntityListener implements Listener {
public EntityListener(final mcMMO pluginRef) {
this.pluginRef = pluginRef;
mobMetadataService = mcMMO.getMetadataService().getMobMetadataService();
}
@EventHandler(priority = EventPriority.MONITOR)
@ -67,10 +65,10 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof LivingEntity livingEntity) {
//Transfer metadata keys from mob-spawned mobs to new mobs
if(mobMetadataService.hasMobFlags(livingEntity)) {
if (hasMobFlags(livingEntity)) {
for(Entity entity : event.getTransformedEntities()) {
if (entity instanceof LivingEntity transformedEntity) {
mobMetadataService.addMobFlags(livingEntity, transformedEntity);
addMobFlags(livingEntity, transformedEntity);
}
}
}
@ -83,18 +81,16 @@ public class EntityListener implements Listener {
return;
//It's rare but targets can be null sometimes
if(event.getTarget() == null)
{
if (event.getTarget() == null) {
return;
}
//Prevent entities from giving XP if they target endermite
if(event.getTarget() instanceof Endermite)
{
if (event.getTarget() instanceof Endermite) {
if (event.getEntity() instanceof Enderman enderman) {
if(!mobMetadataService.hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
mobMetadataService.flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
if (!hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
}
}
}
@ -106,8 +102,7 @@ public class EntityListener implements Listener {
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if(event.getEntity() instanceof Player player)
{
if (event.getEntity() instanceof Player player) {
Entity projectile = event.getProjectile();
//Should be noted that there are API changes regarding Arrow from 1.13.2 to current versions of the game
@ -120,7 +115,7 @@ public class EntityListener implements Listener {
if (bow == null)
return;
if (bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
if (bow.containsEnchantment(mcMMO.p.getEnchantmentMapper().getInfinity())) {
projectile.setMetadata(MetadataConstants.METADATA_KEY_INF_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
}
@ -139,8 +134,7 @@ public class EntityListener implements Listener {
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if(event.getEntity().getShooter() instanceof Player player)
{
if (event.getEntity().getShooter() instanceof Player player) {
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
@ -168,7 +162,7 @@ public class EntityListener implements Listener {
return;
}
if (ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
if (ProbabilityUtil.isSkillRNGSuccessful(SubSkillType.ARCHERY_ARROW_RETRIEVAL, UserManager.getPlayer(player))) {
arrow.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
}
}
@ -208,23 +202,21 @@ public class EntityListener implements Listener {
if (entity instanceof FallingBlock || entity instanceof Enderman) {
boolean isTracked = entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK);
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block);
if (mcMMO.getUserBlockTracker().isIneligible(block) && !isTracked) {
mcMMO.getUserBlockTracker().setEligible(block);
entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
TravelingBlockMetaCleanup metaCleanupTask = new TravelingBlockMetaCleanup(entity, pluginRef);
mcMMO.p.getFoliaLib().getImpl().runAtEntityTimer(entity, metaCleanupTask, 20, 20*60); //6000 ticks is 5 minutes
}
else if (isTracked) {
} else if (isTracked) {
BlockUtils.setUnnaturalBlock(block);
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
}
} 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)) {
mcMMO.getPlaceStore().setFalse(block);
} else {
if (mcMMO.getUserBlockTracker().isIneligible(block)) {
mcMMO.getUserBlockTracker().setEligible(block);
}
}
}
@ -267,8 +259,7 @@ public class EntityListener implements Listener {
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (attacker instanceof Player) {
if (!WorldGuardManager.getInstance().hasMainFlag((Player) attacker)) {
@ -326,8 +317,7 @@ public class EntityListener implements Listener {
if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) {
attacker = (Entity) animalTamer;
}
}
else if (attacker instanceof TNTPrimed && defender instanceof Player) {
} else if (attacker instanceof TNTPrimed && defender instanceof Player) {
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
return;
}
@ -498,11 +488,9 @@ public class EntityListener implements Listener {
event.getEntity().removeMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE, mcMMO.p);
}
if(event.getEntity() instanceof Player player)
{
if (event.getEntity() instanceof Player player) {
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -578,11 +566,9 @@ public class EntityListener implements Listener {
else if (livingEntity instanceof Tameable pet) {
AnimalTamer owner = pet.getOwner();
if(owner instanceof Player player)
{
if (owner instanceof Player player) {
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -593,8 +579,7 @@ public class EntityListener implements Listener {
Wolf wolf = (Wolf) pet;
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -730,11 +715,11 @@ public class EntityListener implements Listener {
}
private void trackSpawnedAndPassengers(LivingEntity livingEntity, MobMetaFlagType mobMetaFlagType) {
mobMetadataService.flagMetadata(mobMetaFlagType, livingEntity);
flagMetadata(mobMetaFlagType, livingEntity);
for(Entity passenger : livingEntity.getPassengers()) {
if (passenger != null) {
mobMetadataService.flagMetadata(mobMetaFlagType, livingEntity);
flagMetadata(mobMetaFlagType, livingEntity);
}
}
}
@ -742,7 +727,7 @@ public class EntityListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityBreed(EntityBreedEvent event) {
if (ExperienceConfig.getInstance().isCOTWBreedingPrevented()) {
if(mobMetadataService.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getFather()) || mobMetadataService.hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getMother())) {
if (hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getFather()) || hasMobFlag(MobMetaFlagType.COTW_SUMMONED_MOB, event.getMother())) {
event.setCancelled(true);
Animals mom = (Animals) event.getMother();
Animals father = (Animals) event.getFather();
@ -786,14 +771,12 @@ public class EntityListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -832,15 +815,13 @@ public class EntityListener implements Listener {
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -871,14 +852,12 @@ public class EntityListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -995,8 +974,7 @@ public class EntityListener implements Listener {
Player player = (Player) event.getOwner();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -1005,16 +983,15 @@ public class EntityListener implements Listener {
if (!UserManager.hasPlayerDataKey(player)
|| (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(livingEntity))
|| mobMetadataService.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|| mobMetadataService.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
|| hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|| hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
return;
}
mobMetadataService.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -1041,8 +1018,7 @@ public class EntityListener implements Listener {
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}

View File

@ -33,8 +33,7 @@ public class InteractionManager {
* Registers subskills with the Interaction registration
* @param abstractSubSkill the target subskill to register
*/
public static void registerSubSkill(AbstractSubSkill abstractSubSkill)
{
public static void registerSubSkill(AbstractSubSkill abstractSubSkill) {
//Store a unique copy of each subskill
if (!subSkillList.contains(abstractSubSkill))
subSkillList.add(abstractSubSkill);
@ -62,8 +61,7 @@ public class InteractionManager {
* @param name name of subskill, not case sensitive
* @return null if the subskill is not registered
*/
public static AbstractSubSkill getAbstractByName(String name)
{
public static AbstractSubSkill getAbstractByName(String name) {
return subSkillNameMap.get(name.toLowerCase(Locale.ENGLISH));
}
@ -73,13 +71,11 @@ public class InteractionManager {
* @param plugin instance of mcMMO plugin
* @param curInteractType the associated interaction type
*/
public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType)
{
public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType) {
if (interactRegister.get(curInteractType) == null)
return;
for(Interaction interaction : interactRegister.get(curInteractType))
{
for(Interaction interaction : interactRegister.get(curInteractType)) {
interaction.doInteraction(event, plugin);
}
}
@ -89,18 +85,15 @@ public class InteractionManager {
* Interactions are extensions of abstract classes that represent modifying behaviours in Minecraft through events
* @return the unique collection of all registered Interaction classes
*/
public static ArrayList<AbstractSubSkill> getSubSkillList()
{
public static ArrayList<AbstractSubSkill> getSubSkillList() {
return subSkillList;
}
public static boolean hasSubSkill(String name)
{
public static boolean hasSubSkill(String name) {
return getAbstractByName(name) != null;
}
public static boolean hasSubSkill(SubSkillType subSkillType)
{
public static boolean hasSubSkill(SubSkillType subSkillType) {
return hasSubSkill(subSkillType.getNiceNameNoSpaces(subSkillType));
}

View File

@ -9,6 +9,7 @@ import com.gmail.nossr50.mcMMO;
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.ContainerMetadataUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.Permissions;
@ -53,7 +54,7 @@ public class InventoryListener implements Listener {
}
Furnace furnace = (Furnace) furnaceState;
OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getFurnaceOwner(furnace);
OfflinePlayer offlinePlayer = ContainerMetadataUtils.getContainerOwner(furnace);
Player player;
if (offlinePlayer != null && offlinePlayer.isOnline() && offlinePlayer instanceof Player) {
@ -99,7 +100,7 @@ public class InventoryListener implements Listener {
}
if (blockState instanceof Furnace furnace) {
OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getFurnaceOwner(furnace);
OfflinePlayer offlinePlayer = ContainerMetadataUtils.getContainerOwner(furnace);
if (offlinePlayer != null) {
@ -130,8 +131,7 @@ public class InventoryListener implements Listener {
if (furnaceBlock instanceof Furnace) {
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -141,8 +141,7 @@ public class InventoryListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -165,16 +164,16 @@ public class InventoryListener implements Listener {
Inventory inventory = event.getInventory();
Player player = ((Player) event.getWhoClicked()).getPlayer();
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if(event.getInventory() instanceof FurnaceInventory)
{
Furnace furnace = mcMMO.getSmeltingTracker().getFurnaceFromInventory(event.getInventory());
if (furnace != null)
{
if (event.getInventory() instanceof FurnaceInventory furnaceInventory) {
//Switch owners
mcMMO.getSmeltingTracker().processFurnaceOwnership(furnace, player);
ContainerMetadataUtils.processContainerOwnership(furnaceInventory.getHolder(), player);
}
if (event.getInventory() instanceof BrewerInventory brewerInventory) {
// switch owners
ContainerMetadataUtils.processContainerOwnership(brewerInventory.getHolder(), player);
}
if (!(inventory instanceof BrewerInventory)) {
@ -189,22 +188,27 @@ public class InventoryListener implements Listener {
HumanEntity whoClicked = event.getWhoClicked();
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
if (mmoPlayer == null || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return;
}
// TODO: Investigate why this WG check is all the way down here?
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
ItemStack clicked = event.getCurrentItem();
ItemStack cursor = event.getCursor();
final ItemStack clicked = event.getCurrentItem();
final ItemStack cursor = event.getCursor();
if ((clicked != null && (clicked.getType() == Material.POTION || clicked.getType() == Material.SPLASH_POTION || clicked.getType() == Material.LINGERING_POTION)) || (cursor != null && (cursor.getType() == Material.POTION || cursor.getType() == Material.SPLASH_POTION || cursor.getType() == Material.LINGERING_POTION))) {
AlchemyPotionBrewer.scheduleCheck(player, stand);
if ((clicked != null && (clicked.getType() == Material.POTION
|| clicked.getType() == Material.SPLASH_POTION
|| clicked.getType() == Material.LINGERING_POTION))
|| (cursor != null && (cursor.getType() == Material.POTION
|| cursor.getType() == Material.SPLASH_POTION
|| cursor.getType() == Material.LINGERING_POTION))) {
AlchemyPotionBrewer.scheduleCheck(stand);
return;
}
@ -214,11 +218,11 @@ public class InventoryListener implements Listener {
if (click.isShiftClick()) {
switch (slot) {
case FUEL:
AlchemyPotionBrewer.scheduleCheck(player, stand);
AlchemyPotionBrewer.scheduleCheck(stand);
return;
case CONTAINER:
case QUICKBAR:
if (!AlchemyPotionBrewer.isValidIngredient(player, clicked)) {
if (!AlchemyPotionBrewer.isValidIngredientByPlayer(player, clicked)) {
return;
}
@ -228,24 +232,22 @@ public class InventoryListener implements Listener {
event.setCancelled(true);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);
AlchemyPotionBrewer.scheduleCheck(stand);
return;
default:
}
}
else if (slot == InventoryType.SlotType.FUEL) {
} else if (slot == InventoryType.SlotType.FUEL) {
boolean emptyClicked = AlchemyPotionBrewer.isEmpty(clicked);
if (AlchemyPotionBrewer.isEmpty(cursor)) {
if (emptyClicked && click == ClickType.NUMBER_KEY) {
AlchemyPotionBrewer.scheduleCheck(player, stand);
AlchemyPotionBrewer.scheduleCheck(stand);
return;
}
AlchemyPotionBrewer.scheduleCheck(player, stand);
}
else if (emptyClicked) {
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
AlchemyPotionBrewer.scheduleCheck(stand);
} else if (emptyClicked) {
if (AlchemyPotionBrewer.isValidIngredientByPlayer(player, cursor)) {
int amount = cursor.getAmount();
if (click == ClickType.LEFT || (click == ClickType.RIGHT && amount == 1)) {
@ -254,9 +256,8 @@ public class InventoryListener implements Listener {
event.setCursor(null);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);
}
else if (click == ClickType.RIGHT) {
AlchemyPotionBrewer.scheduleCheck(stand);
} else if (click == ClickType.RIGHT) {
event.setCancelled(true);
ItemStack one = cursor.clone();
@ -269,7 +270,7 @@ public class InventoryListener implements Listener {
event.setCursor(rest);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);
AlchemyPotionBrewer.scheduleCheck(stand);
}
}
}
@ -316,15 +317,14 @@ public class InventoryListener implements Listener {
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
if (AlchemyPotionBrewer.isValidIngredientByPlayer(player, cursor)) {
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
AlchemyPotionBrewer.scheduleCheck((BrewingStand) holder);
return;
}
@ -335,14 +335,14 @@ public class InventoryListener implements Listener {
// Apparently sometimes vanilla brewing beats our task listener to the actual brew. We handle this by cancelling the vanilla event and finishing our brew ourselves.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBrew(BrewEvent event)
{
public void onBrew(BrewEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBrewEvent)
return;
Location location = event.getBlock().getLocation();
if (Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.get(location).finishImmediately();
@ -350,6 +350,16 @@ public class InventoryListener implements Listener {
}
}
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
// public void onBrewStart(BrewingStartEvent event) {
// /* WORLD BLACKLIST CHECK */
// if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
// return;
//
// if (event instanceof FakeEvent)
// return;
// }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
/* WORLD BLACKLIST CHECK */
@ -358,17 +368,15 @@ public class InventoryListener implements Listener {
if (WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld()))
return;
Inventory inventory = event.getDestination();
final Inventory inventory = event.getDestination();
if (!(inventory instanceof BrewerInventory)) {
return;
}
InventoryHolder holder = inventory.getHolder();
final InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
if (holder instanceof BrewingStand brewingStand) {
ItemStack item = event.getItem();
@ -381,9 +389,20 @@ public class InventoryListener implements Listener {
event.setCancelled(true);
return;
}
int ingredientLevel = 1;
if (mcMMO.p.getGeneralConfig().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
OfflinePlayer offlinePlayer = ContainerMetadataUtils.getContainerOwner(brewingStand);
if (offlinePlayer != null && offlinePlayer.isOnline()) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(offlinePlayer.getPlayer());
if (mmoPlayer != null) {
ingredientLevel = mmoPlayer.getAlchemyManager().getTier();
}
}
if (mcMMO.p.getGeneralConfig().getEnabledForHoppers()
&& AlchemyPotionBrewer.isValidIngredientByLevel(ingredientLevel, item)) {
AlchemyPotionBrewer.scheduleCheck(brewingStand);
}
}
}
@ -433,8 +452,7 @@ public class InventoryListener implements Listener {
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}

View File

@ -87,8 +87,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -98,8 +97,7 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -183,8 +181,7 @@ public class PlayerListener implements Listener {
Player killer = killedPlayer.getKiller();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(killedPlayer))
return;
}
@ -227,8 +224,7 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -254,8 +250,7 @@ public class PlayerListener implements Listener {
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -287,8 +282,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -298,8 +292,7 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -373,8 +366,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -384,8 +376,7 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -393,20 +384,16 @@ public class PlayerListener implements Listener {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
//Track the hook
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
{
if(event.getHook().getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() == 0)
{
if (ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
if (event.getHook().getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() == 0) {
fishingManager.setFishHookReference(event.getHook());
}
//Spam Fishing
if(event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften())
{
if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften()) {
event.setExpToDrop(0);
if(caught instanceof Item caughtItem)
{
if (caught instanceof Item caughtItem) {
caughtItem.remove();
}
@ -489,12 +476,10 @@ public class PlayerListener implements Listener {
return;
}
if(event.getEntity() instanceof Player player)
{
if (event.getEntity() instanceof Player player) {
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -618,8 +603,7 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -640,8 +624,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
@ -665,8 +648,7 @@ public class PlayerListener implements Listener {
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -715,8 +697,7 @@ public class PlayerListener implements Listener {
else if (miningManager.canDetonate()) {
if (type == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close
}
else {
} else {
miningManager.remoteDetonation();
}
}
@ -770,19 +751,19 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (event.getHand() != EquipmentSlot.HAND
|| !UserManager.hasPlayerDataKey(player)
|| player.getGameMode() == GameMode.CREATIVE) {
return;
}
//Profile not loaded
if(UserManager.getPlayer(player) == null)
{
if (UserManager.getPlayer(player) == null) {
return;
}
@ -793,13 +774,10 @@ public class PlayerListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand();
//Spam Fishing Detection
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
if (ExperienceConfig.getInstance().isFishingExploitingPrevented()
&& (heldItem.getType() == Material.FISHING_ROD || player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD))
{
if(player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart))
{
&& (heldItem.getType() == Material.FISHING_ROD || player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD)) {
if (player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart)) {
player.getVehicle().eject();
}
@ -852,7 +830,7 @@ public class PlayerListener implements Listener {
case "NETHER_WART_BLOCK":
case "POTATO":
case "MANGROVE_PROPAGULE":
mcMMO.getPlaceStore().setFalse(blockState);
mcMMO.getUserBlockTracker().setEligible(blockState);
break;
}
}
@ -924,11 +902,9 @@ public class PlayerListener implements Listener {
if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.WOLF.getConfigEntityTypeEntry())) {
tamingManager.summonWolf();
}
else if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry())) {
} else if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry())) {
tamingManager.summonOcelot();
}
else if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry())) {
} else if (type == mcMMO.p.getGeneralConfig().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry())) {
tamingManager.summonHorse();
}
@ -1028,8 +1004,7 @@ public class PlayerListener implements Listener {
if (event.getHand() == EquipmentSlot.OFF_HAND) {
itemInHand = event.getPlayer().getInventory().getItemInOffHand();
}
else {
} else {
itemInHand = event.getPlayer().getInventory().getItemInMainHand();
}

View File

@ -24,8 +24,7 @@ public class SelfListener implements Listener {
//Used in task scheduling and other things
private final mcMMO plugin;
public SelfListener(mcMMO plugin)
{
public SelfListener(mcMMO plugin) {
this.plugin = plugin;
}
@ -42,8 +41,7 @@ public class SelfListener implements Listener {
if (player.isOnline()) {
//Players can gain multiple levels especially during xprate events
for(int i = 0; i < event.getLevelsGained(); i++)
{
for(int i = 0; i < event.getLevelsGained(); i++) {
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
@ -96,12 +94,9 @@ public class SelfListener implements Listener {
if (event.getXpGainReason() == XPGainReason.PVE ||
event.getXpGainReason() == XPGainReason.PVP ||
event.getXpGainReason() == XPGainReason.SHARED_PVE ||
event.getXpGainReason() == XPGainReason.SHARED_PVP)
{
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasXPFlag(player))
{
event.getXpGainReason() == XPGainReason.SHARED_PVP) {
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasXPFlag(player)) {
event.setRawXpGained(0);
event.setCancelled(true);
@ -112,19 +107,16 @@ public class SelfListener implements Listener {
}
}
if (event.getXpGainReason() == XPGainReason.COMMAND)
{
if (event.getXpGainReason() == XPGainReason.COMMAND) {
return;
}
if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled())
{
if (ExperienceConfig.getInstance().isEarlyGameBoostEnabled()) {
int earlyGameBonusXP = 0;
//Give some bonus XP for low levels
if(PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType))
{
if (PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) {
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
}
@ -167,12 +159,10 @@ public class SelfListener implements Listener {
* Make sure players get a guaranteed minimum of XP
*/
//If there is no guaranteed minimum proceed, otherwise only proceed if newValue would be higher than our guaranteed minimum
if(guaranteedMinimum <= 0 || newValue > guaranteedMinimum)
{
if (guaranteedMinimum <= 0 || newValue > guaranteedMinimum) {
if (newValue > 0) {
event.setRawXpGained(newValue);
}
else {
} else {
event.setCancelled(true);
}
} else {

View File

@ -32,7 +32,7 @@ public class WorldListener implements Listener {
// Using 50 ms later as I do not know of a way to run one tick later (safely)
plugin.getFoliaLib().getImpl().runLater(() -> {
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
mcMMO.getUserBlockTracker().setEligible(blockState);
}
}, 1);
}
@ -48,7 +48,7 @@ public class WorldListener implements Listener {
if (WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return;
mcMMO.getPlaceStore().unloadWorld(event.getWorld());
mcMMO.getChunkManager().unloadWorld(event.getWorld());
}
/**
@ -64,6 +64,6 @@ public class WorldListener implements Listener {
Chunk chunk = event.getChunk();
mcMMO.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
mcMMO.getChunkManager().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
}
}

View File

@ -19,7 +19,6 @@ import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.metadata.MetadataService;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.placeholders.PapiExpansion;
import com.gmail.nossr50.runnables.SaveTimerTask;
@ -40,6 +39,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.blockmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.blockmeta.UserBlockTracker;
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.util.compat.CompatibilityManager;
import com.gmail.nossr50.util.experience.FormulaManager;
@ -50,7 +50,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillTools;
import com.gmail.nossr50.util.skills.SmeltingTracker;
import com.gmail.nossr50.util.upgrade.UpgradeManager;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.tcoded.folialib.FoliaLib;
@ -78,12 +77,9 @@ import java.util.ArrayList;
import java.util.List;
public class mcMMO extends JavaPlugin {
/* Managers & Services */
private static PlatformManager platformManager;
private static MetadataService metadataService;
private static ChunkManager placeStore;
private static ChunkManager chunkManager;
private static RepairableManager repairableManager;
private static SalvageableManager salvageableManager;
private static ModManager modManager;
@ -92,7 +88,6 @@ public class mcMMO extends JavaPlugin {
private static UpgradeManager upgradeManager;
private static MaterialMapStore materialMapStore;
private static PlayerLevelUtils playerLevelUtils;
private static SmeltingTracker smeltingTracker;
private static TransientMetadataTools transientMetadataTools;
private static ChatManager chatManager;
private static CommandManager commandManager; //ACF
@ -140,28 +135,20 @@ public class mcMMO extends JavaPlugin {
private GeneralConfig generalConfig;
private AdvancedConfig advancedConfig;
private PartyConfig partyConfig;
private PotionConfig potionConfig;
private CustomItemSupportConfig customItemSupportConfig;
private EnchantmentMapper enchantmentMapper;
private AttributeMapper attributeMapper;
private FoliaLib foliaLib;
private PartyManager partyManager;
// private RepairConfig repairConfig;
// private SalvageConfig salvageConfig;
// private PersistentDataConfig persistentDataConfig;
// private ChatConfig chatConfig;
// private CoreSkillsConfig coreSkillsConfig;
// private RankConfig rankConfig;
// private TreasureConfig treasureConfig;
// private FishingTreasureConfig fishingTreasureConfig;
// private SoundConfig soundConfig;
public mcMMO() {
p = this;
}
protected mcMMO(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file)
{
protected mcMMO(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file);
}
@ -194,9 +181,6 @@ public class mcMMO extends JavaPlugin {
//Platform Manager
platformManager = new PlatformManager();
//metadata service
metadataService = new MetadataService(this);
MetadataConstants.MCMMO_METADATA_VALUE = new FixedMetadataValue(this, true);
PluginManager pluginManager = getServer().getPluginManager();
@ -209,6 +193,9 @@ public class mcMMO extends JavaPlugin {
// Init Material Maps
materialMapStore = new MaterialMapStore();
// Init compatibility mappers
enchantmentMapper = new EnchantmentMapper(this);
attributeMapper = new AttributeMapper(this);
loadConfigFiles();
@ -241,8 +228,7 @@ public class mcMMO extends JavaPlugin {
//Check for the newer API and tell them what to do if its missing
checkForOutdatedAPI();
if(serverAPIOutdated)
{
if (serverAPIOutdated) {
foliaLib
.getImpl()
.runTimer(
@ -250,8 +236,7 @@ public class mcMMO extends JavaPlugin {
20, 20*60*30
);
if(platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT)
{
if (platformManager.getServerSoftware() == ServerSoftwareType.CRAFT_BUKKIT) {
foliaLib
.getImpl()
.runTimer(
@ -280,7 +265,7 @@ public class mcMMO extends JavaPlugin {
scheduleTasks();
CommandRegistrationManager.registerCommands();
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
chunkManager = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
if (generalConfig.getPTPCommandWorldPermissions()) {
Permissions.generateWorldTeleportPermissions();
@ -307,8 +292,7 @@ public class mcMMO extends JavaPlugin {
if (!(t instanceof ExceptionInInitializerError)) {
t.printStackTrace();
}
else {
} else {
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
}
@ -324,9 +308,6 @@ public class mcMMO extends JavaPlugin {
//Init the blacklist
worldBlacklist = new WorldBlacklist(this);
//Init smelting tracker
smeltingTracker = new SmeltingTracker();
//Set up Adventure's audiences
audiences = BukkitAudiences.create(this);
@ -365,11 +346,13 @@ public class mcMMO extends JavaPlugin {
}
@Override
public void onLoad()
{
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
WorldGuardManager.getInstance().registerFlags();
}
// ProtocolLib
// protocolLibManager = new ProtocolLibManager(this);
}
/**
@ -393,7 +376,7 @@ public class mcMMO extends JavaPlugin {
ScoreboardManager.teardownAll();
formulaManager.saveFormula();
placeStore.closeAll();
chunkManager.closeAll();
}
catch (Exception e) {
e.printStackTrace();
@ -456,8 +439,30 @@ public class mcMMO extends JavaPlugin {
return formulaManager;
}
/**
* Get the {@link UserBlockTracker}.
* @return the {@link UserBlockTracker}
*/
public static UserBlockTracker getUserBlockTracker() {
return chunkManager;
}
/**
* Get the chunk manager.
* @return the chunk manager
*/
public static ChunkManager getChunkManager() {
return chunkManager;
}
/**
* Get the chunk manager.
* @deprecated Use {@link #getChunkManager()} or {@link #getUserBlockTracker()} instead.
* @return the chunk manager
*/
@Deprecated(since = "2.2.013", forRemoval = true)
public static ChunkManager getPlaceStore() {
return placeStore;
return chunkManager;
}
public static RepairableManager getRepairableManager() {
@ -484,10 +489,6 @@ public class mcMMO extends JavaPlugin {
return platformManager.getCompatibilityManager();
}
public static MetadataService getMetadataService() {
return metadataService;
}
@Deprecated
public static void setDatabaseManager(DatabaseManager databaseManager) {
mcMMO.databaseManager = databaseManager;
@ -567,7 +568,11 @@ public class mcMMO extends JavaPlugin {
FishingTreasureConfig.getInstance();
HiddenConfig.getInstance();
mcMMO.p.getAdvancedConfig();
PotionConfig.getInstance();
// init potion config
potionConfig = new PotionConfig();
potionConfig.loadPotions();
CoreSkillsConfig.getInstance();
SoundConfig.getInstance();
RankConfig.getInstance();
@ -628,8 +633,7 @@ public class mcMMO extends JavaPlugin {
InteractionManager.initMaps(); //Init maps
if(CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS))
{
if (CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) {
LogUtils.debug(mcMMO.p.getLogger(), "Enabling Acrobatics Skills");
//TODO: Should do this differently
@ -664,8 +668,7 @@ public class mcMMO extends JavaPlugin {
if (purgeIntervalTicks == 0) {
getFoliaLib().getImpl().runLaterAsync(new UserPurgeTask(), 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (purgeIntervalTicks > 0) {
} else if (purgeIntervalTicks > 0) {
getFoliaLib().getImpl().runTimerAsync(new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
}
@ -688,8 +691,7 @@ public class mcMMO extends JavaPlugin {
getFoliaLib().getImpl().runTimer(new ClearRegisteredXPGainTask(), 60, 60);
}
if(mcMMO.p.getAdvancedConfig().allowPlayerTips())
{
if (mcMMO.p.getAdvancedConfig().allowPlayerTips()) {
getFoliaLib().getImpl().runTimer(new NotifySquelchReminderTask(), 60, ((20 * 60) * 60));
}
}
@ -739,10 +741,6 @@ public class mcMMO extends JavaPlugin {
return platformManager;
}
public static SmeltingTracker getSmeltingTracker() {
return smeltingTracker;
}
public static BukkitAudiences getAudiences() {
return audiences;
}
@ -812,7 +810,23 @@ public class mcMMO extends JavaPlugin {
return customItemSupportConfig;
}
public PotionConfig getPotionConfig() {
return potionConfig;
}
public EnchantmentMapper getEnchantmentMapper() {
return enchantmentMapper;
}
public AttributeMapper getAttributeMapper() {
return attributeMapper;
}
public @NotNull FoliaLib getFoliaLib() {
return foliaLib;
}
// public ProtocolLibManager getProtocolLibManager() {
// return protocolLibManager;
// }
}

View File

@ -1,49 +0,0 @@
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();
}
}

View File

@ -1,71 +0,0 @@
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;
}
}

View File

@ -51,8 +51,7 @@ public final class ShareHandler {
for (Player member : nearMembers) {
//Profile not loaded
if(UserManager.getPlayer(member) == null)
{
if (UserManager.getPlayer(member) == null) {
continue;
}
@ -115,8 +114,7 @@ public final class ShareHandler {
McMMOPlayer mcMMOMember = UserManager.getPlayer(member);
//Profile not loaded
if(UserManager.getPlayer(member) == null)
{
if (UserManager.getPlayer(member) == null) {
continue;
}
@ -161,11 +159,9 @@ public final class ShareHandler {
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {
if (xpGainReason == XPGainReason.PVE) {
return XPGainReason.SHARED_PVE;
}
else if (xpGainReason == XPGainReason.PVP) {
} else if (xpGainReason == XPGainReason.PVP) {
return XPGainReason.SHARED_PVP;
}
else {
} else {
return xpGainReason;
}
}

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