Partially finished merge

This commit is contained in:
nossr50 2019-08-20 11:24:47 -04:00
commit 9428ea395d
119 changed files with 2592 additions and 961 deletions

View File

@ -13,6 +13,7 @@ Version 2.2.0
You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks) You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks)
Repair config has been rewritten and expanded to support much more complex settings Repair config has been rewritten and expanded to support much more complex settings
Fixed a bug where salvage anvil noises wouldn't play for a player that lacked repair permissions nodes Fixed a bug where salvage anvil noises wouldn't play for a player that lacked repair permissions nodes
Sharpened Claws now has settings to change its damage for PVE or PVP instead of a flat setting that applied to both
Removed the following Repair/Salvage permissions Removed the following Repair/Salvage permissions
mcmmo.ability.repair.stonerepair mcmmo.ability.repair.stonerepair
mcmmo.ability.repair.stringrepair mcmmo.ability.repair.stringrepair
@ -196,8 +197,116 @@ Version 2.2.0
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
Added API method to check if a skill was being level capped Added API method to check if a skill was being level capped
Added 'UndefinedSkillBehaviour' for trying to use a method that has no behaviour defined for the provided skill Added 'UndefinedSkillBehaviour' for trying to use a method that has no behaviour defined for the provided skill
Version 2.1.97
Fixed a NPE that could occur if a pet participated in combat and its master's mcMMO data was not available
Version 2.1.96
Added the setting 'Skills.General.LimitBreak.AllowPVE' to advanced.yml to allow Limit Break damage bonus to apply in PVE again, defaults to false
Updated Limit Break locale strings
Fixed a few more places where 'Archaeology' was misspelled in the locale
Added the setting 'ExploitFix.PistonCheating' to experience.yml at the request of a user
Added a missing 's' to Nether_Bricks (thanks Sikatsu) in experience.yml
NOTES:
The Skill Tooltips are a bit limited right now, in the future they will be more flexible. In order to reflect that Limit Break doesn't always work in PVE (now up to server settings) I added a crappy note to its hover window tip. I'll be fixing this in the future.
You shouldn't need to update you config entry for Nether_Bricks, I believe that file updates automatically (the old config system is a bit janky, some stuff updates, some other stuff doesn't.)
PistonCheating prevents blocks from being marked "natural" once they've been moved, we've never had an option for this before.
A discord user requested it, its a strange request but I added it anyways.
Of course, it defaults to "true" which prevents cheating with pistons.
Version 2.1.95
Added missing Chorus_Fruit & Chorus_Plant entries to Herbalism's Bonus Drops in config.yml (See notes)
Limit Break now does dramatically less damage to players with lower grades of armor
Limit Break damage bonuses now only apply to Players
Updated in game text to reflect changes to Limit Break
Fixed a bug where opponents used your stats instead of their own to activate Iron Grip
Fixed a bug preventing Wandering Traders from granting XP
Fixed a bug that prevented Chorus Tree's from giving full XP if you broke anything other than the bottom block
Fixed a bug which could cause Large Fern's to reward less XP
Fixed a bug where certain herbalism crops could have fewer than intended bonus drops
Fixed a bug involving Ender Pearl and Acrobatics
Added some protection to Acrobatics to prevent gaining too much XP in one Roll.
Added 'Carrots, Cocoa, Potatoes, Wheat, Beetroots, Nether_Wart' to Herbalism in experience.yml (See notes)
Removed the _Ripe entries from experience.yml (no longer used)
Updated locale string 'Swords.SubSkill.SwordsLimitBreak.Description' & 'Swords.SubSkill.SwordsLimitBreak.Stat'
Added missing 'Chorus_Flower' entry to herbalism in experience.yml
Added some debug messages about XP gains if you are in debug mode
Added some debug messages for Acrobatics if you are in debug mode
Added some debug messages for Herbalism if you are in debug mode
NOTES:
Add 'Chorus_Fruit' and 'Chorus_Plant' under Bonus_Drops.Herbalism in config.yml or you will not be getting double drops for Chorus Fruit.
You shouldn't need to add "Chorus_Flower, Carrots, Cocoa, Potatoes, Wheat, Beetroots, Nether_Wart" to your experience file, it seems that config file updates automatically for missing entries.
Version 2.1.94
2 new devs have joined the mcMMO team (electronicboy, kashike), bringing the active dev team to 3 including myself! Strings relating to authors of mcMMO have been updated to reflect this
Fixed a bug where 2 people using Tree Feller could result in the tree being rejected for being too big
New command /mmodebug (or /mcmmodebugmode) - Prints useful information when players punch blocks while they are in debug mode
mcMMO no longer prints debug information when you attack stuff with the debug stick, use the new command (/mmodebug) instead
Added locale string 'mcMMO.Description.FormerDevs'
Added locale string 'mcMMO.Template.Prefix'
Added locale string 'Commands.Mmodebug.Toggle'
Added locale string 'Commands.Description.mmodebug'
Tweaked locale string 'mcMMO.Description'
Updated Japanese locale (thanks snake)
Updated hu_HU locale (thanks andris155)
Version 2.1.93
Fixed a bug where players would be told they could not breed summoned animals when the animals weren't summoned (bug didn't actually do anything besides send you a message)
Version 2.1.92
Call Of The Wild (COTW) no longer cares if entities of the same type are nearby when attempting to summon a new entity
Fixed a bug where COTW summon limit was global instead of per player
If you are playing in 1.14 mcMMO will now summon cats instead of ocelots
The default summon limit for COTW is now per player instead of global which is how it should be, for wolves this defaults to 2, for other entities it defaults to 1
The COTW setting named Summon_Max_Amount in config.yml has been renamed to Per_Player_Limit
By default players are no longer allowed to breed COTW summoned animals with other animals, you can turn this off (see the notes)
If a player tries to breed animals with a COTW animal and the server settings prevent this, they are informed via a message that it is not allowed
If the COTW summon has a lifespan, players are now informed about this lifespan when the entity is first summoned
COTW entities now send the player a message when they die, time out, or get removed through other means
COTW summons now have their name prefixed with some colored text to to make it easier to identify them.
COTW summons now despawn if their owner logs out
There is now a small 150ms window in which you cannot summon an entity via COTW to prevent accidentally summoning extra entities
COTW Horses, Cats, and Wolves now always spawn in as adults
Changed the sound effect for COTW (Fireworks -> Pop)
Most COTW messages have been tweaked and new COTW messages have been added
Added new setting to experience.yml 'ExploitFix.COTWBreeding' - Prevents breeding with COTW summoned entities when set to true, defaults to true
Removed the 'mcmmo.ability.taming.callofthewild.renamepets' permission node as it is seen as unnecessary
Removed locale strings
Taming.Summon.Fail.Ocelot
Taming.Summon.Fail.Wolf
Taming.Summon.Fail.Horse
Taming.Summon.Fail.TooMany
Taming.Summon.Lifespan
Added new locale strings
Taming.Summon.COTW.NeedMoreItems
Taming.Summon.COTW.BreedingDisallowed
Taming.Summon.COTW.Success.WithLifespan
Taming.Summon.COTW.Success.WithoutLifespan
Taming.Summon.COTW.Limit
Taming.Summon.COTW.TimeExpired
Tweaked locale string
Taming.Summon.Name.Format
NOTES:
I plan to rework Call of The Wild (COTW) significantly in the upcoming content patch, until then I have made several tweaks to it.
COTW Summoning Requirement Changes
It is intentional that you are not supposed to be able to COTW summon something that you already have tamed, but mcMMO was not checking this properly.
So previous to this patch, if you tried to summon a wolf and wolves were nearby, it would fail. This is not intentional behaviour and was a bug.
The correct behaviour is that if you try to summon a wolf and you already have wolves, it should fail.
I was fixing this bug when it occurred to me, why do we even care if nearby tamed wolves owned by you exist if you are trying to summon a temporary one?
As a result of this train of thought, I have removed this restriction on COTW and several other tweaks have been made as a result of this line of thinking.
There was also an issue involving how many COTW entities could be out at once, for some reason the limit was applied globally and defaulted to 10, so if 10 players had COTW entities out no one else would be able to summon anything. I have fixed this.
You can set the lifespan to 0 in the config to make it so that COTW entities last until a server restart or the player logs out.
COTW Breeding Change
It was never intentional for COTW summoned entities to be breedable, by default they will not be. You can change this by setting 'ExploitFix.COTWBreeding' to false in experience.yml
Version 2.1.91 Version 2.1.91
mcMMO is now more compatible with plugins that spawn arrows in unexpected ways, this fixes some NPE in mcMMO when using certain plugins mcMMO is now more compatible with plugins that spawn arrows in unexpected ways, this fixes some NPE in mcMMO when using certain plugins
Fixed a bug where Unarmed was using the same CD timer for every player in the server (thanks slop_me)
Version 2.1.90 Version 2.1.90
Salvaged items now travel much slower towards the player Salvaged items now travel much slower towards the player

View File

@ -1,15 +1,15 @@
# mcMMO # mcMMO
## The RPG lovers mod ## The #1 RPG Mod for Minecraft
## Website ## Website
I'm working on a brand new website for mcMMO I'm working on a brand new website for mcMMO
You can check it out here http://www.mcmmo.org You can check it out here http://www.mcmmo.org
Spigot Resource: https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/
Spigot Resource: https://spigot.mcmmo.org
I plan to post links to our new wiki (its still under development), downloads, and dev blogs there. I plan to post links to our new wiki (its still under development), downloads, and dev blogs there.
### Builds ### Builds
Currently, you can obtain our builds via the Spigot resource page: http://spigot.mcmmo.org Currently, you can obtain our builds via the Spigot resource page: http://spigot.mcmmo.org
@ -17,16 +17,16 @@ Currently, you can obtain our builds via the Spigot resource page: http://spigot
The goal of mcMMO is to take core Minecraft game mechanics and expand them into an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update. The goal of mcMMO is to take core Minecraft game mechanics and expand them into an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
## About the Team ## About the Team
In December 2018 nossr50 returned as project lead for mcMMO once again to develop and improve mcMMO. In December 2018, the original author and creator of mcMMO (nossr50) returned and took over the role of project lead once again, to develop and improve mcMMO.
The mcMMO team currently has two members, nossr50 (lead) and t00thpick1 (classic maintainer). #### Project Lead & Founder
mcMMO is currently developed almost entirely by nossr50, many thanks go out to the many developers who have worked on the project over the years.
### Project Lead & Founder
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50) [![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50)
Other mcMMO Projects #### mcMMO Devs
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50)
[![kashike](https://secure.gravatar.com/avatar/b5e86d6d443b957fd5cdee55501f3799.png)](https://github.com/kashike)
[![electronicboy](https://secure.gravatar.com/avatar/44759c38d311ce09596de6a2d5b88036.png)](https://github.com/electronicboy)
### Classic Maintainer #### Classic Maintainer
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1) [![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
## Former Team Members ## Former Team Members
@ -50,10 +50,13 @@ mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary c
The typical command used to build mcMMO is: `mvn clean package install` The typical command used to build mcMMO is: `mvn clean package install`
Required Libraries: Required Libraries:
* Bukkit * Spigot
* JUnit * JUnit
* WorldGuard 7 * WorldGuard 7
* bStats Bukkit * bStats Bukkit
http://spigot.mcmmo.org for more up to date information. https://spigot.mcmmo.org for more up to date information.
Resource Page
https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/ https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/

View File

@ -217,7 +217,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version> <version>1.14.3-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.spigotmc</groupId>--> <!-- <groupId>org.spigotmc</groupId>-->

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class AbilityToggleCommand extends ToggleCommand { public class AbilityToggleCommand extends ToggleCommand {
@ -13,12 +12,12 @@ public class AbilityToggleCommand extends ToggleCommand {
@Override @Override
protected boolean hasOtherPermission(CommandSender sender) { protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.mcabilityOthers(sender); return pluginRef.getPermissionTools().mcabilityOthers(sender);
} }
@Override @Override
protected boolean hasSelfPermission(CommandSender sender) { protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.mcability(sender); return pluginRef.getPermissionTools().mcability(sender);
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType; import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -30,7 +29,7 @@ public class ExperienceRateCommand implements TabExecutor {
return false; return false;
} }
if (!Permissions.xprateReset(sender)) { if (!pluginRef.getPermissionTools().xprateReset(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -63,7 +62,7 @@ public class ExperienceRateCommand implements TabExecutor {
return true; return true;
} }
if (!Permissions.xprateSet(sender)) { if (!pluginRef.getPermissionTools().xprateSet(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class GodModeCommand extends ToggleCommand { public class GodModeCommand extends ToggleCommand {
@ -13,12 +12,12 @@ public class GodModeCommand extends ToggleCommand {
@Override @Override
protected boolean hasOtherPermission(CommandSender sender) { protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.mcgodOthers(sender); return pluginRef.getPermissionTools().mcgodOthers(sender);
} }
@Override @Override
protected boolean hasSelfPermission(CommandSender sender) { protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.mcgod(sender); return pluginRef.getPermissionTools().mcgod(sender);
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType; import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -20,7 +19,7 @@ public class McMMOCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (!Permissions.mcmmoDescription(sender)) { if (!pluginRef.getPermissionTools().mcmmoDescription(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -28,6 +27,7 @@ public class McMMOCommand implements CommandExecutor {
String description = pluginRef.getLocaleManager().getString("mcMMO.Description"); String description = pluginRef.getLocaleManager().getString("mcMMO.Description");
String[] mcSplit = description.split(","); String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit); sender.sendMessage(mcSplit);
sender.sendMessage(LocaleLoader.getString("mcMMO.Description.FormerDevs"));
if (pluginRef.getConfigManager().getConfigAds().isShowDonationInfo()) { if (pluginRef.getConfigManager().getConfigAds().isShowDonationInfo()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Donate")); sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Donate"));
@ -41,7 +41,7 @@ public class McMMOCommand implements CommandExecutor {
case 1: case 1:
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) { if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
if (!Permissions.mcmmoHelp(sender)) { if (!pluginRef.getPermissionTools().mcmmoHelp(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -63,54 +63,54 @@ public class McMMOCommand implements CommandExecutor {
sender.sendMessage(ChatColor.DARK_AQUA + " /<skill>" + pluginRef.getLocaleManager().getString("Commands.SkillInfo")); sender.sendMessage(ChatColor.DARK_AQUA + " /<skill>" + pluginRef.getLocaleManager().getString("Commands.SkillInfo"));
sender.sendMessage(ChatColor.DARK_AQUA + " /mctop " + pluginRef.getLocaleManager().getString("Commands.Leaderboards")); sender.sendMessage(ChatColor.DARK_AQUA + " /mctop " + pluginRef.getLocaleManager().getString("Commands.Leaderboards"));
if (Permissions.inspect(sender)) { if (pluginRef.getPermissionTools().inspect(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /inspect " + pluginRef.getLocaleManager().getString("Commands.Inspect")); sender.sendMessage(ChatColor.DARK_AQUA + " /inspect " + pluginRef.getLocaleManager().getString("Commands.Inspect"));
} }
if (Permissions.mcability(sender)) { if (pluginRef.getPermissionTools().mcability(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcability " + pluginRef.getLocaleManager().getString("Commands.ToggleAbility")); sender.sendMessage(ChatColor.DARK_AQUA + " /mcability " + pluginRef.getLocaleManager().getString("Commands.ToggleAbility"));
} }
} }
private void displayOtherCommands(CommandSender sender) { private void displayOtherCommands(CommandSender sender) {
//Don't show them this category if they have none of the permissions //Don't show them this category if they have none of the permissions
if (!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender)) if (!pluginRef.getPermissionTools().skillreset(sender) && !pluginRef.getPermissionTools().mmoedit(sender) && !pluginRef.getPermissionTools().adminChat(sender) && !pluginRef.getPermissionTools().mcgod(sender))
return; return;
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Other")); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Other"));
if (Permissions.skillreset(sender)) { if (pluginRef.getPermissionTools().skillreset(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /skillreset <skill|all> " + pluginRef.getLocaleManager().getString("Commands.Reset")); sender.sendMessage(ChatColor.DARK_AQUA + " /skillreset <skill|all> " + pluginRef.getLocaleManager().getString("Commands.Reset"));
} }
if (Permissions.mmoedit(sender)) { if (pluginRef.getPermissionTools().mmoedit(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mmoedit " + pluginRef.getLocaleManager().getString("Commands.mmoedit")); sender.sendMessage(ChatColor.DARK_AQUA + " /mmoedit " + pluginRef.getLocaleManager().getString("Commands.mmoedit"));
} }
if (Permissions.adminChat(sender)) { if (pluginRef.getPermissionTools().adminChat(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /adminchat " + pluginRef.getLocaleManager().getString("Commands.AdminToggle")); sender.sendMessage(ChatColor.DARK_AQUA + " /adminchat " + pluginRef.getLocaleManager().getString("Commands.AdminToggle"));
} }
if (Permissions.mcgod(sender)) { if (pluginRef.getPermissionTools().mcgod(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcgod " + pluginRef.getLocaleManager().getString("Commands.mcgod")); sender.sendMessage(ChatColor.DARK_AQUA + " /mcgod " + pluginRef.getLocaleManager().getString("Commands.mcgod"));
} }
} }
private void displayPartyCommands(CommandSender sender) { private void displayPartyCommands(CommandSender sender) {
if (Permissions.party(sender)) { if (pluginRef.getPermissionTools().party(sender)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Commands")); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Commands"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party create <" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + "> " + pluginRef.getLocaleManager().getString("Commands.Party1")); sender.sendMessage(ChatColor.DARK_AQUA + " /party create <" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + "> " + pluginRef.getLocaleManager().getString("Commands.Party1"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party join <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party2")); sender.sendMessage(ChatColor.DARK_AQUA + " /party join <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party2"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party quit " + pluginRef.getLocaleManager().getString("Commands.Party.Quit")); sender.sendMessage(ChatColor.DARK_AQUA + " /party quit " + pluginRef.getLocaleManager().getString("Commands.Party.Quit"));
if (Permissions.partyChat(sender)) { if (pluginRef.getPermissionTools().partyChat(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /party chat " + pluginRef.getLocaleManager().getString("Commands.Party.Toggle")); sender.sendMessage(ChatColor.DARK_AQUA + " /party chat " + pluginRef.getLocaleManager().getString("Commands.Party.Toggle"));
} }
sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Invite")); sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Invite"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + pluginRef.getLocaleManager().getString("Commands.Party.Accept")); sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + pluginRef.getLocaleManager().getString("Commands.Party.Accept"));
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) { if (pluginRef.getPermissionTools().partySubcommand(sender, PartySubcommandType.TELEPORT)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Teleport")); sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Teleport"));
} }
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class RefreshCooldownsCommand extends ToggleCommand { public class RefreshCooldownsCommand extends ToggleCommand {
@ -13,12 +12,12 @@ public class RefreshCooldownsCommand extends ToggleCommand {
@Override @Override
protected boolean hasOtherPermission(CommandSender sender) { protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.mcrefreshOthers(sender); return pluginRef.getPermissionTools().mcrefreshOthers(sender);
} }
@Override @Override
protected boolean hasSelfPermission(CommandSender sender) { protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.mcrefresh(sender); return pluginRef.getPermissionTools().mcrefresh(sender);
} }
@Override @Override

View File

@ -0,0 +1,24 @@
package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlayerDebugCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
pluginRef.getNotificationManager().sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
return true;
} else {
return false;
}
}
}

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.admin; package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -20,7 +19,7 @@ public final class ReloadLocaleCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) { if (args.length == 0) {
if (!Permissions.reloadlocale(sender)) { if (!pluginRef.getPermissionTools().reloadlocale(sender)) {
if(command.getPermissionMessage() != null) if(command.getPermissionMessage() != null)
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.ToggleCommand; import com.gmail.nossr50.commands.ToggleCommand;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class ChatSpyCommand extends ToggleCommand { public class ChatSpyCommand extends ToggleCommand {
@ -14,12 +13,12 @@ public class ChatSpyCommand extends ToggleCommand {
@Override @Override
protected boolean hasOtherPermission(CommandSender sender) { protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.adminChatSpyOthers(sender); return pluginRef.getPermissionTools().adminChatSpyOthers(sender);
} }
@Override @Override
protected boolean hasSelfPermission(CommandSender sender) { protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.adminChatSpy(sender); return pluginRef.getPermissionTools().adminChatSpy(sender);
} }
@Override @Override

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -16,12 +15,12 @@ public class AddLevelsCommand extends ExperienceCommand {
@Override @Override
protected boolean permissionsCheckSelf(CommandSender sender) { protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.addlevels(sender); return pluginRef.getPermissionTools().addlevels(sender);
} }
@Override @Override
protected boolean permissionsCheckOthers(CommandSender sender) { protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.addlevelsOthers(sender); return pluginRef.getPermissionTools().addlevelsOthers(sender);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,12 +16,12 @@ public class AddXPCommand extends ExperienceCommand {
@Override @Override
protected boolean permissionsCheckSelf(CommandSender sender) { protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.addxp(sender); return pluginRef.getPermissionTools().addxp(sender);
} }
@Override @Override
protected boolean permissionsCheckOthers(CommandSender sender) { protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.addxpOthers(sender); return pluginRef.getPermissionTools().addxpOthers(sender);
} }
@Override @Override

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,12 +14,12 @@ public class SkillEditCommand extends ExperienceCommand {
@Override @Override
protected boolean permissionsCheckSelf(CommandSender sender) { protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.mmoedit(sender); return pluginRef.getPermissionTools().mmoedit(sender);
} }
@Override @Override
protected boolean permissionsCheckOthers(CommandSender sender) { protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.mmoeditOthers(sender); return pluginRef.getPermissionTools().mmoeditOthers(sender);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -138,11 +137,11 @@ public class SkillResetCommand implements TabExecutor {
} }
protected boolean permissionsCheckSelf(CommandSender sender) { protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.skillreset(sender); return pluginRef.getPermissionTools().skillreset(sender);
} }
protected boolean permissionsCheckOthers(CommandSender sender) { protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.skillresetOthers(sender); return pluginRef.getPermissionTools().skillresetOthers(sender);
} }
protected void handlePlayerMessageAll(Player player) { protected void handlePlayerMessageAll(Player player) {

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -95,7 +94,7 @@ public class PartyCommand implements TabExecutor {
return true; return true;
} }
if (!Permissions.party(sender)) { if (!pluginRef.getPermissionTools().party(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -129,7 +128,7 @@ public class PartyCommand implements TabExecutor {
} }
// Can't use this for lock/unlock since they're handled by the same command // Can't use this for lock/unlock since they're handled by the same command
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) { if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !pluginRef.getPermissionTools().partySubcommand(sender, subcommand)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -63,7 +62,7 @@ public class PartyLockCommand implements CommandExecutor {
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty(); Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) { if (!pluginRef.getPermissionTools().partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoPermission")); sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoPermission"));
return; return;
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -16,7 +15,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.partyTeleportAcceptAll(sender)) { if (!pluginRef.getPermissionTools().partyTeleportAcceptAll(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -19,7 +18,7 @@ public class PtpAcceptCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.partyTeleportAccept(sender)) { if (!pluginRef.getPermissionTools().partyTeleportAccept(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -54,11 +53,11 @@ public class PtpAcceptCommand implements CommandExecutor {
World targetWorld = target.getWorld(); World targetWorld = target.getWorld();
World playerWorld = player.getWorld(); World playerWorld = player.getWorld();
if (!Permissions.partyTeleportAllWorlds(target)) { if (!pluginRef.getPermissionTools().partyTeleportAllWorlds(target)) {
if (!Permissions.partyTeleportWorld(target, targetWorld)) { if (!pluginRef.getPermissionTools().partyTeleportWorld(target, targetWorld)) {
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true; return true;
} else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) { } else if (targetWorld != playerWorld && !pluginRef.getPermissionTools().partyTeleportWorld(target, playerWorld)) {
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true; return true;
} }

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -102,7 +101,7 @@ public class PtpCommand implements TabExecutor {
return ptpAcceptCommand.onCommand(sender, command, label, args); return ptpAcceptCommand.onCommand(sender, command, label, args);
} }
if (!Permissions.partyTeleportSend(sender)) { if (!pluginRef.getPermissionTools().partyTeleportSend(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,7 +16,7 @@ public class PtpToggleCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.partyTeleportToggle(sender)) { if (!pluginRef.getPermissionTools().partyTeleportToggle(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -68,11 +67,11 @@ public class InspectCommand implements TabExecutor {
} else { } else {
Player target = mcMMOPlayer.getPlayer(); Player target = mcMMOPlayer.getPlayer();
if (pluginRef.getCommandTools().hidden(sender, target, Permissions.inspectHidden(sender))) { if (pluginRef.getCommandTools().hidden(sender, target, pluginRef.getPermissionTools().inspectHidden(sender))) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline")); sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline"));
return true; return true;
} }
else if (pluginRef.getCommandTools().tooFar(sender, target, Permissions.inspectFar(sender))) { else if (pluginRef.getCommandTools().tooFar(sender, target, pluginRef.getPermissionTools().inspectFar(sender))) {
return true; return true;
} }

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.LeaderboardsCommandAsyncTask; import com.gmail.nossr50.runnables.commands.LeaderboardsCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -80,7 +79,7 @@ public class LeaderboardCommand implements TabExecutor {
} }
private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) { private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) {
if (skill != null && !Permissions.mctop(sender, skill)) { if (skill != null && !pluginRef.getPermissionTools().mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return; return;
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.RankCommandAsyncTask; import com.gmail.nossr50.runnables.commands.RankCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -32,7 +31,7 @@ public class RankCommand implements TabExecutor {
return true; return true;
} }
if (!Permissions.mcrank(sender)) { if (!pluginRef.getPermissionTools().mcrank(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -46,7 +45,7 @@ public class RankCommand implements TabExecutor {
return true; return true;
case 1: case 1:
if (!Permissions.mcrankOthers(sender)) { if (!pluginRef.getPermissionTools().mcrankOthers(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
@ -62,7 +61,7 @@ public class RankCommand implements TabExecutor {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
playerName = player.getName(); playerName = player.getName();
if (pluginRef.getCommandTools().tooFar(sender, player, Permissions.mcrankFar(sender))) { if (pluginRef.getCommandTools().tooFar(sender, player, pluginRef.getPermissionTools().mcrankFar(sender))) {
return true; return true;
} }
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.server; package com.gmail.nossr50.commands.server;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -20,7 +19,7 @@ public class ReloadPluginCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) { if (sender instanceof Player) {
if (!Permissions.reload(sender)) if (!pluginRef.getPermissionTools().reload(sender))
return false; return false;
} }

View File

@ -74,7 +74,11 @@ public class ArcheryCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK,
<<<<<<< HEAD
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))));
=======
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, 1000))));
>>>>>>> 308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
} }
return messages; return messages;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -58,7 +57,7 @@ public class AxesCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER); canSkullSplitter = pluginRef.getPermissionTools().skullSplitter(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES); canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES);
canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY); canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY);
canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT); canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT);
@ -93,7 +92,11 @@ public class AxesCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK,
<<<<<<< HEAD
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK))));
=======
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.AXES_AXES_LIMIT_BREAK, 1000))));
>>>>>>> 308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
} }
return messages; return messages;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -34,7 +33,7 @@ public class ExcavationCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER); canGigaDrill = pluginRef.getPermissionTools().gigaDrillBreaker(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY); canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -107,7 +106,7 @@ public class FishingCommand extends SkillCommand {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
} }
double luckyModifier = Permissions.lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D; double luckyModifier = pluginRef.getPermissionTools().lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D;
biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier); biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier);
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -86,9 +85,9 @@ public class HerbalismCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK); hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player); canGreenTerra = pluginRef.getPermissionTools().greenTerra(player);
canGreenThumbPlants = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA)); canGreenThumbPlants = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (pluginRef.getPermissionTools().greenThumbPlant(player, Material.WHEAT) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.CARROT) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.POTATO) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.BEETROOT) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.NETHER_WART) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.COCOA));
canGreenThumbBlocks = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS)); canGreenThumbBlocks = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (pluginRef.getPermissionTools().greenThumbBlock(player, Material.DIRT) || pluginRef.getPermissionTools().greenThumbBlock(player, Material.COBBLESTONE) || pluginRef.getPermissionTools().greenThumbBlock(player, Material.COBBLESTONE_WALL) || pluginRef.getPermissionTools().greenThumbBlock(player, Material.STONE_BRICKS));
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET); canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS); canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB); canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB);

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -65,11 +64,11 @@ public class MiningCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBiggerBombs = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player); canBiggerBombs = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && pluginRef.getPermissionTools().biggerBombs(player);
canBlast = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player); canBlast = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && pluginRef.getPermissionTools().remoteDetonation(player);
canDemoExpert = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player); canDemoExpert = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && pluginRef.getPermissionTools().demolitionsExpertise(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS); canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS);
canSuperBreaker = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player); canSuperBreaker = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && pluginRef.getPermissionTools().superBreaker(player);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -37,7 +36,7 @@ public class MmoInfoCommand implements TabExecutor {
return false; return false;
Player player = (Player) commandSender; Player player = (Player) commandSender;
if (Permissions.mmoinfo(player)) { if (pluginRef.getPermissionTools().mmoinfo(player)) {
if (args == null || args[0] == null) if (args == null || args[0] == null)
return false; return false;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -81,7 +80,7 @@ public class RepairCommand extends SkillCommand {
// canRepairString = Permissions.repairMaterialType(player, ItemMaterialCategory.STRING); // canRepairString = Permissions.repairMaterialType(player, ItemMaterialCategory.STRING);
// canRepairLeather = Permissions.repairMaterialType(player, ItemMaterialCategory.LEATHER); // canRepairLeather = Permissions.repairMaterialType(player, ItemMaterialCategory.LEATHER);
// canRepairWood = Permissions.repairMaterialType(player, ItemMaterialCategory.WOOD); // canRepairWood = Permissions.repairMaterialType(player, ItemMaterialCategory.WOOD);
arcaneBypass = (Permissions.arcaneBypass(player) || Permissions.hasRepairEnchantBypassPerk(player)); arcaneBypass = (pluginRef.getPermissionTools().arcaneBypass(player) || pluginRef.getPermissionTools().hasRepairEnchantBypassPerk(player));
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -66,7 +65,7 @@ public abstract class SkillCommand implements TabExecutor {
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
boolean isLucky = Permissions.lucky(player, skill); boolean isLucky = pluginRef.getPermissionTools().lucky(player, skill);
boolean hasEndurance = pluginRef.getSkillTools().getEnduranceLength(player) > 0; boolean hasEndurance = pluginRef.getSkillTools().getEnduranceLength(player) > 0;
double skillValue = mcMMOPlayer.getSkillLevel(skill); double skillValue = mcMMOPlayer.getSkillLevel(skill);
@ -231,7 +230,19 @@ public abstract class SkillCommand implements TabExecutor {
} }
} }
<<<<<<< HEAD
protected abstract void dataCalculations(Player player, double skillValue); protected abstract void dataCalculations(Player player, double skillValue);
=======
protected String getLimitBreakDescriptionParameter() {
if(AdvancedConfig.getInstance().canApplyLimitBreakPVE()) {
return "(PVP/PVE)";
} else {
return "(PVP)";
}
}
protected abstract void dataCalculations(Player player, float skillValue);
>>>>>>> 308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
protected abstract void permissionsCheck(Player player); protected abstract void permissionsCheck(Player player);
@ -249,6 +260,6 @@ public abstract class SkillCommand implements TabExecutor {
* @return true if the player has permission and has the skill unlocked * @return true if the player has permission and has the skill unlocked
*/ */
protected boolean canUseSubskill(Player player, SubSkillType subSkillType) { protected boolean canUseSubskill(Player player, SubSkillType subSkillType) {
return Permissions.isSubSkillEnabled(player, subSkillType) && pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType); return pluginRef.getPermissionTools().isSubSkillEnabled(player, subSkillType) && pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType);
} }
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -53,7 +52,7 @@ public class SmeltingCommand extends SkillCommand {
canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY); canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT); canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT);
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING); //canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART); canUnderstandTheArt = pluginRef.getPermissionTools().vanillaXpBoost(player, skill) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
} }
@Override @Override

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -57,7 +56,7 @@ public class SwordsCommand extends SkillCommand {
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE); canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK); canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canSerratedStrike = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player); canSerratedStrike = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && pluginRef.getPermissionTools().serratedStrikes(player);
} }
@Override @Override
@ -99,7 +98,11 @@ public class SwordsCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
<<<<<<< HEAD
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))));
=======
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, 1000))));
>>>>>>> 308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
} }
return messages; return messages;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -42,7 +41,7 @@ public class TamingCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE); canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT); canCallWild = pluginRef.getPermissionTools().callOfTheWild(player, EntityType.HORSE) || pluginRef.getPermissionTools().callOfTheWild(player, EntityType.WOLF) || pluginRef.getPermissionTools().callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE); canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
canFastFood = canUseSubskill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE); canFastFood = canUseSubskill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
canGore = canUseSubskill(player, SubSkillType.TAMING_GORE); canGore = canUseSubskill(player, SubSkillType.TAMING_GORE);

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -69,7 +68,7 @@ public class UnarmedCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canBerserk = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player); canBerserk = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && pluginRef.getPermissionTools().berserk(player);
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_IRON_ARM_STYLE); canIronArm = canUseSubskill(player, SubSkillType.UNARMED_IRON_ARM_STYLE);
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT); canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM); canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);
@ -111,7 +110,11 @@ public class UnarmedCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) { if (canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK,
<<<<<<< HEAD
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)))); String.valueOf(pluginRef.getCombatTools().getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))));
=======
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, 1000))));
>>>>>>> 308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
} }
return messages; return messages;

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -50,7 +49,7 @@ public class WoodcuttingCommand extends SkillCommand {
@Override @Override
protected void permissionsCheck(Player player) { protected void permissionsCheck(Player player) {
canTreeFell = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player); canTreeFell = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && pluginRef.getPermissionTools().treeFeller(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && pluginRef.getRankTools().getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1; canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && pluginRef.getRankTools().getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER); canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER); /*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);

View File

@ -0,0 +1,340 @@
package com.gmail.nossr50.config.experience;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
if (instance == null) {
instance = new ExperienceConfig();
}
return instance;
}
@Override
protected void loadKeys() {}
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
/*
* FORMULA SETTINGS
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
* XP SETTINGS
*/
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience_Values.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXP(EntityType.OCELOT) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
return noErrorsInConfig(reason);
}
public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); }
/*
* FORMULA SETTINGS
*/
/* EXPLOIT TOGGLES */
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
public boolean isPistonCheatingPrevented() { return config.getBoolean("ExploitFix.PistonCheating", true); }
public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
public boolean allowUnsafeEnchantments() { return config.getBoolean("ExploitFix.UnsafeEnchantments", false); }
public boolean isCOTWBreedingPrevented() { return config.getBoolean("ExploitFix.COTWBreeding", true); }
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); }
/* Curve settings */
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
/* Curve values */
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
/* Global modifier */
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
/* PVP modifier */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
/* Custom XP perk */
public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
/* Diminished Returns */
public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
/* Conversion */
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); }
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); }
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
/* Materials */
public int getXp(PrimarySkillType skill, Material data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
/* Materials */
public int getXp(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
return config.contains(wildcardString);
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
return config.contains(wildcardString);
}
/*
* Experience Bar Stuff
*/
public boolean isPartyExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Party", true);
}
public boolean isPassiveGainsExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Passive", true);
}
public boolean getDoExperienceBarsAlwaysUpdateTitle()
{
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
}
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color");
for(BarColor barColor : BarColor.values())
{
if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
return barColor;
}
//In case the value is invalid
return BarColor.WHITE;
}
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
for(BarStyle barStyle : BarStyle.values())
{
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
return barStyle;
}
//In case the value is invalid
return BarStyle.SOLID;
}
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); }
public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Alchemy */
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Archery */
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); }
public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); }
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXP(EntityType type)
{
return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
}
public boolean preventStoneLavaFarming() { return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);}
}

View File

@ -111,4 +111,12 @@ public class ConfigExploitPrevention {
public ConfigSectionExploitSalvage getConfigSectionExploitSalvage() { public ConfigSectionExploitSalvage getConfigSectionExploitSalvage() {
return configSectionExploitSkills.getConfigSectionExploitSalvage(); return configSectionExploitSkills.getConfigSectionExploitSalvage();
} }
public boolean areSummonsBreedable() {
return configSectionExploitSkills.areSummonsBreedable();
}
public ConfigSectionExploitTaming getConfigSectionExploitTaming() {
return configSectionExploitSkills.getConfigSectionExploitTaming();
}
} }

View File

@ -23,6 +23,9 @@ public class ConfigSectionExploitSkills {
@Setting(value = "Salvage", comment = "Exploit settings related to Salvage") @Setting(value = "Salvage", comment = "Exploit settings related to Salvage")
private ConfigSectionExploitSalvage configSectionExploitSalvage = new ConfigSectionExploitSalvage(); private ConfigSectionExploitSalvage configSectionExploitSalvage = new ConfigSectionExploitSalvage();
@Setting(value = "Taming", comment = "Exploit settings related to Taming")
private ConfigSectionExploitTaming configSectionExploitTaming = new ConfigSectionExploitTaming();
public ConfigSectionExploitAcrobatics getConfigSectionExploitAcrobatics() { public ConfigSectionExploitAcrobatics getConfigSectionExploitAcrobatics() {
return configSectionExploitAcrobatics; return configSectionExploitAcrobatics;
} }
@ -43,6 +46,10 @@ public class ConfigSectionExploitSkills {
return configSectionExploitMining.isPreventCobblestoneStoneGeneratorXP(); return configSectionExploitMining.isPreventCobblestoneStoneGeneratorXP();
} }
public boolean areSummonsBreedable() {
return configSectionExploitTaming.areSummonsBreedable();
}
public boolean isPreventVehicleAutoFarming() { public boolean isPreventVehicleAutoFarming() {
return configSectionExploitHerbalism.isPreventVehicleAutoFarming(); return configSectionExploitHerbalism.isPreventVehicleAutoFarming();
} }
@ -90,4 +97,8 @@ public class ConfigSectionExploitSkills {
public ConfigSectionExploitSalvage getConfigSectionExploitSalvage() { public ConfigSectionExploitSalvage getConfigSectionExploitSalvage() {
return configSectionExploitSalvage; return configSectionExploitSalvage;
} }
public ConfigSectionExploitTaming getConfigSectionExploitTaming() {
return configSectionExploitTaming;
}
} }

View File

@ -0,0 +1,15 @@
package com.gmail.nossr50.config.hocon.antiexploit;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionExploitTaming {
@Setting(value = "Breedable-Summons", comment = "Whether or not players can breed the temporary summons from Call Of The Wild.")
private boolean breedableSummons = false;
public boolean areSummonsBreedable() {
return breedableSummons;
}
}

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.config.hocon.serializers;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.bukkit.Material;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MaterialSerializer implements TypeSerializer<Material> {
private static final String FULLY_QUALIFIED_NAME = "Fully-Qualified-Name";
@Nullable
@Override
public Material deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
Material material = null;
try {
material = Material.matchMaterial(value.getNode(FULLY_QUALIFIED_NAME).getValue(TypeToken.of(String.class)));
} catch (ObjectMappingException | NullPointerException e) {
e.printStackTrace();
}
return material;
}
@Override
public void serialize(@NonNull TypeToken<?> type, @Nullable Material obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
value.getNode(FULLY_QUALIFIED_NAME).setValue(obj.getKey().toString());
}
}

View File

@ -7,6 +7,9 @@ import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.bukkit.Material; import org.bukkit.Material;
/**
* Class is for example purposes
*/
public class MinecraftMaterialWrapperSerializer implements TypeSerializer<MinecraftMaterialWrapper> { public class MinecraftMaterialWrapperSerializer implements TypeSerializer<MinecraftMaterialWrapper> {
private static final String FULLY_QUALIFIED_NAME = "Fully-Qualified-Name"; private static final String FULLY_QUALIFIED_NAME = "Fully-Qualified-Name";

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.config.hocon.serializers;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.bukkit.Material;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class TamingSummonSerializer implements TypeSerializer<TamingSummon> {
@Nullable
@Override
public TamingSummon deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
/*
private Material itemType;
private int itemAmountRequired;
private int entitiesSummoned;
private int summonLifespan;
private int summonCap;
private CallOfTheWildType callOfTheWildType;
private EntityType entityType;
*/
Material itemType = value.getNode("Item-Material").getValue(TypeToken.of(Material.class));
}
@Override
public void serialize(@NonNull TypeToken<?> type, @Nullable TamingSummon obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.config.hocon.skills.taming; package com.gmail.nossr50.config.hocon.skills.taming;
import com.gmail.nossr50.config.ConfigConstants; import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -13,4 +14,48 @@ public class ConfigTaming {
public ConfigTamingSubSkills getSubSkills() { public ConfigTamingSubSkills getSubSkills() {
return subSkills; return subSkills;
} }
public ConfigTamingGore getGore() {
return subSkills.getGore();
}
public ConfigTamingCallOfTheWild getCallOfTheWild() {
return subSkills.getCallOfTheWild();
}
public ConfigTamingSharpenedClaws getSharpenedClaws() {
return subSkills.getSharpenedClaws();
}
public ConfigTamingShockProof getShockProof() {
return subSkills.getShockProof();
}
public ConfigTamingThickFur getThickFur() {
return subSkills.getThickFur();
}
public ConfigTamingEnvironmentallyAware getEnvironmentallyAware() {
return subSkills.getEnvironmentallyAware();
}
public ConfigTamingFastFoodService getFastFoodService() {
return subSkills.getFastFoodService();
}
public ConfigTamingPummel getPummel() {
return subSkills.getPummel();
}
public String getItemString(CallOfTheWildType callOfTheWildType) {
return subSkills.getItemString(callOfTheWildType);
}
public double getMinHorseJumpStrength() {
return subSkills.getMinHorseJumpStrength();
}
public double getMaxHorseJumpStrength() {
return subSkills.getMaxHorseJumpStrength();
}
} }

View File

@ -1,26 +1,54 @@
package com.gmail.nossr50.config.hocon.skills.taming; package com.gmail.nossr50.config.hocon.skills.taming;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.bukkit.Material;
import java.util.HashMap;
@ConfigSerializable @ConfigSerializable
public class ConfigTamingCallOfTheWild { public class ConfigTamingCallOfTheWild {
private static final double MIN_HORSE_DEFAULT = 0.7D;
private static final double MAX_HORSE_DEFAULT = 2.0D;
private static final HashMap<CallOfTheWildType, TamingSummon> TAMING_SUMMON_DEFAULT_MAP;
@Setting(value = "Cat-Summon-Item-Name", comment = "The name of the item used to summon cats.") static {
private String cotwCatItem = "minecraft:raw_cod"; TAMING_SUMMON_DEFAULT_MAP = new HashMap<>();
private String cotwWolfItem = "minecraft:bone"; TAMING_SUMMON_DEFAULT_MAP.put(CallOfTheWildType.CAT, new TamingSummon(CallOfTheWildType.CAT, Material.COD, 10, 1, 240, 1));
private String cotwHorseItem = "minecraft:apple"; TAMING_SUMMON_DEFAULT_MAP.put(CallOfTheWildType.WOLF, new TamingSummon(CallOfTheWildType.WOLF, Material.BONE, 10, 1, 240, 2));
TAMING_SUMMON_DEFAULT_MAP.put(CallOfTheWildType.HORSE, new TamingSummon(CallOfTheWildType.HORSE, Material.APPLE, 10, 1, 240, 1));
public String getCotwCatItem() {
return cotwCatItem;
} }
public String getCotwWolfItem() { //TODO: Set this up for custom item stuff after NBT support is done
return cotwWolfItem;
@Setting(value = "Taming-Summons", comment = "Taming summon settings.")
private HashMap<CallOfTheWildType, TamingSummon> tamingSummonHashMap = TAMING_SUMMON_DEFAULT_MAP;
@Setting(value = "Minimum-Horse-Jump-Strength", comment = "The minimum value of jump strength a summoned COTW horse can have." +
"\nDefault value: "+MIN_HORSE_DEFAULT)
private double minHorseJumpStrength = MIN_HORSE_DEFAULT;
@Setting(value = "Maximum-Horse-Jump-Strength", comment = "The maximum value of jump strength a summoned COTW horse can have." +
"\nDefault value: "+MAX_HORSE_DEFAULT)
private double maxHorseJumpStrength = MAX_HORSE_DEFAULT;
public double getMinHorseJumpStrength() {
return minHorseJumpStrength;
} }
public String getCotwHorseItem() { public double getMaxHorseJumpStrength() {
return cotwHorseItem; return maxHorseJumpStrength;
}
public TamingSummon getCOTWSummon(CallOfTheWildType callOfTheWildType) {
if(tamingSummonHashMap.get(callOfTheWildType) == null) {
System.out.println("mcMMO - Could not find summon config entry for CallOfTheWildType, using default instead - "+callOfTheWildType.toString());
return TAMING_SUMMON_DEFAULT_MAP.get(callOfTheWildType);
} else {
return tamingSummonHashMap.get(callOfTheWildType);
}
} }
} }

View File

@ -3,5 +3,6 @@ package com.gmail.nossr50.config.hocon.skills.taming;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigTamingEnvironmentalllyAware { public class ConfigTamingEnvironmentallyAware {
} }

View File

@ -12,6 +12,9 @@ public class ConfigTamingGore {
@Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = ConfigConstants.MAX_CHANCE_FIELD_DESCRIPTION) @Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = ConfigConstants.MAX_CHANCE_FIELD_DESCRIPTION)
private double maxChance = 50.0; private double maxChance = 50.0;
@Setting(value = "Gore-Bleed-Tick-Length", comment = "How many times to apply the bleed DOT from gore before it wears off.")
private int goreBleedTicks = 2;
@Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = ConfigConstants.MAX_BONUS_LEVEL_DESCRIPTION) @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = ConfigConstants.MAX_BONUS_LEVEL_DESCRIPTION)
private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100);
@ -29,4 +32,8 @@ public class ConfigTamingGore {
public double getGoreMofifier() { public double getGoreMofifier() {
return goreMofifier; return goreMofifier;
} }
public int getGoreBleedTicks() {
return goreBleedTicks;
}
} }

View File

@ -1,7 +1,16 @@
package com.gmail.nossr50.config.hocon.skills.taming; package com.gmail.nossr50.config.hocon.skills.taming;
import com.gmail.nossr50.datatypes.skills.properties.AbstractDamageProperty;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigTamingSharpenedClaws { public class ConfigTamingSharpenedClaws {
@Setting(value = "Bonus-Damage", comment = "The amount of bonus damage Sharpened Claws will add.")
private AbstractDamageProperty bonusDamage;
public AbstractDamageProperty getBonusDamage() {
return bonusDamage;
}
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.config.hocon.skills.taming; package com.gmail.nossr50.config.hocon.skills.taming;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -22,7 +23,7 @@ public class ConfigTamingSubSkills {
private ConfigTamingThickFur thickFur = new ConfigTamingThickFur(); private ConfigTamingThickFur thickFur = new ConfigTamingThickFur();
@Setting(value = "Environmentally-Aware") @Setting(value = "Environmentally-Aware")
private ConfigTamingEnvironmentalllyAware environmentalllyAware = new ConfigTamingEnvironmentalllyAware(); private ConfigTamingEnvironmentallyAware environmentallyAware = new ConfigTamingEnvironmentallyAware();
@Setting(value = "Fast-Food-Service") @Setting(value = "Fast-Food-Service")
private ConfigTamingFastFoodService fastFoodService = new ConfigTamingFastFoodService(); private ConfigTamingFastFoodService fastFoodService = new ConfigTamingFastFoodService();
@ -50,8 +51,8 @@ public class ConfigTamingSubSkills {
return thickFur; return thickFur;
} }
public ConfigTamingEnvironmentalllyAware getEnvironmentalllyAware() { public ConfigTamingEnvironmentallyAware getEnvironmentallyAware() {
return environmentalllyAware; return environmentallyAware;
} }
public ConfigTamingFastFoodService getFastFoodService() { public ConfigTamingFastFoodService getFastFoodService() {
@ -61,4 +62,16 @@ public class ConfigTamingSubSkills {
public ConfigTamingPummel getPummel() { public ConfigTamingPummel getPummel() {
return pummel; return pummel;
} }
public String getItemString(CallOfTheWildType callOfTheWildType) {
return callOfTheWild.getItemString(callOfTheWildType);
}
public double getMinHorseJumpStrength() {
return callOfTheWild.getMinHorseJumpStrength();
}
public double getMaxHorseJumpStrength() {
return callOfTheWild.getMaxHorseJumpStrength();
}
} }

View File

@ -43,9 +43,11 @@ public class DynamicSettingsManager {
private HashMap<Material, Integer> partyItemWeights; private HashMap<Material, Integer> partyItemWeights;
private HashMap<PartyFeature, Integer> partyFeatureUnlocks; private HashMap<PartyFeature, Integer> partyFeatureUnlocks;
/* Skill Behaviours */ /* Misc Managers*/
//TODO: This class is a band-aid fix for a large problem with mcMMO code, they will be removed once the new skill system is in place //TODO: This class is a band-aid fix for a large problem with mcMMO code, they will be removed once the new skill system is in place
private SkillBehaviourManager skillBehaviourManager; private SkillBehaviourManager skillBehaviourManager;
//TODO: Generify and better cross version support
private TamingItemManager tamingItemManager;
public DynamicSettingsManager(mcMMO pluginRef) { public DynamicSettingsManager(mcMMO pluginRef) {
@ -74,15 +76,23 @@ public class DynamicSettingsManager {
} }
/** /**
* Misc managers * Misc managers init
*/ */
private void initMiscManagers() { private void initMiscManagers() {
//Init Skill Behaviour Manager //Init Skill Behaviour Manager
skillBehaviourManager = new SkillBehaviourManager(pluginRef);
initExperienceManager();
initWorldBlackList(); initWorldBlackList();
initExperienceManager();
initSkillBehaviourManager();
initTamingItemManager();
}
private void initSkillBehaviourManager() {
skillBehaviourManager = new SkillBehaviourManager(pluginRef);
}
private void initTamingItemManager() {
tamingItemManager = new TamingItemManager(pluginRef);
} }
private void initWorldBlackList() { private void initWorldBlackList() {
@ -136,7 +146,7 @@ public class DynamicSettingsManager {
/** /**
* Registers bonus drops from several skill configs * Registers bonus drops from several skill configs
*/ */
public void registerBonusDrops() { private void registerBonusDrops() {
bonusDropManager.addToWhitelistByNameID(pluginRef.getConfigManager().getConfigMining().getBonusDrops()); bonusDropManager.addToWhitelistByNameID(pluginRef.getConfigManager().getConfigMining().getBonusDrops());
bonusDropManager.addToWhitelistByNameID(pluginRef.getConfigManager().getConfigHerbalism().getBonusDrops()); bonusDropManager.addToWhitelistByNameID(pluginRef.getConfigManager().getConfigHerbalism().getBonusDrops());
// bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops()); // bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops());
@ -190,6 +200,10 @@ public class DynamicSettingsManager {
return worldBlackListManager; return worldBlackListManager;
} }
public TamingItemManager getTamingItemManager() {
return tamingItemManager;
}
public boolean isWorldBlacklisted(String worldName) { public boolean isWorldBlacklisted(String worldName) {
return getWorldBlackListManager().isWorldBlacklisted(worldName); return getWorldBlackListManager().isWorldBlacklisted(worldName);
} }

View File

@ -19,7 +19,7 @@ public class MaterialMapStore {
private HashSet<String> herbalismAbilityBlackList; private HashSet<String> herbalismAbilityBlackList;
private HashSet<String> blockCrackerWhiteList; private HashSet<String> blockCrackerWhiteList;
private HashSet<String> canMakeShroomyWhiteList; private HashSet<String> canMakeShroomyWhiteList;
private HashSet<String> multiBlockEntities; private HashSet<String> multiBlockPlant;
private HashSet<String> foodItemWhiteList; private HashSet<String> foodItemWhiteList;
public MaterialMapStore() { public MaterialMapStore() {
@ -30,14 +30,15 @@ public class MaterialMapStore {
herbalismAbilityBlackList = new HashSet<>(); herbalismAbilityBlackList = new HashSet<>();
blockCrackerWhiteList = new HashSet<>(); blockCrackerWhiteList = new HashSet<>();
canMakeShroomyWhiteList = new HashSet<>(); canMakeShroomyWhiteList = new HashSet<>();
multiBlockEntities = new HashSet<>(); multiBlockPlant = new HashSet<>();
foodItemWhiteList = new HashSet<>(); foodItemWhiteList = new HashSet<>();
fillHardcodedHashSets(); fillHardcodedHashSets();
} }
public boolean isMultiBlock(Material material) { public boolean isMultiBlockPlant(Material material)
return multiBlockEntities.contains(material.getKey().getKey()); {
return multiBlockPlant.contains(material.getKey().getKey());
} }
public boolean isAbilityActivationBlackListed(Material material) { public boolean isAbilityActivationBlackListed(Material material) {
@ -70,7 +71,7 @@ public class MaterialMapStore {
private void fillHardcodedHashSets() { private void fillHardcodedHashSets() {
fillAbilityBlackList(); fillAbilityBlackList();
filltoolBlackList(); fillToolBlackList();
fillMossyWhiteList(); fillMossyWhiteList();
fillLeavesWhiteList(); fillLeavesWhiteList();
fillHerbalismAbilityBlackList(); fillHerbalismAbilityBlackList();
@ -124,14 +125,17 @@ public class MaterialMapStore {
} }
private void fillMultiBlockEntitiesList() { private void fillMultiBlockEntitiesList() {
multiBlockEntities.add("cactus"); //Multi-Block Plants
multiBlockEntities.add("chorus_plant"); multiBlockPlant.add("cactus");
multiBlockEntities.add("sugar_cane"); multiBlockPlant.add("chorus_plant");
multiBlockEntities.add("kelp_plant"); multiBlockPlant.add("chorus_flower");
multiBlockEntities.add("kelp"); multiBlockPlant.add("sugar_cane");
multiBlockEntities.add("tall_seagrass"); multiBlockPlant.add("kelp_plant");
multiBlockEntities.add("tall_grass"); multiBlockPlant.add("kelp");
multiBlockEntities.add("bamboo"); multiBlockPlant.add("tall_seagrass");
multiBlockPlant.add("large_fern");
multiBlockPlant.add("tall_grass");
multiBlockPlant.add("bamboo");
} }
private void fillShroomyWhiteList() { private void fillShroomyWhiteList() {
@ -268,8 +272,8 @@ public class MaterialMapStore {
abilityBlackList.add("wall_sign"); //1.13 and lower? abilityBlackList.add("wall_sign"); //1.13 and lower?
abilityBlackList.add("sign"); //1.13 and lower? abilityBlackList.add("sign"); //1.13 and lower?
} }
private void fillToolBlackList()
private void filltoolBlackList() { {
//TODO: Add anvils / missing logs //TODO: Add anvils / missing logs
toolBlackList.add("black_bed"); toolBlackList.add("black_bed");
toolBlackList.add("blue_bed"); toolBlackList.add("blue_bed");

View File

@ -29,6 +29,7 @@ public class MetadataConstants {
public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb"; public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb";
public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command"; public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command";
public final static String PETS_ANIMAL_TRACKING_METAKEY = "mcMMO: Pet Animal"; public final static String PETS_ANIMAL_TRACKING_METAKEY = "mcMMO: Pet Animal";
public static final String COTW_TEMPORARY_SUMMON = "mcMMO: COTW Entity";
public static FixedMetadataValue metadataValue; //Gains value in onEnable public static FixedMetadataValue metadataValue; //Gains value in onEnable

View File

@ -84,7 +84,7 @@ public class SkillPropertiesManager {
if(subSkillCategoryNode != null) { if(subSkillCategoryNode != null) {
//Check all the "children" of this skill, this will need to be rewritten in the future //Check all the "children" of this skill, this will need to be rewritten in the future
for (SubSkillType subSkillType : primarySkillType.getSkillAbilities()) { for (SubSkillType subSkillType : pluginRef.getSkillTools().getSkillAbilities(primarySkillType)) {
//HOCON friendly subskill name //HOCON friendly subskill name
String hoconFriendlySubskillName = subSkillType.getHoconFriendlyConfigName(); String hoconFriendlySubskillName = subSkillType.getHoconFriendlyConfigName();

View File

@ -0,0 +1,85 @@
package com.gmail.nossr50.core;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import java.util.HashMap;
//TODO: 2.2 - Need better cross-version support
public class TamingItemManager {
private HashMap<CallOfTheWildType, Material> cotwToSummonItemMap;
private HashMap<Material, CallOfTheWildType> summonItemToCotwMap;
private final mcMMO pluginRef;
public TamingItemManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
initMaps();
}
private void initMaps() {
cotwToSummonItemMap = new HashMap<>();
summonItemToCotwMap = new HashMap<>();
registerCatSummonItem();
registerWolfSummonItem();
registerHorseSummonItem();
}
private void registerCatSummonItem() {
//TODO: Remove the ENUM, use string only
registerSummonItemRelationships(CallOfTheWildType.CAT, Material.COD);
}
private void registerWolfSummonItem() {
//TODO: Remove the ENUM, use string only
registerSummonItemRelationships(CallOfTheWildType.WOLF, Material.BONE);
}
private void registerHorseSummonItem() {
//TODO: Remove the ENUM, use string only
registerSummonItemRelationships(CallOfTheWildType.HORSE, Material.APPLE);
}
public void registerSummonItemRelationships(CallOfTheWildType callOfTheWildType, Material defaultType) {
String materialString = pluginRef.getConfigManager().getConfigTaming().getSubSkills().getCallOfTheWild().getItemString(callOfTheWildType);
pluginRef.getLogger().info("Registering COTW Summon Item - "+callOfTheWildType.toString()+" | "+materialString);
Material material = Material.matchMaterial(materialString);
if(material != null) {
summonItemToCotwMap.put(material, callOfTheWildType);
cotwToSummonItemMap.put(callOfTheWildType, material);
} else {
pluginRef.getLogger().severe("Item not found for COTW summon! Reverting to backup named: "+defaultType.toString());
summonItemToCotwMap.put(defaultType, callOfTheWildType);
cotwToSummonItemMap.put(callOfTheWildType, defaultType);
}
}
public Material getEntitySummonItem(CallOfTheWildType callOfTheWildType) {
return cotwToSummonItemMap.get(callOfTheWildType);
}
public CallOfTheWildType getCallType(Material material) {
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
//TODO: Remove the ENUM, use string only
return summonItemToCotwMap.get(material);
}
public boolean isCOTWItem(Material material) {
return summonItemToCotwMap.get(material) != null;
}
}

View File

@ -81,7 +81,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
/*if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS)) { /*if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS)) {
new UUIDUpdateAsyncTask(mcMMO.p, getStoredUsers()).runTaskAsynchronously(mcMMO.p); new UUIDUpdateAsyncTask(mcMMO.p, getStoredUsers()).runTaskAsynchronously(pluginRef);
}*/ }*/
} }

View File

@ -0,0 +1,30 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.Material;
import org.bukkit.block.Block;
/**
* Contains a snapshot of a block at a specific moment in time
* Used to check before/after type stuff
*/
public class BlockSnapshot {
private final Material oldType;
private Block blockRef;
public BlockSnapshot(Material oldType, Block blockRef) {
this.oldType = oldType;
this.blockRef = blockRef;
}
public Material getOldType() {
return oldType;
}
public Block getBlockRef() {
return blockRef;
}
public boolean hasChangedType() {
return oldType != blockRef.getState().getType();
}
}

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes.party; package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.commands.party.PartySubcommandType; import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public enum PartyFeature { public enum PartyFeature {
@ -33,6 +32,6 @@ public enum PartyFeature {
return false; return false;
} }
return Permissions.partySubcommand(player, partySubCommandType); return pluginRef.getPermissionTools().partySubcommand(player, partySubCommandType);
} }
} }

View File

@ -31,7 +31,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
@ -67,6 +66,8 @@ public class McMMOPlayer {
private boolean partyChatMode; private boolean partyChatMode;
private boolean adminChatMode; private boolean adminChatMode;
private boolean displaySkillNotifications = true; private boolean displaySkillNotifications = true;
private boolean debugMode;
private boolean abilityUse = true; private boolean abilityUse = true;
private boolean godMode; private boolean godMode;
private boolean chatSpy = false; //Off by default private boolean chatSpy = false; //Off by default
@ -106,6 +107,7 @@ public class McMMOPlayer {
} }
experienceBarManager = new ExperienceBarManager(pluginRef,this); experienceBarManager = new ExperienceBarManager(pluginRef,this);
debugMode = false; //Debug mode helps solve support issues, players can toggle it on or off
fillPersonalXPModifiers(); //Cache players XP rates fillPersonalXPModifiers(); //Cache players XP rates
} }
@ -499,6 +501,18 @@ public class McMMOPlayer {
chatSpy = !chatSpy; chatSpy = !chatSpy;
} }
/*
* Debug Mode Flags
*/
public boolean isDebugMode() {
return debugMode;
}
public void toggleDebugMode() {
debugMode = !debugMode;
}
/* /*
* Skill notifications * Skill notifications
*/ */
@ -863,7 +877,7 @@ public class McMMOPlayer {
} }
public void checkGodMode() { public void checkGodMode() {
if (godMode && !Permissions.mcgod(player) if (godMode && !pluginRef.getPermissionTools().mcgod(player)
|| godMode && pluginRef.getDynamicSettingsManager().isWorldBlacklisted(player.getWorld().getName())) { || godMode && pluginRef.getDynamicSettingsManager().isWorldBlacklisted(player.getWorld().getName())) {
toggleGodMode(); toggleGodMode();
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode.Forbidden")); player.sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode.Forbidden"));
@ -871,7 +885,7 @@ public class McMMOPlayer {
} }
public void checkParty() { public void checkParty() {
if (inParty() && !Permissions.party(player)) { if (inParty() && !pluginRef.getPermissionTools().party(player)) {
removeParty(); removeParty();
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Forbidden")); player.sendMessage(pluginRef.getLocaleManager().getString("Party.Forbidden"));
} }
@ -1063,6 +1077,7 @@ public class McMMOPlayer {
Player thisPlayer = getPlayer(); Player thisPlayer = getPlayer();
resetAbilityMode(); resetAbilityMode();
pluginRef.getBleedTimerTask().bleedOut(thisPlayer); pluginRef.getBleedTimerTask().bleedOut(thisPlayer);
cleanup();
if (syncSave) { if (syncSave) {
getProfile().save(true); getProfile().save(true);
@ -1082,4 +1097,15 @@ public class McMMOPlayer {
//Remove user from cache //Remove user from cache
pluginRef.getDatabaseManager().cleanupUser(thisPlayer.getUniqueId()); pluginRef.getDatabaseManager().cleanupUser(thisPlayer.getUniqueId());
} }
/**
* Cleanup various things related to this player
* Such as temporary summons..
* Turning off abilities...
* Etc...
*/
public void cleanup() {
resetAbilityMode();
getTamingManager().cleanupAllSummons();
}
} }

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills; package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -159,28 +158,28 @@ public enum SuperAbilityType {
public boolean getPermissions(Player player) { public boolean getPermissions(Player player) {
switch (this) { switch (this) {
case BERSERK: case BERSERK:
return Permissions.berserk(player); return pluginRef.getPermissionTools().berserk(player);
case BLAST_MINING: case BLAST_MINING:
return Permissions.remoteDetonation(player); return pluginRef.getPermissionTools().remoteDetonation(player);
case GIGA_DRILL_BREAKER: case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(player); return pluginRef.getPermissionTools().gigaDrillBreaker(player);
case GREEN_TERRA: case GREEN_TERRA:
return Permissions.greenTerra(player); return pluginRef.getPermissionTools().greenTerra(player);
case SERRATED_STRIKES: case SERRATED_STRIKES:
return Permissions.serratedStrikes(player); return pluginRef.getPermissionTools().serratedStrikes(player);
case SKULL_SPLITTER: case SKULL_SPLITTER:
return Permissions.skullSplitter(player); return pluginRef.getPermissionTools().skullSplitter(player);
case SUPER_BREAKER: case SUPER_BREAKER:
return Permissions.superBreaker(player); return pluginRef.getPermissionTools().superBreaker(player);
case TREE_FELLER: case TREE_FELLER:
return Permissions.treeFeller(player); return pluginRef.getPermissionTools().treeFeller(player);
default: default:
return false; return false;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills.behaviours; package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;

View File

@ -2,14 +2,9 @@ package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import java.util.HashSet;
/** /**
* These behaviour classes are a band-aid fix for a larger problem * These behaviour classes are a band-aid fix for a larger problem
* Until the new skill system for mcMMO is finished/implemented, there is no good place to store the hardcoded behaviours for each skill * Until the new skill system for mcMMO is finished/implemented, there is no good place to store the hardcoded behaviours for each skill
@ -55,141 +50,6 @@ public class HerbalismBehaviour {
} }
} }
private int calculateChorusPlantDrops(Block target, boolean triple, HerbalismManager herbalismManager) {
return calculateChorusPlantDropsRecursive(target, new HashSet<>(), triple, herbalismManager);
}
private int calculateChorusPlantDropsRecursive(Block target, HashSet<Block> traversed, boolean triple, HerbalismManager herbalismManager) {
if (target.getType() != Material.CHORUS_PLANT)
return 0;
// Prevent any infinite loops, who needs more than 64 chorus anyways
if (traversed.size() > 64)
return 0;
if (!traversed.add(target))
return 0;
int dropAmount = 0;
if (pluginRef.getPlaceStore().isTrue(target))
pluginRef.getPlaceStore().setFalse(target);
else {
dropAmount++;
if (herbalismManager.checkDoubleDrop(target.getState()))
pluginRef.getBlockTools().markDropsAsBonus(target.getState(), triple);
}
for (BlockFace blockFace : new BlockFace[]{BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
dropAmount += calculateChorusPlantDropsRecursive(target.getRelative(blockFace, 1), traversed, triple, herbalismManager);
return dropAmount;
}
/**
* Calculate the drop amounts for multi block plants based on the blocks
* relative to them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
public int countAndMarkDoubleDropsMultiBlockPlant(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
Block block = blockState.getBlock();
Material blockType = blockState.getType();
int dropAmount = 0;
int bonusDropAmount = 0;
int bonusAdd = triple ? 2 : 1;
if (blockType == Material.CHORUS_PLANT) {
dropAmount = 1;
if (block.getRelative(BlockFace.DOWN, 1).getType() == Material.END_STONE) {
dropAmount = calculateChorusPlantDrops(block, triple, herbalismManager);
}
} else {
//Check the block itself first
if (!pluginRef.getPlaceStore().isTrue(block)) {
dropAmount++;
if (herbalismManager.checkDoubleDrop(blockState))
bonusDropAmount += bonusAdd;
} else {
pluginRef.getPlaceStore().setFalse(blockState);
}
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 255; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
if (relativeBlock.getType() != blockType) {
break;
}
if (pluginRef.getPlaceStore().isTrue(relativeBlock)) {
pluginRef.getPlaceStore().setFalse(relativeBlock);
} else {
dropAmount++;
if (herbalismManager.checkDoubleDrop(relativeBlock.getState()))
bonusDropAmount += bonusAdd;
}
}
}
//Mark the original block for bonus drops
pluginRef.getBlockTools().markDropsAsBonus(blockState, bonusDropAmount);
return dropAmount;
}
/**
* Calculate the drop amounts for kelp plants based on the blocks
* relative to them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
public int countAndMarkDoubleDropsKelp(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
Block block = blockState.getBlock();
int kelpMaxHeight = 255;
int amount = 1;
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < kelpMaxHeight; y++) {
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
if (!isKelp(relativeUpBlock))
break;
amount += 1;
if (herbalismManager.checkDoubleDrop(relativeUpBlock.getState()))
pluginRef.getBlockTools().markDropsAsBonus(relativeUpBlock.getState(), triple);
}
return amount;
}
private int addKelpDrops(int dropAmount, Block relativeBlock) {
if (isKelp(relativeBlock) && !pluginRef.getPlaceStore().isTrue(relativeBlock)) {
dropAmount++;
} else {
pluginRef.getPlaceStore().setFalse(relativeBlock);
}
return dropAmount;
}
private boolean isKelp(Block relativeBlock) {
Material kelptype_1 = Material.KELP_PLANT;
Material kelptype_2 = Material.KELP;
return relativeBlock.getType() == kelptype_1 || relativeBlock.getType() == kelptype_2;
}
/** /**
* Convert blocks affected by the Green Thumb & Green Terra abilities. * Convert blocks affected by the Green Thumb & Green Terra abilities.
* *

View File

@ -5,8 +5,11 @@ import com.gmail.nossr50.mcMMO;
/** /**
* These behaviour classes are a band-aid fix for a larger problem * These behaviour classes are a band-aid fix for a larger problem
* Until the new skill system for mcMMO is finished/implemented, there is no good place to store the hardcoded behaviours for each skill * Until the new skill system for mcMMO is finished/implemented, there is no good place to store the hardcoded behaviours for each skill
*
* These behaviour classes server this purpose, they act as a bad solution to a bad problem * These behaviour classes server this purpose, they act as a bad solution to a bad problem
* These classes will be removed when the new skill system is in place * These classes will be removed when the new skill system is in place
*
* All per player state will be held in SkillManager classes, and should not be stored in behaviour classes
*/ */
@Deprecated @Deprecated
public class SkillBehaviourManager { public class SkillBehaviourManager {

View File

@ -1,6 +1,12 @@
package com.gmail.nossr50.datatypes.skills.behaviours; package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import sun.security.krb5.Config;
import java.util.HashMap;
/** /**
* These behaviour classes are a band-aid fix for a larger problem * These behaviour classes are a band-aid fix for a larger problem
@ -12,9 +18,14 @@ import com.gmail.nossr50.mcMMO;
public class TamingBehaviour { public class TamingBehaviour {
private final mcMMO pluginRef; private final mcMMO pluginRef;
private HashMap<CallOfTheWildType, TamingSummon> cotwSummonDataProperties;
public TamingBehaviour(mcMMO pluginRef) { public TamingBehaviour(mcMMO pluginRef) {
this.pluginRef = pluginRef; this.pluginRef = pluginRef;
} }
public TamingSummon getSummon(CallOfTheWildType callOfTheWildType) {
return pluginRef.getConfigManager().getConfigTaming().getCallOfTheWild().getCOTWSummon(callOfTheWildType);
}
} }

View File

@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
@ -23,6 +23,10 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
<<<<<<<HEAD
=======
>>>>>>>308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
public class Roll extends AcrobaticsSubSkill { public class Roll extends AcrobaticsSubSkill {
private final mcMMO pluginRef; private final mcMMO pluginRef;
@ -109,7 +113,7 @@ public class Roll extends AcrobaticsSubSkill {
*/ */
@Override @Override
public boolean hasPermission(Player player) { public boolean hasPermission(Player player) {
return Permissions.isSubSkillEnabled(player, this); return pluginRef.getPermissionTools().isSubSkillEnabled(player, this);
} }
/** /**
@ -125,7 +129,7 @@ public class Roll extends AcrobaticsSubSkill {
/* Values related to the player */ /* Values related to the player */
PlayerProfile playerProfile = pluginRef.getUserManager().getPlayer(player).getProfile(); PlayerProfile playerProfile = pluginRef.getUserManager().getPlayer(player).getProfile();
float skillValue = playerProfile.getSkillLevel(getPrimarySkill()); float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(player, getPrimarySkill()); boolean isLucky = pluginRef.getPermissionTools().lucky(player, getPrimarySkill());
String[] rollStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); String[] rollStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
rollChance = rollStrings[0]; rollChance = rollStrings[0];
@ -180,7 +184,7 @@ public class Roll extends AcrobaticsSubSkill {
} }
private boolean canRoll(Player player) { private boolean canRoll(Player player) {
return pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.ACROBATICS_ROLL) && Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL); return pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.ACROBATICS_ROLL) && pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL);
} }
/** /**
@ -273,21 +277,39 @@ public class Roll extends AcrobaticsSubSkill {
return false; return false;
} }
if (player.getInventory().getItemInMainHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) { 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");
}
return true; return true;
} }
<<<<<<< HEAD
//Teleport CD //Teleport CD
if (System.currentTimeMillis() < pluginRef.getUserManager().getPlayer(player).getTeleportATS()) if (System.currentTimeMillis() < pluginRef.getUserManager().getPlayer(player).getTeleportATS())
return true; return true;
if (pluginRef.getUserManager().getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player))) if (pluginRef.getUserManager().getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
=======
if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
{
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
}
>>>>>>> 308e3a4b1f46e9e3de28d6d540dd055a540ed4d5
return true; return true;
}
return false; return false;
} }
private float calculateRollXP(Player player, double damage, boolean isRoll) { private float calculateRollXP(Player player, double damage, boolean isRoll) {
//Clamp Damage to account for insane DRs
damage = Math.min(40, damage);
ItemStack boots = player.getInventory().getBoots(); ItemStack boots = player.getInventory().getBoots();
float xp = (float) (damage * (isRoll ? pluginRef.getConfigManager().getConfigExperience().getRollXP() : pluginRef.getConfigManager().getConfigExperience().getFallXP())); float xp = (float) (damage * (isRoll ? pluginRef.getConfigManager().getConfigExperience().getRollXP() : pluginRef.getConfigManager().getConfigExperience().getFallXP()));

View File

@ -0,0 +1,26 @@
package com.gmail.nossr50.datatypes.skills.subskills.taming;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.entity.EntityType;
public enum CallOfTheWildType {
WOLF,
CAT,
HORSE;
//TODO: This is a hacky fix to make the COTW code in 2.1 more bearable, this will be removed upon the rework planned for COTW
public String getConfigEntityTypeEntry() {
switch(this) {
case CAT:
return StringUtils.getPrettyEntityTypeString(EntityType.OCELOT); //Even though cats will be summoned in 1.14, we specify Ocelot here. This will be gone in 2.2
case WOLF:
return StringUtils.getPrettyEntityTypeString(EntityType.WOLF);
case HORSE:
return StringUtils.getPrettyEntityTypeString(EntityType.HORSE);
}
return null;
}
}

View File

@ -0,0 +1,87 @@
package com.gmail.nossr50.datatypes.skills.subskills.taming;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
/**
* Data Container for properties used in summoning an entity via COTW
*/
public class TamingSummon {
private Material itemType;
private int itemAmountRequired;
private int entitiesSummoned;
private int summonLifespan;
private int summonCap;
private CallOfTheWildType callOfTheWildType;
private EntityType entityType;
public TamingSummon(CallOfTheWildType callOfTheWildType, Material itemType, int itemAmountRequired, int entitiesSummoned, int summonLifespan, int summonCap) {
this.callOfTheWildType = callOfTheWildType;
this.itemType = itemType;
this.itemAmountRequired = Math.max(itemAmountRequired, 1);
this.entitiesSummoned = Math.max(entitiesSummoned, 1);
this.summonLifespan = summonLifespan;
this.summonCap = Math.max(summonCap, 1);
initEntityType();
}
private void initEntityType() {
switch(callOfTheWildType) {
case WOLF:
entityType = EntityType.WOLF;
break;
case HORSE:
entityType = EntityType.HORSE;
break;
case CAT:
if(shouldSpawnCatInsteadOfOcelot()) {
//Server is on 1.14 or above
entityType = EntityType.CAT;
} else {
//Server is not on 1.14 or above
entityType = EntityType.OCELOT;
}
}
}
private boolean shouldSpawnCatInsteadOfOcelot() {
try {
Class<?> clazz = Class.forName("org.bukkit.entity.Panda");
//Panda exists which means this is at least 1.14, so we should spawn a cat instead of ocelot
return true;
} catch (ClassNotFoundException e) {
/*e.printStackTrace();*/
return false;
}
}
public EntityType getEntityType() {
return entityType;
}
public Material getItemType() {
return itemType;
}
public int getItemAmountRequired() {
return itemAmountRequired;
}
public int getEntitiesSummoned() {
return entitiesSummoned;
}
public int getSummonLifespan() {
return summonLifespan;
}
public int getSummonCap() {
return summonCap;
}
public CallOfTheWildType getCallOfTheWildType() {
return callOfTheWildType;
}
}

View File

@ -238,13 +238,13 @@
// } // }
// //
// public static void scheduleCheck(Player player, BrewingStand brewingStand) { // public static void scheduleCheck(Player player, BrewingStand brewingStand) {
// new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p); // new AlchemyBrewCheckTask(player, brewingStand).runTask(pluginRef);
// } // }
// //
// public static void scheduleUpdate(Inventory inventory) { // public static void scheduleUpdate(Inventory inventory) {
// for (HumanEntity humanEntity : inventory.getViewers()) { // for (HumanEntity humanEntity : inventory.getViewers()) {
// if (humanEntity instanceof Player) { // if (humanEntity instanceof Player) {
// new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p); // new PlayerUpdateInventoryTask((Player) humanEntity).runTask(pluginRef);
// } // }
// } // }
// } // }

View File

@ -13,10 +13,10 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
@ -78,6 +78,9 @@ public class BlockListener implements Listener {
if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getBlock().getWorld().getName())) if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getBlock().getWorld().getName()))
return; return;
if(!pluginRef.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural())
return;
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock(); Block movedBlock = event.getBlock();
// movedBlock = movedBlock.getRelative(direction, 2); // movedBlock = movedBlock.getRelative(direction, 2);
@ -86,7 +89,6 @@ public class BlockListener implements Listener {
if (pluginRef.getBlockTools().shouldBeWatched(b.getState())) { if (pluginRef.getBlockTools().shouldBeWatched(b.getState())) {
movedBlock = b.getRelative(direction); movedBlock = b.getRelative(direction);
if (pluginRef.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural())
pluginRef.getPlaceStore().setTrue(movedBlock); pluginRef.getPlaceStore().setTrue(movedBlock);
} }
} }
@ -103,6 +105,10 @@ public class BlockListener implements Listener {
if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getBlock().getWorld().getName())) if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getBlock().getWorld().getName()))
return; return;
if(!pluginRef.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural()) {
return;
}
// Get opposite direction so we get correct block // Get opposite direction so we get correct block
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock().getRelative(direction); Block movedBlock = event.getBlock().getRelative(direction);
@ -291,7 +297,7 @@ public class BlockListener implements Listener {
* Instead, we check it inside the drops handler. * Instead, we check it inside the drops handler.
*/ */
if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.HERBALISM, player)) { if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.HERBALISM, player)) {
herbalismManager.herbalismBlockCheck(blockState); herbalismManager.processHerbalismBlockBreakEvent(event);
} }
} }
@ -433,15 +439,15 @@ public class BlockListener implements Listener {
if (pluginRef.getBlockTools().canActivateAbilities(blockState)) { if (pluginRef.getBlockTools().canActivateAbilities(blockState)) {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && pluginRef.getItemTools().isHoe(heldItem) && (pluginRef.getBlockTools().affectedByGreenTerra(blockState) || pluginRef.getBlockTools().canMakeMossy(blockState)) && Permissions.greenTerra(player)) { if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && pluginRef.getItemTools().isHoe(heldItem) && (pluginRef.getBlockTools().affectedByGreenTerra(blockState) || pluginRef.getBlockTools().canMakeMossy(blockState)) && pluginRef.getPermissionTools().greenTerra(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && pluginRef.getItemTools().isAxe(heldItem) && pluginRef.getBlockTools().isLog(blockState) && Permissions.treeFeller(player)) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && pluginRef.getItemTools().isAxe(heldItem) && pluginRef.getBlockTools().isLog(blockState) && pluginRef.getPermissionTools().treeFeller(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && pluginRef.getItemTools().isPickaxe(heldItem) && pluginRef.getBlockTools().affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && pluginRef.getItemTools().isPickaxe(heldItem) && pluginRef.getBlockTools().affectedBySuperBreaker(blockState) && pluginRef.getPermissionTools().superBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && pluginRef.getItemTools().isShovel(heldItem) && pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && pluginRef.getItemTools().isShovel(heldItem) && pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) && pluginRef.getPermissionTools().gigaDrillBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || pluginRef.getBlockTools().affectedByBlockCracker(blockState) && Permissions.berserk(player))) { } else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (pluginRef.getBlockTools().affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || pluginRef.getBlockTools().affectedByBlockCracker(blockState) && pluginRef.getPermissionTools().berserk(player))) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
} }
} }
@ -508,7 +514,7 @@ public class BlockListener implements Listener {
* We don't need to check permissions here because they've already been checked for the ability to even activate. * We don't need to check permissions here because they've already been checked for the ability to even activate.
*/ */
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && pluginRef.getBlockTools().canMakeMossy(blockState)) { if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && pluginRef.getBlockTools().canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) { if (mcMMOPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
blockState.update(true); blockState.update(true);
} }
} else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) { } else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
@ -540,18 +546,19 @@ public class BlockListener implements Listener {
} }
} }
public void debugStickDump(Player player, BlockState blockState) { //TODO: Rewrite this
//TODO: Convert into locale strings
if (pluginRef.getPlaceStore().isTrue(blockState)) private void debugStickDump(Player player, BlockState blockState) {
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP"); //Profile not loaded
else { if(pluginRef.getUserManager().getPlayer(player) == null)
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO"); {
pluginRef.getUserManager().getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState); return;
} }
if (WorldGuardUtils.isWorldGuardLoaded()) { if(pluginRef.getUserManager().getPlayer(player).isDebugMode())
if (pluginRef.getWorldGuardManager().hasMainFlag(player)) {
player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region"); if(pluginRef.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else else
player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player in this region"); player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player in this region");
@ -569,10 +576,16 @@ public class BlockListener implements Listener {
if (furnacePlayer != null) { if (furnacePlayer != null) {
player.sendMessage("[mcMMO DEBUG] This furnace is owned by player " + furnacePlayer.getName()); player.sendMessage("[mcMMO DEBUG] This furnace is owned by player " + furnacePlayer.getName());
} }
} else else
player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner"); player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner");
} }
if(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().isEnableXPBars())
player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled.");
player.sendMessage(ChatColor.RED+"You can turn this debug info off by typing "+ ChatColor.GOLD+"/mmodebug");
}
if (pluginRef.getConfigManager().getConfigLeveling().isEnableXPBars()) if (pluginRef.getConfigManager().getConfigLeveling().isEnableXPBars())
player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled."); player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled.");
} }

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.Material; import org.bukkit.Material;
@ -64,8 +63,7 @@ public class EntityListener implements Listener {
//Prevent entities from giving XP if they target endermite //Prevent entities from giving XP if they target endermite
if (event.getTarget() instanceof Endermite) { if (event.getTarget() instanceof Endermite) {
if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY))
|| event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() <= 0)
event.getEntity().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); event.getEntity().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue);
} }
} }
@ -174,13 +172,10 @@ public class EntityListener implements Listener {
} else if (isTracked) { } else if (isTracked) {
pluginRef.getPlaceStore().setTrue(block); pluginRef.getPlaceStore().setTrue(block);
} }
} else if ((block.getType() == Material.REDSTONE_ORE)) { } else if(pluginRef.getPlaceStore().isTrue(block)) {
} else {
if (pluginRef.getPlaceStore().isTrue(block)) {
pluginRef.getPlaceStore().setFalse(block); pluginRef.getPlaceStore().setFalse(block);
} }
} }
}
/*@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) /*@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamageDebugLowest(EntityDamageEvent event) public void onEntityDamageDebugLowest(EntityDamageEvent event)
@ -257,13 +252,15 @@ public class EntityListener implements Listener {
Projectile projectile = (Projectile) event.getCombuster(); Projectile projectile = (Projectile) event.getCombuster();
if(projectile.getShooter() instanceof Player) { if(projectile.getShooter() instanceof Player) {
Player attacker = (Player) projectile.getShooter(); Player attacker = (Player) projectile.getShooter();
if(checkParties(event, defender, attacker))
return; //Don't Ignite party members
event.setCancelled(checkParties(event, defender, attacker));
} }
} else if(event.getCombuster() instanceof Player) { } else if(event.getCombuster() instanceof Player) {
Player attacker = (Player) event.getCombuster(); Player attacker = (Player) event.getCombuster();
if(checkParties(event, defender, attacker))
return; //Don't Ignite party members
event.setCancelled(checkParties(event, defender, attacker));
} }
} }
} }
@ -432,9 +429,8 @@ public class EntityListener implements Listener {
if(!pluginRef.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled()) if(!pluginRef.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled())
if ((pluginRef.getPartyManager().inSameParty(defendingPlayer, attackingPlayer) if ((pluginRef.getPartyManager().inSameParty(defendingPlayer, attackingPlayer)
|| pluginRef.getPartyManager().areAllies(defendingPlayer, attackingPlayer)) || pluginRef.getPartyManager().areAllies(defendingPlayer, attackingPlayer))
&& !(Permissions.friendlyFire(attackingPlayer) && !(pluginRef.getPermissionTools().friendlyFire(attackingPlayer)
&& Permissions.friendlyFire(defendingPlayer))) { && pluginRef.getPermissionTools().friendlyFire(defendingPlayer))) {
event.setCancelled(true);
return true; return true;
} }
return false; return false;
@ -644,7 +640,7 @@ public class EntityListener implements Listener {
* *
* @param event The event to watch * @param event The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getEntity().getWorld().getName())) if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getEntity().getWorld().getName()))
@ -695,6 +691,29 @@ public class EntityListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityBreed(EntityBreedEvent event) {
if(pluginRef.getConfigManager().getConfigExploitPrevention().areSummonsBreedable()) {
//TODO: Change to NBT
if(event.getFather().hasMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON) || event.getMother().hasMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON)) {
event.setCancelled(true);
Animals mom = (Animals) event.getMother();
Animals father = (Animals) event.getFather();
//Prevent love mode spam
mom.setLoveModeTicks(0);
father.setLoveModeTicks(0);
//Inform the player
if(event.getBreeder() instanceof Player) {
Player player = (Player) event.getBreeder();
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.BreedingDisallowed");
}
}
}
}
/** /**
* Handle ExplosionPrime events that involve modifying the event. * Handle ExplosionPrime events that involve modifying the event.
* *
@ -892,7 +911,7 @@ public class EntityListener implements Listener {
* @ 1000 * @ 1000
*/ */
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) { if (pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(pluginRef.getUserManager().getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel)); event.setFoodLevel(pluginRef.getUserManager().getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
} }
return; return;
@ -901,7 +920,7 @@ public class EntityListener implements Listener {
case TROPICAL_FISH: case TROPICAL_FISH:
case COOKED_COD: case COOKED_COD:
case COOKED_SALMON: case COOKED_SALMON:
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) { if (pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
event.setFoodLevel(pluginRef.getUserManager().getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel)); event.setFoodLevel(pluginRef.getUserManager().getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
} }
return; return;
@ -988,7 +1007,7 @@ public class EntityListener implements Listener {
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player,
// and the owner is in the same party // and the owner is in the same party
// So we can make some assumptions here, about our casting and our check // So we can make some assumptions here, about our casting and our check
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) { if (!(pluginRef.getPermissionTools().friendlyFire(player) && pluginRef.getPermissionTools().friendlyFire((Player) tameable.getOwner()))) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask; import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -99,7 +98,7 @@ public class InventoryListener implements Listener {
return; return;
} }
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
return; return;
} }
@ -164,7 +163,7 @@ public class InventoryListener implements Listener {
return; return;
} }
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !pluginRef.getPermissionTools().vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
return; return;
} }

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
@ -17,7 +17,10 @@ import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -141,7 +144,7 @@ public class PlayerListener implements Listener {
Player killedPlayer = event.getEntity(); Player killedPlayer = event.getEntity();
if (!killedPlayer.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY) || Permissions.hardcoreBypass(killedPlayer)) { if (!killedPlayer.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY) || pluginRef.getPermissionTools().hardcoreBypass(killedPlayer)) {
return; return;
} }
@ -274,7 +277,7 @@ public class PlayerListener implements Listener {
} }
} }
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_INNER_PEACE)) { if (pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.FISHING_INNER_PEACE)) {
//Don't modify XP below vanilla values //Don't modify XP below vanilla values
if (fishingManager.addInnerPeaceVanillaXPBoost(event.getExpToDrop()) > 1) if (fishingManager.addInnerPeaceVanillaXPBoost(event.getExpToDrop()) > 1)
event.setExpToDrop(fishingManager.addInnerPeaceVanillaXPBoost(event.getExpToDrop())); event.setExpToDrop(fishingManager.addInnerPeaceVanillaXPBoost(event.getExpToDrop()));
@ -811,11 +814,18 @@ public class PlayerListener implements Listener {
Material type = heldItem.getType(); Material type = heldItem.getType();
TamingManager tamingManager = mcMMOPlayer.getTamingManager(); TamingManager tamingManager = mcMMOPlayer.getTamingManager();
if (type == MainConfig.getInstance().getTamingCOTWMaterial(EntityType.WOLF)) {
switch(type) {
case
}
if (type == ) {
tamingManager.summonWolf(); tamingManager.summonWolf();
} else if (type == MainConfig.getInstance().getTamingCOTWMaterial(EntityType.OCELOT)) { }
else if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.CAT.getConfigEntityTypeEntry())) {
tamingManager.summonOcelot(); tamingManager.summonOcelot();
} else if (type == MainConfig.getInstance().getTamingCOTWMaterial(EntityType.HORSE)) { }
else if (type == Config.getInstance().getTamingCOTWMaterial(CallOfTheWildType.HORSE.getConfigEntityTypeEntry())) {
tamingManager.summonHorse(); tamingManager.summonHorse();
} }

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.PlayerLevelTools;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -31,7 +30,7 @@ public class SelfListener implements Listener {
for (int i = 0; i < event.getLevelsGained(); i++) { for (int i = 0; i < event.getLevelsGained(); i++) {
int previousLevelGained = event.getSkillLevel() - i; int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications //Send player skill unlock notifications
pluginRef.getUserManager().getPlayer(player).processUnlockNotifications(pluginRef, event.getSkill(), previousLevelGained); pluginRef.getUserManager().getPlayer(player).processUnlockNotifications(event.getSkill(), previousLevelGained);
} }
//Reset the delay timer //Reset the delay timer
@ -63,6 +62,11 @@ public class SelfListener implements Listener {
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
PrimarySkillType primarySkillType = event.getSkill(); PrimarySkillType primarySkillType = event.getSkill();
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage(event.getSkill().toString() + " XP Gained");
mcMMOPlayer.getPlayer().sendMessage("Incoming Raw XP: "+event.getRawXpGained());
}
//WorldGuard XP Check //WorldGuard XP Check
if (event.getXpGainReason() == XPGainReason.PVE || if (event.getXpGainReason() == XPGainReason.PVE ||
event.getXpGainReason() == XPGainReason.PVP || event.getXpGainReason() == XPGainReason.PVP ||
@ -72,6 +76,10 @@ public class SelfListener implements Listener {
if (!pluginRef.getWorldGuardManager().hasXPFlag(player)) { if (!pluginRef.getWorldGuardManager().hasXPFlag(player)) {
event.setRawXpGained(0); event.setRawXpGained(0);
event.setCancelled(true); event.setCancelled(true);
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("No WG XP Flag - New Raw XP: "+event.getRawXpGained());
}
} }
} }
} }
@ -85,7 +93,7 @@ public class SelfListener implements Listener {
int earlyGameBonusXP = 0; int earlyGameBonusXP = 0;
//Give some bonus XP for low levels //Give some bonus XP for low levels
if(PlayerLevelTools.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) if(pluginRef.getPlayerLevelTools().qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType))
{ {
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
@ -95,6 +103,9 @@ public class SelfListener implements Listener {
int threshold = pluginRef.getConfigManager().getConfigLeveling().getSkillThreshold(primarySkillType); int threshold = pluginRef.getConfigManager().getConfigLeveling().getSkillThreshold(primarySkillType);
if (threshold <= 0 || !pluginRef.getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { if (threshold <= 0 || !pluginRef.getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) {
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
}
// Diminished returns is turned off // Diminished returns is turned off
return; return;
} }
@ -137,6 +148,10 @@ public class SelfListener implements Listener {
} }
} }
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Final Raw XP: "+event.getRawXpGained());
}
} }

View File

@ -96,6 +96,7 @@ public class mcMMO extends JavaPlugin {
private RandomChanceTools randomChanceTools; private RandomChanceTools randomChanceTools;
private RankTools rankTools; private RankTools rankTools;
private ItemTools itemTools; private ItemTools itemTools;
private PermissionTools permissionTools;
/* Never-Ending tasks */ /* Never-Ending tasks */
private BleedTimerTask bleedTimerTask; private BleedTimerTask bleedTimerTask;
@ -121,11 +122,19 @@ public class mcMMO extends JavaPlugin {
public void onEnable() { public void onEnable() {
try { try {
getLogger().setFilter(new LogFilter(this)); getLogger().setFilter(new LogFilter(this));
//TODO: Disgusting...
MetadataConstants.metadataValue = new FixedMetadataValue(this, true); MetadataConstants.metadataValue = new FixedMetadataValue(this, true);
PluginManager pluginManager = getServer().getPluginManager(); PluginManager pluginManager = getServer().getPluginManager();
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null; healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
//Init Locale Manager
localeManager = new LocaleManager(this); localeManager = new LocaleManager(this);
//Init Permission Tools
permissionTools = new PermissionTools(this);
//upgradeManager = new UpgradeManager(); //upgradeManager = new UpgradeManager();
setupFilePaths(); setupFilePaths();
@ -190,7 +199,7 @@ public class mcMMO extends JavaPlugin {
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
if (getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { if (getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) {
Permissions.generateWorldTeleportPermissions(); pluginRef.getPermissionTools().generateWorldTeleportPermissions();
} }
//Init Rank Tools //Init Rank Tools
@ -785,4 +794,8 @@ public class mcMMO extends JavaPlugin {
public ItemTools getItemTools() { public ItemTools getItemTools() {
return itemTools; return itemTools;
} }
public PermissionTools getPermissionTools() {
return permissionTools;
}
} }

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -131,7 +130,7 @@ public final class PartyManager {
* @return true if party is full and cannot be joined * @return true if party is full and cannot be joined
*/ */
public boolean isPartyFull(Player player, Party targetParty) { public boolean isPartyFull(Player player, Party targetParty) {
return !Permissions.partySizeBypass(player) return !pluginRef.getPermissionTools().partySizeBypass(player)
&& targetParty.getMembers().size() >= pluginRef.getConfigManager().getConfigParty().getPartySizeLimit(); && targetParty.getMembers().size() >= pluginRef.getConfigManager().getConfigParty().getPartySizeLimit();
} }

View File

@ -0,0 +1,23 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.BlockSnapshot;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
public class DelayedHerbalismXPCheckTask extends BukkitRunnable {
private final McMMOPlayer mcMMOPlayer;
private final ArrayList<BlockSnapshot> chorusBlocks;
public DelayedHerbalismXPCheckTask(McMMOPlayer mcMMOPlayer, ArrayList<BlockSnapshot> chorusBlocks) {
this.mcMMOPlayer = mcMMOPlayer;
this.chorusBlocks = chorusBlocks;
}
@Override
public void run() {
mcMMOPlayer.getHerbalismManager().awardXPForBlockSnapshots(chorusBlocks);
}
}

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.behaviours.AcrobaticsBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
@ -64,7 +63,7 @@ public class AcrobaticsManager extends SkillManager {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ACROBATICS_DODGE))
return false; return false;
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ACROBATICS_DODGE)) { if (pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.ACROBATICS_DODGE)) {
/*if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) { /*if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) {
return false; return false;
}*/ }*/

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.behaviours.ArcheryBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -34,21 +33,21 @@ public class ArcheryManager extends SkillManager {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_DAZE))
return false; return false;
return target instanceof Player && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE); return target instanceof Player && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_DAZE);
} }
public boolean canSkillShot() { public boolean canSkillShot() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_SKILL_SHOT);
} }
public boolean canRetrieveArrows() { public boolean canRetrieveArrows() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.ARCHERY_ARROW_RETRIEVAL);
} }
/** /**

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.skills.behaviours.AxesBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.AxesBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -32,39 +31,39 @@ public class AxesManager extends SkillManager {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_AXE_MASTERY)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_AXE_MASTERY))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_AXE_MASTERY); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.AXES_AXE_MASTERY);
} }
public boolean canCriticalHit(LivingEntity target) { public boolean canCriticalHit(LivingEntity target) {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES))
return false; return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES); return target.isValid() && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.AXES_CRITICAL_STRIKES);
} }
public boolean canImpact(LivingEntity target) { public boolean canImpact(LivingEntity target) {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT))
return false; return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT) && axesBehaviour.hasArmor(target); return target.isValid() && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT) && axesBehaviour.hasArmor(target);
} }
public boolean canGreaterImpact(LivingEntity target) { public boolean canGreaterImpact(LivingEntity target) {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_GREATER_IMPACT)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_GREATER_IMPACT))
return false; return false;
return target.isValid() && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.AXES_GREATER_IMPACT) && !axesBehaviour.hasArmor(target); return target.isValid() && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.AXES_GREATER_IMPACT) && !axesBehaviour.hasArmor(target);
} }
public boolean canUseSkullSplitter(LivingEntity target) { public boolean canUseSkullSplitter(LivingEntity target) {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_SKULL_SPLITTER)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.AXES_SKULL_SPLITTER))
return false; return false;
return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer()); return target.isValid() && mcMMOPlayer.getAbilityMode(SuperAbilityType.SKULL_SPLITTER) && pluginRef.getPermissionTools().skullSplitter(getPlayer());
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {
return mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer()); return mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && pluginRef.getPermissionTools().skullSplitter(getPlayer());
} }
/** /**

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -35,7 +34,7 @@ public class ExcavationManager extends SkillManager {
public void excavationBlockCheck(BlockState blockState) { public void excavationBlockCheck(BlockState blockState) {
int xp = excavationBehaviour.getBlockXP(blockState); int xp = excavationBehaviour.getBlockXP(blockState);
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) { if (pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
List<ExcavationTreasure> treasures = excavationBehaviour.getTreasures(blockState); List<ExcavationTreasure> treasures = excavationBehaviour.getTreasures(blockState);
if (!treasures.isEmpty()) { if (!treasures.isEmpty()) {
@ -76,7 +75,7 @@ public class ExcavationManager extends SkillManager {
public void printExcavationDebug(Player player, BlockState blockState) public void printExcavationDebug(Player player, BlockState blockState)
{ {
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) { if (pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
List<ExcavationTreasure> treasures = excavationBehaviour.getTreasures(blockState); List<ExcavationTreasure> treasures = excavationBehaviour.getTreasures(blockState);
if (!treasures.isEmpty()) { if (!treasures.isEmpty()) {

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.fishing; package com.gmail.nossr50.skills.fishing;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -18,7 +17,6 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -62,11 +60,11 @@ public class FishingManager extends SkillManager {
} }
public boolean canShake(Entity target) { public boolean canShake(Entity target) {
return target instanceof LivingEntity && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_SHAKE) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_SHAKE); return target instanceof LivingEntity && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_SHAKE) && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_SHAKE);
} }
public boolean canMasterAngler() { public boolean canMasterAngler() {
return getSkillLevel() >= pluginRef.getRankTools().getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER); return getSkillLevel() >= pluginRef.getRankTools().getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER);
} }
public void setFishingRodCastTimestamp() { public void setFishingRodCastTimestamp() {
@ -146,7 +144,7 @@ public class FishingManager extends SkillManager {
if (overFishCount == 2) { if (overFishCount == 2) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isOp() || Permissions.adminChat(player)) { if (player.isOp() || pluginRef.getPermissionTools().adminChat(player)) {
player.sendMessage(pluginRef.getLocaleManager().getString("Fishing.OverFishingDetected", getPlayer().getDisplayName())); player.sendMessage(pluginRef.getLocaleManager().getString("Fishing.OverFishingDetected", getPlayer().getDisplayName()));
} }
} }
@ -180,7 +178,7 @@ public class FishingManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
if (!Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_ICE_FISHING)) { if (!pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_ICE_FISHING)) {
return false; return false;
} }
@ -262,7 +260,7 @@ public class FishingManager extends SkillManager {
public boolean isMagicHunterEnabled() { public boolean isMagicHunterEnabled() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_MAGIC_HUNTER) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_MAGIC_HUNTER)
&& pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER);
} }
/** /**
@ -277,7 +275,7 @@ public class FishingManager extends SkillManager {
FishingTreasure treasure = null; FishingTreasure treasure = null;
if (pluginRef.getConfigManager().getConfigFishing().isAllowCustomDrops() if (pluginRef.getConfigManager().getConfigFishing().isAllowCustomDrops()
&& Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) { && pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
treasure = getFishingTreasure(); treasure = getFishingTreasure();
} }

View File

@ -1,8 +1,9 @@
package com.gmail.nossr50.skills.herbalism; package com.gmail.nossr50.skills.herbalism;
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.BlockSnapshot;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -12,22 +13,29 @@ import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.skills.behaviours.HerbalismBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.HerbalismBehaviour;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure; import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.DelayedHerbalismXPCheckTask;
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask; import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable; import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List; import java.util.List;
public class HerbalismManager extends SkillManager { public class HerbalismManager extends SkillManager {
@ -50,7 +58,7 @@ public class HerbalismManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
ItemStack item = player.getInventory().getItemInMainHand(); ItemStack item = player.getInventory().getItemInMainHand();
return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && pluginRef.getBlockTools().canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && pluginRef.getBlockTools().canMakeMossy(blockState) && pluginRef.getPermissionTools().greenThumbBlock(player, blockState.getType());
} }
public boolean canUseShroomThumb(BlockState blockState) { public boolean canUseShroomThumb(BlockState blockState) {
@ -61,14 +69,14 @@ public class HerbalismManager extends SkillManager {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
Material itemType = inventory.getItemInMainHand().getType(); Material itemType = inventory.getItemInMainHand().getType();
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && pluginRef.getBlockTools().canMakeShroomy(blockState) && Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB); return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && pluginRef.getBlockTools().canMakeShroomy(blockState) && pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
} }
public boolean canUseHylianLuck() { public boolean canUseHylianLuck() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK);
} }
public boolean canGreenTerraBlock(BlockState blockState) { public boolean canGreenTerraBlock(BlockState blockState) {
@ -76,10 +84,10 @@ public class HerbalismManager extends SkillManager {
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {
return mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer()); return mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && pluginRef.getPermissionTools().greenTerra(getPlayer());
} }
public boolean canGreenTerraPlant() { public boolean isGreenTerraActive() {
return mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA); return mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA);
} }
@ -99,10 +107,10 @@ public class HerbalismManager extends SkillManager {
* @param blockState The {@link BlockState} to check ability activation for * @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise * @return true if the ability was successful, false otherwise
*/ */
public boolean processGreenTerra(BlockState blockState) { public boolean processGreenTerraBlockConversion(BlockState blockState) {
Player player = getPlayer(); Player player = getPlayer();
if (!Permissions.greenThumbBlock(player, blockState.getType())) { if (!pluginRef.getPermissionTools().greenThumbBlock(player, blockState.getType())) {
return false; return false;
} }
@ -121,62 +129,399 @@ public class HerbalismManager extends SkillManager {
} }
/** /**
* @param blockState The {@link BlockState} to check ability activation for * Handles herbalism abilities and XP rewards from a BlockBreakEvent
* @param blockBreakEvent The Block Break Event to process
*/ */
public void herbalismBlockCheck(BlockState blockState) { public void processHerbalismBlockBreakEvent(BlockBreakEvent blockBreakEvent) {
Player player = getPlayer(); Player player = getPlayer();
Material material = blockState.getType();
boolean oneBlockPlant = isOneBlockPlant(material);
// Prevents placing and immediately breaking blocks for exp if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitHerbalism().isPreventVehicleAutoFarming() && player.isInsideVehicle()) {
if (oneBlockPlant && pluginRef.getPlaceStore().isTrue(blockState)) {
return; return;
} }
if (!canBlockCheck()) { /*
return; * There are single-block plants and multi-block plants in Minecraft
* In order to give out proper rewards, we need to collect all blocks that would be broken from this event
*/
//Grab all broken blocks
HashSet<Block> brokenBlocks = getBrokenHerbalismBlocks(blockBreakEvent);
//Handle rewards, xp, ability interactions, etc
processHerbalismOnBlocksBroken(blockBreakEvent, brokenBlocks);
} }
int amount; /**
int xp; * Process rewards for a set of plant blocks for Herbalism
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getSuperAbility()); * @param blockBreakEvent the block break event
* @param brokenPlants plant blocks to process
*/
private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent, HashSet<Block> brokenPlants) {
BlockState originalBreak = blockBreakEvent.getBlock().getState();
// if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) { //TODO: The design of Green Terra needs to change, this is a mess
// CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState); if(pluginRef.getPermissionTools().greenThumbPlant(getPlayer(), originalBreak.getType())) {
// xp = customBlock.getXpGain(); processGreenThumbPlants(originalBreak, isGreenTerraActive());
// }
// if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) {
// drops = blockState.getBlock().getDrops();
// }
// }
// else {
xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(blockState.getType());
if (!oneBlockPlant) { /*
//Kelp is actually two blocks mixed together * Mark blocks for double drops
if (material == Material.KELP_PLANT || material == Material.KELP) { * Be aware of the hacky interactions we are doing with Chorus Plants
amount = herbalismBehaviour.countAndMarkDoubleDropsKelp(blockState, greenTerra, this); */
checkDoubleDropsOnBrokenPlants(brokenPlants);
//It would take an expensive algorithm to predict which parts of a Chorus Tree will break as a result of root break
//So this hacky method is used instead
ArrayList<BlockSnapshot> delayedChorusBlocks = new ArrayList<>(); //Blocks that will be checked in future ticks
HashSet<Block> noDelayPlantBlocks = new HashSet<>(); //Blocks that will be checked immediately
for(Block brokenPlant : brokenPlants) {
/*
* This check is to make XP bars appear to work properly with Chorus Trees by giving XP for the originalBreak immediately instead of later
*/
if(brokenPlant.getLocation().equals(originalBreak.getBlock().getLocation())) {
//If its the same block as the original, we are going to directly check it for being a valid XP gain and add it to the nonChorusBlocks list even if its a chorus block
//This stops a delay from happening when bringing up the XP bar for chorus trees
if(!pluginRef.getPlaceStore().isTrue(originalBreak)) {
//Even if its a chorus block, the original break will be moved to nonChorusBlocks for immediate XP rewards
noDelayPlantBlocks.add(brokenPlant);
} else { } else {
amount = herbalismBehaviour.countAndMarkDoubleDropsMultiBlockPlant(blockState, greenTerra, this); if(isChorusTree(brokenPlant.getType())) {
} //If its a chorus tree AND it was marked as true in the placestore then we add this block to the list of chorus blocks
delayedChorusBlocks.add(new BlockSnapshot(brokenPlant.getType(), brokenPlant));
xp *= amount;
} else { } else {
/* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */ noDelayPlantBlocks.add(brokenPlant); //If its not a chorus plant that was marked as unnatural but it was marked unnatural, put it in the nodelay list to be handled
if (checkDoubleDrop(blockState)) }
pluginRef.getBlockTools().markDropsAsBonus(blockState, greenTerra); }
} else if(isChorusTree(brokenPlant.getType())) {
//Chorus Blocks get checked for XP several ticks later to avoid expensive calculations
delayedChorusBlocks.add(new BlockSnapshot(brokenPlant.getType(), brokenPlant));
} else {
noDelayPlantBlocks.add(brokenPlant);
}
} }
if (Permissions.greenThumbPlant(player, material)) { //Give out XP to the non-chorus blocks
processGreenThumbPlants(blockState, greenTerra); if(noDelayPlantBlocks.size() > 0) {
} //Note: Will contain 1 chorus block if the original block was a chorus block, this is to prevent delays for the XP bar
//} mod config close awardXPForPlantBlocks(noDelayPlantBlocks);
applyXpGain(xp, XPGainReason.PVE);
} }
public boolean isOneBlockPlant(Material material) { if(delayedChorusBlocks.size() > 0) {
return !pluginRef.getMaterialMapStore().isMultiBlock(material); //Check XP for chorus blocks
DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mcMMOPlayer, delayedChorusBlocks);
//Large delay because the tree takes a while to break
delayedHerbalismXPCheckTask.runTaskLater(pluginRef, 20); //Calculate Chorus XP + Bonus Drops 1 tick later
}
}
public void checkDoubleDropsOnBrokenPlants(Collection<Block> brokenPlants) {
for(Block brokenPlant : brokenPlants) {
BlockState brokenPlantState = brokenPlant.getState();
BlockData plantData = brokenPlantState.getBlockData();
//Check for double drops
if(!pluginRef.getPlaceStore().isTrue(brokenPlant)) {
/*
*
* Natural Blocks
*
*
*
*/
//Not all things that are natural should give double drops, make sure its fully mature as well
if(plantData instanceof Ageable) {
Ageable ageable = (Ageable) plantData;
if(isAgeableMature(ageable) || isBizarreAgeable(plantData)) {
markForBonusDrops(brokenPlantState);
}
} else if(checkDoubleDrop(brokenPlantState)) {
//Add metadata to mark this block for double or triple drops
markForBonusDrops(brokenPlantState);
}
} else {
/*
*
* Unnatural Blocks
*
*/
//If its a Crop we need to reward XP when its fully grown
if(isAgeableAndFullyMature(plantData) && !isBizarreAgeable(plantData)) {
//Add metadata to mark this block for double or triple drops
markForBonusDrops(brokenPlantState);
}
}
}
}
/**
* Checks if BlockData is ageable and we can trust that age for Herbalism rewards/XP reasons
* The age of Cactus and sugar canes seems to be useless to use, hence they are bizarre
* @param blockData target BlockData
* @return returns true if the ageable is trustworthy for Herbalism XP / Rewards
*/
public boolean isBizarreAgeable(BlockData blockData) {
if(blockData instanceof Ageable) {
//Catcus and Sugar Canes cannot be trusted
switch(blockData.getMaterial()) {
case CACTUS:
case SUGAR_CANE:
return true;
default:
return false;
}
}
return false;
}
public void markForBonusDrops(BlockState brokenPlantState) {
//Add metadata to mark this block for double or triple drops
boolean awardTriple = mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA);
pluginRef.getBlockTools().markDropsAsBonus(brokenPlantState, awardTriple);
}
/**
* Checks if a block is an ageable and if that ageable is fully mature
* @param plantData target plant
* @return returns true if the block is both an ageable and fully mature
*/
public boolean isAgeableAndFullyMature(BlockData plantData) {
return plantData instanceof Ageable && isAgeableMature((Ageable) plantData);
}
public void awardXPForPlantBlocks(HashSet<Block> brokenPlants) {
int xpToReward = 0;
for(Block brokenPlantBlock : brokenPlants) {
BlockState brokenBlockNewState = brokenPlantBlock.getState();
BlockData plantData = brokenBlockNewState.getBlockData();
if(pluginRef.getPlaceStore().isTrue(brokenBlockNewState)) {
/*
*
* Unnatural Blocks
*
*
*/
//If its a Crop we need to reward XP when its fully grown
if(isAgeableAndFullyMature(plantData) && !isBizarreAgeable(plantData)) {
xpToReward += pluginRef.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(brokenBlockNewState.getType());
}
//Mark it as natural again as it is being broken
pluginRef.getPlaceStore().setFalse(brokenBlockNewState);
} else {
/*
*
* Natural Blocks
*
*
*/
//Calculate XP
if(plantData instanceof Ageable) {
Ageable plantAgeable = (Ageable) plantData;
if(isAgeableMature(plantAgeable) || isBizarreAgeable(plantData)) {
xpToReward += pluginRef.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(brokenBlockNewState.getType());
}
} else {
xpToReward += pluginRef.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(brokenPlantBlock.getType());
}
}
}
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Plants processed: "+brokenPlants.size());
}
//Reward XP
if(xpToReward > 0) {
applyXpGain(xpToReward, XPGainReason.PVE, XPGainSource.SELF);
}
}
public boolean isAgeableMature(Ageable ageable) {
return ageable.getAge() == ageable.getMaximumAge()
&& ageable.getAge() != 0;
}
/**
* Award XP for any blocks that used to be something else but are now AIR
* @param brokenPlants snapshot of broken blocks
*/
public void awardXPForBlockSnapshots(ArrayList<BlockSnapshot> brokenPlants) {
/*
* This handles XP for blocks that we need to check are broken after the fact
* This only applies to chorus trees right now
*/
int xpToReward = 0;
int blocksGivingXP = 0;
for(BlockSnapshot blockSnapshot : brokenPlants) {
BlockState brokenBlockNewState = blockSnapshot.getBlockRef().getState();
//Remove metadata from the snapshot of blocks
if(brokenBlockNewState.hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY)) {
brokenBlockNewState.removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, pluginRef);
}
//If the block is not AIR that means it wasn't broken
if(brokenBlockNewState.getType() != Material.AIR) {
continue;
}
if(pluginRef.getPlaceStore().isTrue(brokenBlockNewState)) {
//Mark it as natural again as it is being broken
pluginRef.getPlaceStore().setFalse(brokenBlockNewState);
} else {
//TODO: Do we care about chorus flower age?
//Calculate XP for the old type
xpToReward += pluginRef.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(blockSnapshot.getOldType());
blocksGivingXP++;
}
}
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Chorus Plants checked for XP: "+brokenPlants.size());
mcMMOPlayer.getPlayer().sendMessage("Valid Chorus Plant XP Gains: "+blocksGivingXP);
}
//Reward XP
if(xpToReward > 0) {
applyXpGain(xpToReward, XPGainReason.PVE, XPGainSource.SELF);
}
}
/**
* Process and return plant blocks from a BlockBreakEvent
* @param blockBreakEvent target event
* @return a set of plant-blocks that were broken as a result of this event
*/
private HashSet<Block> getBrokenHerbalismBlocks(BlockBreakEvent blockBreakEvent) {
//Get an updated capture of this block
BlockState originalBlockBlockState = blockBreakEvent.getBlock().getState();
Material originalBlockMaterial = originalBlockBlockState.getType();
HashSet<Block> blocksBroken = new HashSet<>(); //Blocks broken
//Check if this block is a one block plant or not
boolean oneBlockPlant = isOneBlockPlant(originalBlockMaterial);
if(oneBlockPlant) {
//If the block is a one-block plant return only that
blocksBroken.add(originalBlockBlockState.getBlock());
} else {
//If the block is a multi-block structure, capture a set of all blocks broken and return that
blocksBroken = getBrokenBlocksMultiBlockPlants(originalBlockBlockState, blockBreakEvent);
}
//Return all broken plant-blocks
return blocksBroken;
}
private HashSet<Block> getBrokenChorusBlocks(BlockState originalBreak) {
HashSet<Block> traversedBlocks = grabChorusTreeBrokenBlocksRecursive(originalBreak.getBlock(), new HashSet<>());
return traversedBlocks;
}
private HashSet<Block> grabChorusTreeBrokenBlocksRecursive(Block currentBlock, HashSet<Block> traversed) {
if (!isChorusTree(currentBlock.getType()))
return traversed;
// Prevent any infinite loops, who needs more than 256 chorus anyways
if (traversed.size() > 256)
return traversed;
if (!traversed.add(currentBlock))
return traversed;
//Grab all Blocks in the Tree
for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST ,BlockFace.WEST})
grabChorusTreeBrokenBlocksRecursive(currentBlock.getRelative(blockFace, 1), traversed);
traversed.add(currentBlock);
return traversed;
}
/**
* Grab a set of all plant blocks that are broken as a result of this event
* The method to grab these blocks is a bit hacky and does not hook into the API
* Basically we expect the blocks to be broken if this event is not cancelled and we determine which block are broken on our end rather than any event state captures
*
* @param blockBreakEvent target event
* @return a set of plant-blocks broken from this event
*/
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState originalBlockBroken, BlockBreakEvent blockBreakEvent) {
//Track the broken blocks
HashSet<Block> brokenBlocks;
if (isChorusBranch(originalBlockBroken.getType())) {
brokenBlocks = getBrokenChorusBlocks(originalBlockBroken);
} else {
brokenBlocks = getBlocksBrokenAbove(originalBlockBroken);
}
return brokenBlocks;
}
private boolean isChorusBranch(Material blockType) {
return blockType == Material.CHORUS_PLANT;
}
private boolean isChorusTree(Material blockType) {
return blockType == Material.CHORUS_PLANT || blockType == Material.CHORUS_FLOWER;
}
/**
* Grabs blocks upwards from a target block
* A lot of Plants/Crops in Herbalism only break vertically from a broken block
* The vertical search returns early if it runs into anything that is not a multi-block plant
* Multi-block plants are hard-coded and kept in {@link com.gmail.nossr50.core.MaterialMapStore}
*
* @param breakPointBlockState The point of the "break"
* @return A set of blocks above the target block which can be assumed to be broken
*/
private HashSet<Block> getBlocksBrokenAbove(BlockState breakPointBlockState) {
HashSet<Block> brokenBlocks = new HashSet<>();
Block block = breakPointBlockState.getBlock();
//Add the initial block to the set
brokenBlocks.add(block);
//Limit our search
int maxHeight = 255;
// Search vertically for multi-block plants, exit early if any non-multi block plants
for (int y = 1; y < maxHeight; y++) {
//TODO: Should this grab state? It would be more expensive..
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
//Abandon our search if the block isn't multi
if(!pluginRef.getMaterialMapStore().isMultiBlockPlant(relativeUpBlock.getType()))
break;
brokenBlocks.add(relativeUpBlock);
}
return brokenBlocks;
}
/**
* If the plant is considered a one block plant
* This is determined by seeing if it exists in a hard-coded collection of Multi-Block plants
* @param material target plant material
* @return true if the block is not contained in the collection of multi-block plants
*/
private boolean isOneBlockPlant(Material material) {
return !pluginRef.getMaterialMapStore().isMultiBlockPlant(material);
} }
/** /**
@ -324,7 +669,7 @@ public class HerbalismManager extends SkillManager {
return; return;
} }
if (!handleBlockState(blockState, greenTerra)) { if (!processGrowingPlants(blockState, greenTerra)) {
return; return;
} }
@ -340,7 +685,7 @@ public class HerbalismManager extends SkillManager {
new HerbalismBlockUpdaterTask(blockState).runTaskLater(pluginRef, 0); new HerbalismBlockUpdaterTask(blockState).runTaskLater(pluginRef, 0);
} }
private boolean handleBlockState(BlockState blockState, boolean greenTerra) { private boolean processGrowingPlants(BlockState blockState, boolean greenTerra) {
int greenThumbStage = getGreenThumbStage(); int greenThumbStage = getGreenThumbStage();
blockState.setMetadata(MetadataConstants.GREEN_THUMB_METAKEY, new FixedMetadataValue(pluginRef, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); blockState.setMetadata(MetadataConstants.GREEN_THUMB_METAKEY, new FixedMetadataValue(pluginRef, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));

View File

@ -12,7 +12,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -51,7 +50,7 @@ public class MiningManager extends SkillManager {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DEMOLITIONS_EXPERTISE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DEMOLITIONS_EXPERTISE))
return false; return false;
return getSkillLevel() >= miningBehaviour.getDemolitionExpertUnlockLevel() && Permissions.demolitionsExpertise(getPlayer()); return getSkillLevel() >= miningBehaviour.getDemolitionExpertUnlockLevel() && pluginRef.getPermissionTools().demolitionsExpertise(getPlayer());
} }
public boolean canDetonate() { public boolean canDetonate() {
@ -59,7 +58,7 @@ public class MiningManager extends SkillManager {
return canUseBlastMining() && player.isSneaking() return canUseBlastMining() && player.isSneaking()
&& miningBehaviour.isDetonator(player.getInventory().getItemInMainHand()) && miningBehaviour.isDetonator(player.getInventory().getItemInMainHand())
&& Permissions.remoteDetonation(player); && pluginRef.getPermissionTools().remoteDetonation(player);
} }
public boolean canUseBlastMining() { public boolean canUseBlastMining() {
@ -71,11 +70,11 @@ public class MiningManager extends SkillManager {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_BIGGER_BOMBS))
return false; return false;
return getSkillLevel() >= miningBehaviour.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer()); return getSkillLevel() >= miningBehaviour.getBiggerBombsUnlockLevel() && pluginRef.getPermissionTools().biggerBombs(getPlayer());
} }
public boolean canDoubleDrop() { public boolean canDoubleDrop() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS); return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS) && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS);
} }
/** /**

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
@ -233,7 +232,7 @@ public class RepairManager extends SkillManager {
private short repairCalculate(short durability, int repairAmount) { private short repairCalculate(short durability, int repairAmount) {
Player player = getPlayer(); Player player = getPlayer();
if (Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_REPAIR_MASTERY) if (pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.REPAIR_REPAIR_MASTERY)
&& pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_REPAIR_MASTERY)) { && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_REPAIR_MASTERY)) {
double maxBonusCalc = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY) / 100.0D; double maxBonusCalc = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY) / 100.0D;
@ -243,7 +242,7 @@ public class RepairManager extends SkillManager {
repairAmount += bonus; repairAmount += bonus;
} }
if (Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_SUPER_REPAIR) && checkPlayerProcRepair()) { if (pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.REPAIR_SUPER_REPAIR) && checkPlayerProcRepair()) {
repairAmount *= 2.0D; repairAmount *= 2.0D;
} }
@ -285,12 +284,12 @@ public class RepairManager extends SkillManager {
return; return;
} }
if (Permissions.arcaneBypass(player)) { if (pluginRef.getPermissionTools().arcaneBypass(player)) {
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Arcane.Perfect"); pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Arcane.Perfect");
return; return;
} }
if (getArcaneForgingRank() == 0 || !Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_ARCANE_FORGING)) { if (getArcaneForgingRank() == 0 || !pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.REPAIR_ARCANE_FORGING)) {
for (Enchantment enchant : enchants.keySet()) { for (Enchantment enchant : enchants.keySet()) {
item.removeEnchantment(enchant); item.removeEnchantment(enchant);
} }

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
@ -66,12 +65,12 @@ public class SalvageManager extends SkillManager {
} }
// Permissions checks on material and item types // Permissions checks on material and item types
if (!Permissions.salvageItemType(player, salvageable.getSalvageItemType())) { if (!pluginRef.getPermissionTools().salvageItemType(player, salvageable.getSalvageItemType())) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission");
return; return;
} }
if (!Permissions.salvageMaterialType(player, salvageable.getSalvageItemMaterialCategory())) { if (!pluginRef.getPermissionTools().salvageMaterialType(player, salvageable.getSalvageItemMaterialCategory())) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission");
return; return;
} }
@ -203,7 +202,7 @@ public class SalvageManager extends SkillManager {
}*/ }*/
public double getExtractFullEnchantChance() { public double getExtractFullEnchantChance() {
if (Permissions.hasSalvageEnchantBypassPerk(getPlayer())) if (pluginRef.getPermissionTools().hasSalvageEnchantBypassPerk(getPlayer()))
return 100.0D; return 100.0D;
return pluginRef.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().getExtractFullEnchantChance().get(getArcaneSalvageRank()); return pluginRef.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().getExtractFullEnchantChance().get(getArcaneSalvageRank());
@ -216,7 +215,7 @@ public class SalvageManager extends SkillManager {
private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) { private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) {
Player player = getPlayer(); Player player = getPlayer();
if (!pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE) || !Permissions.arcaneSalvage(player)) { if (!pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE) || !pluginRef.getPermissionTools().arcaneSalvage(player)) {
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed"); pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed");
return null; return null;
} }
@ -238,7 +237,7 @@ public class SalvageManager extends SkillManager {
} }
if (!salvageBehaviour.isArcaneSalvageEnchantLoss() if (!salvageBehaviour.isArcaneSalvageEnchantLoss()
|| Permissions.hasSalvageEnchantBypassPerk(player) || pluginRef.getPermissionTools().hasSalvageEnchantBypassPerk(player)
|| pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) { || pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel, true); enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel, true);

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -18,7 +17,7 @@ public class SmeltingManager extends SkillManager {
} }
public boolean isSecondSmeltSuccessful() { public boolean isSecondSmeltSuccessful() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_SECOND_SMELT) return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_SECOND_SMELT)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SMELTING_SECOND_SMELT, getPlayer()); && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SMELTING_SECOND_SMELT, getPlayer());
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -24,22 +23,22 @@ public class SwordsManager extends SkillManager {
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {
return mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && Permissions.serratedStrikes(getPlayer()); return mcMMOPlayer.getToolPreparationMode(ToolType.SWORD) && pluginRef.getPermissionTools().serratedStrikes(getPlayer());
} }
public boolean canUseStab() { public boolean canUseStab() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_STAB) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_STAB); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_STAB) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_STAB);
} }
public boolean canUseRupture() { public boolean canUseRupture() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_RUPTURE) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_RUPTURE); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_RUPTURE) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_RUPTURE);
} }
public boolean canUseCounterAttack(Entity target) { public boolean canUseCounterAttack(Entity target) {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK))
return false; return false;
return target instanceof LivingEntity && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK); return target instanceof LivingEntity && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.SWORDS_COUNTER_ATTACK);
} }
public boolean canUseSerratedStrike() { public boolean canUseSerratedStrike() {

View File

@ -1,22 +1,25 @@
package com.gmail.nossr50.skills.taming; package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.datatypes.skills.behaviours.TamingBehaviour;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -25,72 +28,79 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class TamingManager extends SkillManager { public class TamingManager extends SkillManager {
private HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<>(); //TODO: Temporary cache, will be changed in 2.2
private long lastSummonTimeStamp;
private TamingBehaviour tamingBehaviour;
private HashMap<CallOfTheWildType, List<TrackedTamingEntity>> playerSummonedEntities;
public TamingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { public TamingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
super(pluginRef, mcMMOPlayer, PrimarySkillType.TAMING); super(pluginRef, mcMMOPlayer, PrimarySkillType.TAMING);
init();
} }
protected void addToTracker(LivingEntity livingEntity) { //TODO: Hacky stuff for 2.1, will be cleaned up in 2.2
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity); private void init() {
//Init Behaviour
tamingBehaviour = new TamingBehaviour(pluginRef);
if (!summonedEntities.containsKey(livingEntity.getType())) { //prevents accidentally summoning too many things when holding down left click
summonedEntities.put(livingEntity.getType(), new ArrayList<>()); lastSummonTimeStamp = 0L;
//Init per-player tracking of summoned entities
initPerPlayerSummonTracking();
} }
summonedEntities.get(livingEntity.getType()).add(trackedEntity); private void initPerPlayerSummonTracking() {
} playerSummonedEntities = new HashMap<>();
protected List<TrackedTamingEntity> getTrackedEntities(EntityType entityType) { for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
return summonedEntities.get(entityType); playerSummonedEntities.put(callOfTheWildType, new ArrayList<TrackedTamingEntity>());
} }
protected void removeFromTracker(TrackedTamingEntity trackedEntity) {
summonedEntities.get(trackedEntity.getLivingEntity().getType()).remove(trackedEntity);
} }
public boolean canUseThickFur() { public boolean canUseThickFur() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_THICK_FUR); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_THICK_FUR);
} }
public boolean canUseEnvironmentallyAware() { public boolean canUseEnvironmentallyAware() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
} }
public boolean canUseShockProof() { public boolean canUseShockProof() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHOCK_PROOF);
} }
public boolean canUseHolyHound() { public boolean canUseHolyHound() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_ENVIRONMENTALLY_AWARE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_HOLY_HOUND); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_HOLY_HOUND);
} }
public boolean canUseFastFoodService() { public boolean canUseFastFoodService() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_FAST_FOOD_SERVICE);
} }
public boolean canUseSharpenedClaws() { public boolean canUseSharpenedClaws() {
return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS) return pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS)
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS); && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_SHARPENED_CLAWS);
} }
public boolean canUseGore() { public boolean canUseGore() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE)) if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_GORE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_GORE);
} }
public boolean canUseBeastLore() { public boolean canUseBeastLore() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE)) if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_BEAST_LORE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.TAMING_BEAST_LORE);
} }
/** /**
@ -99,7 +109,7 @@ public class TamingManager extends SkillManager {
* @param entity The LivingEntity to award XP for * @param entity The LivingEntity to award XP for
*/ */
public void awardTamingXP(LivingEntity entity) { public void awardTamingXP(LivingEntity entity) {
applyXpGain(pluginRef.getDynamicSettingsManager().getExperienceManager().getTamingXp(entity.getType()), XPGainReason.PVE); applyXpGain(ExperienceConfig.getInstance().getTamingXP(entity.getType()), XPGainReason.PVE);
} }
/** /**
@ -109,7 +119,6 @@ public class TamingManager extends SkillManager {
* @param damage The damage being absorbed by the wolf * @param damage The damage being absorbed by the wolf
*/ */
public void fastFoodService(Wolf wolf, double damage) { public void fastFoodService(Wolf wolf, double damage) {
//chance (3rd param)
if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.TAMING_FAST_FOOD_SERVICE, getPlayer())) { if (!pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.TAMING_FAST_FOOD_SERVICE, getPlayer())) {
return; return;
} }
@ -134,62 +143,66 @@ public class TamingManager extends SkillManager {
return 0; return 0;
} }
pluginRef.getBleedTimerTask().add(target, getPlayer(), Taming.getInstance().getGoreBleedTicks(), 1, 2); pluginRef.getBleedTimerTask().add(target, getPlayer(), pluginRef.getConfigManager().getConfigTaming().getSubSkills().getGore().getGoreBleedTicks(), 1, 2);
if (target instanceof Player) { if (target instanceof Player) {
pluginRef.getNotificationManager().sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore"); pluginRef.getNotificationManager().sendPlayerInformation((Player)target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore");
} }
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore"); pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore");
damage = (damage * Taming.getInstance().getGoreModifier()) - damage; damage = (damage * pluginRef.getConfigManager().getConfigTaming().getSubSkills().getGore().getGoreMofifier()) - damage;
return damage; return damage;
} }
public double getSharpenedClawsDamage() { //TODO: Add tooltips to /taming for this
return Taming.getInstance().getSharpenedClawsBonusDamage(); public double sharpenedClaws(boolean PVE) {
if(PVE)
return pluginRef.getConfigManager().getConfigTaming().getSubSkills().getSharpenedClaws().getBonusDamage().getPVEModifier();
else
return pluginRef.getConfigManager().getConfigTaming().getSubSkills().getSharpenedClaws().getBonusDamage().getPVPModifier();
} }
/** /**
* Summon an ocelot to your side. * Summon an ocelot to your side.
*/ */
public void summonOcelot() { public void summonOcelot() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) { if (!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), EntityType.OCELOT)) {
return; return;
} }
callOfTheWild(EntityType.OCELOT, MainConfig.getInstance().getTamingCOTWCost(EntityType.OCELOT)); processCallOfTheWild();
} }
/** /**
* Summon a wolf to your side. * Summon a wolf to your side.
*/ */
public void summonWolf() { public void summonWolf() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) { if (!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), EntityType.WOLF)) {
return; return;
} }
callOfTheWild(EntityType.WOLF, MainConfig.getInstance().getTamingCOTWCost(EntityType.WOLF)); processCallOfTheWild();
} }
/** /**
* Summon a horse to your side. * Summon a horse to your side.
*/ */
public void summonHorse() { public void summonHorse() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD)) if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_CALL_OF_THE_WILD))
return; return;
if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) { if (!pluginRef.getPermissionTools().callOfTheWild(getPlayer(), EntityType.HORSE)) {
return; return;
} }
callOfTheWild(EntityType.HORSE, MainConfig.getInstance().getTamingCOTWCost(EntityType.HORSE)); processCallOfTheWild();
} }
/** /**
@ -223,10 +236,10 @@ public class TamingManager extends SkillManager {
} }
public void pummel(LivingEntity target, Wolf wolf) { public void pummel(LivingEntity target, Wolf wolf) {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL)) if(!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
return; return;
if (!pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL))) if(!pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(pluginRef, pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getStaticChance(SubSkillType.TAMING_PUMMEL), getPlayer(), SubSkillType.TAMING_PUMMEL)))
return; return;
ParticleEffectUtils.playGreaterImpactEffect(target); ParticleEffectUtils.playGreaterImpactEffect(target);
@ -242,9 +255,11 @@ public class TamingManager extends SkillManager {
} }
public void attackTarget(LivingEntity target) { public void attackTarget(LivingEntity target) {
if (target instanceof Tameable) { if(target instanceof Tameable)
{
Tameable tameable = (Tameable) target; Tameable tameable = (Tameable) target;
if (tameable.getOwner() == getPlayer()) { if(tameable.getOwner() == getPlayer())
{
return; return;
} }
} }
@ -266,133 +281,258 @@ public class TamingManager extends SkillManager {
} }
} }
/**
* Handle the Call of the Wild ability. private void processCallOfTheWild() {
* //Prevent summoning too many things accidentally if a player holds down the button
* @param type The type of entity to summon. if(lastSummonTimeStamp + 150 > System.currentTimeMillis()) {
* @param summonAmount The amount of material needed to summon the entity return;
*/ } else {
private void callOfTheWild(EntityType type, int summonAmount) { lastSummonTimeStamp = System.currentTimeMillis();
}
Player player = getPlayer(); Player player = getPlayer();
ItemStack itemInMainHand = player.getInventory().getItemInMainHand();
ItemStack heldItem = player.getInventory().getItemInMainHand(); //Check if the item the player is currently holding is a COTW item
int heldItemAmount = heldItem.getAmount(); if(isCOTWItem(itemInMainHand)) {
Location location = player.getLocation(); //Get the summoning type
CallOfTheWildType callOfTheWildType = pluginRef.getDynamicSettingsManager().getTamingItemManager().getCallType(itemInMainHand.getType());
TamingSummon tamingSummon = tamingBehaviour.getSummon(callOfTheWildType);
if (heldItemAmount < summonAmount) { //Players will pay for the cost if at least one thing was summoned
int moreAmount = summonAmount - heldItemAmount; int amountSummoned = 0;
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.NotEnough", String.valueOf(moreAmount), StringUtils.getPrettyItemString(heldItem.getType()));
return;
}
if (!rangeCheck(type)) { //Check to see if players have the correct amount of the item required to summon
return; if(itemInMainHand.getAmount() >= tamingSummon.getItemAmountRequired()) {
} //Initial Spawn location
Location spawnLocation = Misc.getLocationOffset(player.getLocation(), 1);
int amount = MainConfig.getInstance().getTamingCOTWAmount(type); //COTW can summon multiple entities per usage
int tamingCOTWLength = MainConfig.getInstance().getTamingCOTWLength(type); for (int i = 0; i < tamingSummon.getEntitiesSummoned(); i++) {
for (int i = 0; i < amount; i++) { if (getAmountCurrentlySummoned(callOfTheWildType) >= tamingSummon.getSummonCap()) {
if (!summonAmountCheck(type)) { pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.Limit",
return; String.valueOf(tamingSummon.getSummonCap()),
} StringUtils.getCapitalized(callOfTheWildType.toString()));
location = Misc.getLocationOffset(location, 1);
LivingEntity callOfWildEntity = (LivingEntity) player.getWorld().spawnEntity(location, type);
FakeEntityTameEvent event = new FakeEntityTameEvent(callOfWildEntity, player);
pluginRef.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
callOfWildEntity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue);
((Tameable) callOfWildEntity).setOwner(player);
callOfWildEntity.setRemoveWhenFarAway(false);
addToTracker(callOfWildEntity);
switch (type) {
case OCELOT:
((Ocelot) callOfWildEntity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
break; break;
}
spawnLocation = Misc.getLocationOffset(spawnLocation, 1);
spawnCOTWEntity(callOfTheWildType, spawnLocation, tamingSummon.getEntityType());
//Inform the player about what they have just done
if (tamingSummon.getSummonLifespan() > 0) {
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.Success.WithLifespan",
StringUtils.getCapitalized(callOfTheWildType.toString()), String.valueOf(tamingSummon.getSummonLifespan()));
} else {
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.Success.WithoutLifespan", StringUtils.getCapitalized(callOfTheWildType.toString()));
}
//Send Sound
SoundManager.sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);
amountSummoned++;
}
//Remove items from the player if they had at least one entity summoned successfully
if(amountSummoned >= 1) {
//Remove the items used to summon
int itemAmountAfterPayingCost = itemInMainHand.getAmount() - tamingSummon.getItemAmountRequired();
itemInMainHand.setAmount(itemAmountAfterPayingCost);
player.updateInventory();
}
} else {
//Player did not have enough of the item in their main hand
int difference = tamingSummon.getItemAmountRequired() - itemInMainHand.getAmount();
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.NeedMoreItems", String.valueOf(difference), StringUtils.getPrettyItemString(itemInMainHand.getType()));
}
}
}
private void spawnCOTWEntity(CallOfTheWildType callOfTheWildType, Location spawnLocation, EntityType entityType) {
switch(callOfTheWildType) {
case CAT:
//Entity type is needed for cats because in 1.13 and below we spawn ocelots, in 1.14 and above we spawn cats
spawnCat(spawnLocation, entityType);
break;
case HORSE:
spawnHorse(spawnLocation);
break;
case WOLF: case WOLF:
spawnWolf(spawnLocation);
break;
}
}
private void spawnWolf(Location spawnLocation) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, EntityType.WOLF);
//This is used to prevent XP gains for damaging this entity
applyMetaDataToCOTWEntity(callOfWildEntity);
setBaseCOTWEntityProperties(callOfWildEntity);
((Wolf) callOfWildEntity).setAdult();
addToTracker(callOfWildEntity, CallOfTheWildType.WOLF);
//Setup wolf stats
callOfWildEntity.setMaxHealth(20.0); callOfWildEntity.setMaxHealth(20.0);
callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth()); callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth());
break;
case HORSE: callOfWildEntity.setCustomName(pluginRef.getLocaleManager().getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.WOLF)));
}
private void spawnCat(Location spawnLocation, EntityType entityType) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, entityType);
//This is used to prevent XP gains for damaging this entity
applyMetaDataToCOTWEntity(callOfWildEntity);
setBaseCOTWEntityProperties(callOfWildEntity);
addToTracker(callOfWildEntity, CallOfTheWildType.CAT);
//Randomize the cat
if(callOfWildEntity instanceof Ocelot) {
int numberOfTypes = Ocelot.Type.values().length;
((Ocelot) callOfWildEntity).setCatType(Ocelot.Type.values()[Misc.getRandom().nextInt(numberOfTypes)]);
((Ocelot) callOfWildEntity).setAdult();
} else if(callOfWildEntity instanceof Cat) {
int numberOfTypes = Cat.Type.values().length;
((Cat) callOfWildEntity).setCatType(Cat.Type.values()[Misc.getRandom().nextInt(numberOfTypes)]);
((Cat) callOfWildEntity).setAdult();
}
callOfWildEntity.setCustomName(pluginRef.getLocaleManager().getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(entityType)));
//Particle effect
ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity);
}
private void spawnHorse(Location spawnLocation) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
applyMetaDataToCOTWEntity(callOfWildEntity);
setBaseCOTWEntityProperties(callOfWildEntity);
addToTracker(callOfWildEntity, CallOfTheWildType.HORSE);
//Randomize Horse
Horse horse = (Horse) callOfWildEntity; Horse horse = (Horse) callOfWildEntity;
callOfWildEntity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15)); callOfWildEntity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth()); callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]); horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]); horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength()))); horse.setJumpStrength(Math.max(pluginRef.getConfigManager().getConfigTaming().getMinHorseJumpStrength(),
Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, pluginRef.getConfigManager().getConfigTaming().getMaxHorseJumpStrength())));
horse.setAdult();
//TODO: setSpeed, once available //TODO: setSpeed, once available
break;
default: callOfWildEntity.setCustomName(pluginRef.getLocaleManager().getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.HORSE)));
break;
}
if (Permissions.renamePets(player)) {
callOfWildEntity.setCustomName(pluginRef.getLocaleManager().getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
}
//Particle effect
ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity); ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity);
} }
ItemStack leftovers = new ItemStack(heldItem); private void setBaseCOTWEntityProperties(LivingEntity callOfWildEntity) {
leftovers.setAmount(heldItemAmount - summonAmount); ((Tameable) callOfWildEntity).setOwner(getPlayer());
player.getInventory().setItemInMainHand(heldItemAmount == summonAmount ? null : leftovers); callOfWildEntity.setRemoveWhenFarAway(false);
String lifeSpan = "";
if (tamingCOTWLength > 0) {
lifeSpan = pluginRef.getLocaleManager().getString("Taming.Summon.Lifespan", tamingCOTWLength);
} }
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Taming.Summon.Complete", lifeSpan); private void applyMetaDataToCOTWEntity(LivingEntity callOfWildEntity) {
player.playSound(location, Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 1F, 0.5F); //This is used to prevent XP gains for damaging this entity
callOfWildEntity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue);
//This helps identify the entity as being summoned by COTW
callOfWildEntity.setMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON, MetadataConstants.metadataValue);
} }
private boolean rangeCheck(EntityType type) { /**
double range = MainConfig.getInstance().getTamingCOTWRange(); * Whether or not the itemstack is used for COTW
Player player = getPlayer(); * @param itemStack target ItemStack
* @return true if it is used for any COTW
if (range == 0) { */
return true; public boolean isCOTWItem(ItemStack itemStack) {
return pluginRef.getDynamicSettingsManager().getTamingItemManager().isCOTWItem(itemStack.getType());
} }
for (Entity entity : player.getNearbyEntities(range, range, range)) { //TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
if (entity.getType() == type) { private int getAmountCurrentlySummoned(CallOfTheWildType callOfTheWildType) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, Taming.getInstance().getCallOfTheWildFailureMessage(type)); //The tracker is unreliable so validate its contents first
return false; recalibrateTracker();
return playerSummonedEntities.get(callOfTheWildType).size();
}
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
private void addToTracker(LivingEntity livingEntity, CallOfTheWildType callOfTheWildType) {
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(pluginRef, livingEntity, callOfTheWildType, this);
playerSummonedEntities.get(callOfTheWildType).add(trackedEntity);
}
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
public List<TrackedTamingEntity> getTrackedEntities(CallOfTheWildType callOfTheWildType) {
return playerSummonedEntities.get(callOfTheWildType);
}
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
public void removeFromTracker(TrackedTamingEntity trackedEntity) {
if(playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).contains(trackedEntity))
playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).remove(trackedEntity);
pluginRef.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Taming.Summon.COTW.TimeExpired", StringUtils.getPrettyEntityTypeString(trackedEntity.getLivingEntity().getType()));
}
/**
* Builds a new tracked list by determining which tracked things are still valid
*/
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
private void recalibrateTracker() {
for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
ArrayList<TrackedTamingEntity> validEntities = getValidTrackedEntities(callOfTheWildType);
playerSummonedEntities.put(callOfTheWildType, validEntities); //Replace the old list with the new list
} }
} }
return true; //TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
private ArrayList<TrackedTamingEntity> getValidTrackedEntities(CallOfTheWildType callOfTheWildType) {
ArrayList<TrackedTamingEntity> validTrackedEntities = new ArrayList<>();
for(TrackedTamingEntity trackedTamingEntity : getTrackedEntities(callOfTheWildType)) {
LivingEntity livingEntity = trackedTamingEntity.getLivingEntity();
//Remove from existence
if(livingEntity != null && livingEntity.isValid()) {
validTrackedEntities.add(trackedTamingEntity);
}
} }
private boolean summonAmountCheck(EntityType entityType) { return validTrackedEntities;
Player player = getPlayer();
int maxAmountSummons = MainConfig.getInstance().getTamingCOTWMaxAmount(entityType);
if (maxAmountSummons <= 0) {
return true;
} }
List<TrackedTamingEntity> trackedEntities = getTrackedEntities(entityType); /**
int summonAmount = trackedEntities == null ? 0 : trackedEntities.size(); * Remove all tracked entities from existence if they currently exist
* Clear the tracked entity lists afterwards
*/
//TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update
public void cleanupAllSummons() {
for(List<TrackedTamingEntity> trackedTamingEntities : playerSummonedEntities.values()) {
for(TrackedTamingEntity trackedTamingEntity : trackedTamingEntities) {
LivingEntity livingEntity = trackedTamingEntity.getLivingEntity();
if (summonAmount >= maxAmountSummons) { //Remove from existence
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Taming.Summon.Fail.TooMany", String.valueOf(maxAmountSummons)); if(livingEntity != null && livingEntity.isValid()) {
return false; livingEntity.setHealth(0);
livingEntity.remove();
}
} }
return true; //Clear the list
trackedTamingEntities.clear();
}
} }
} }

View File

@ -1,26 +1,31 @@
package com.gmail.nossr50.skills.taming; package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID; import java.util.UUID;
public class TrackedTamingEntity extends BukkitRunnable { public class TrackedTamingEntity extends BukkitRunnable {
private LivingEntity livingEntity; private LivingEntity livingEntity;
private final CallOfTheWildType callOfTheWildType;
private UUID id; private UUID id;
private int length; private int length;
private final TamingManager tamingManagerRef;
private final mcMMO pluginRef;
protected TrackedTamingEntity(LivingEntity livingEntity) { protected TrackedTamingEntity(mcMMO pluginRef, LivingEntity livingEntity, CallOfTheWildType callOfTheWildType, TamingManager tamingManagerRef) {
this.tamingManagerRef = tamingManagerRef;
this.callOfTheWildType = callOfTheWildType;
this.livingEntity = livingEntity; this.livingEntity = livingEntity;
this.id = livingEntity.getUniqueId(); this.id = livingEntity.getUniqueId();
int tamingCOTWLength = MainConfig.getInstance().getTamingCOTWLength(livingEntity.getType()); int tamingCOTWLength = pluginRef.getConfigManager().getConfigTaming().getSubSkills().getCallOfTheWild()..getTamingCOTWLength(livingEntity.getType());
if (tamingCOTWLength > 0) { if (tamingCOTWLength > 0) {
this.length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR; this.length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR;
@ -35,17 +40,26 @@ public class TrackedTamingEntity extends BukkitRunnable {
location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F);
ParticleEffectUtils.playCallOfTheWildEffect(livingEntity); ParticleEffectUtils.playCallOfTheWildEffect(livingEntity);
pluginRef.getCombatTools().dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); pluginRef.getCombatTools().dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity);
if(tamingManagerRef != null)
tamingManagerRef.removeFromTracker(this);
livingEntity.setHealth(0);
livingEntity.remove();
} }
TamingManager.removeFromTracker(this);
this.cancel(); this.cancel();
} }
protected LivingEntity getLivingEntity() { public CallOfTheWildType getCallOfTheWildType() {
return callOfTheWildType;
}
public LivingEntity getLivingEntity() {
return livingEntity; return livingEntity;
} }
protected UUID getID() { public UUID getID() {
return id; return id;
} }
} }

View File

@ -9,8 +9,6 @@ import org.bukkit.inventory.ItemStack;
public class Unarmed { public class Unarmed {
// public static boolean blockCrackerSmoothBrick = MainConfig.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked(); // public static boolean blockCrackerSmoothBrick = MainConfig.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
public static double berserkDamageModifier = 1.5; public static double berserkDamageModifier = 1.5;
public static long lastAttacked = 0;
public static long attackInterval = 750;
public static void handleItemPickup(Player player, EntityPickupItemEvent event) { public static void handleItemPickup(Player player, EntityPickupItemEvent event) {
ItemStack[] storageContents = player.getInventory().getStorageContents(); ItemStack[] storageContents = player.getInventory().getStorageContents();

View File

@ -10,30 +10,40 @@ import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class UnarmedManager extends SkillManager { public class UnarmedManager extends SkillManager {
private long lastAttacked;
private long attackInterval;
public UnarmedManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { public UnarmedManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
super(pluginRef, mcMMOPlayer, PrimarySkillType.UNARMED); super(pluginRef, mcMMOPlayer, PrimarySkillType.UNARMED);
initUnarmedPerPlayerVars();
}
/**
* Inits variables used for each player for unarmed
*/
private void initUnarmedPerPlayerVars() {
lastAttacked = 0;
attackInterval = 750;
} }
public boolean canActivateAbility() { public boolean canActivateAbility() {
return mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && Permissions.berserk(getPlayer()); return mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && pluginRef.getPermissionTools().berserk(getPlayer());
} }
public boolean canUseIronArm() { public boolean canUseIronArm() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_IRON_ARM_STYLE);
} }
public boolean canUseBerserk() { public boolean canUseBerserk() {
@ -44,7 +54,7 @@ public class UnarmedManager extends SkillManager {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_DISARM))
return false; return false;
return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_DISARM); return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_DISARM);
} }
public boolean canDeflect() { public boolean canDeflect() {
@ -53,14 +63,14 @@ public class UnarmedManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
return pluginRef.getItemTools().isUnarmed(player.getInventory().getItemInMainHand()) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT); return pluginRef.getItemTools().isUnarmed(player.getInventory().getItemInMainHand()) && pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_ARROW_DEFLECT);
} }
public boolean canUseBlockCracker() { public boolean canUseBlockCracker() {
if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER)) if (!pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER))
return false; return false;
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER); return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.UNARMED_BLOCK_CRACKER);
} }
public boolean blockCrackerCheck(BlockState blockState) { public boolean blockCrackerCheck(BlockState blockState) {
@ -68,8 +78,6 @@ public class UnarmedManager extends SkillManager {
return false; return false;
} }
BlockData data = blockState.getBlockData();
switch (blockState.getType()) { switch (blockState.getType()) {
case STONE_BRICKS: case STONE_BRICKS:
/*if (!Unarmed.blockCrackerSmoothBrick) { /*if (!Unarmed.blockCrackerSmoothBrick) {
@ -144,7 +152,7 @@ public class UnarmedManager extends SkillManager {
} }
public boolean isPunchingCooldownOver() { public boolean isPunchingCooldownOver() {
return (Unarmed.lastAttacked + Unarmed.attackInterval) <= System.currentTimeMillis(); return (lastAttacked + attackInterval) <= System.currentTimeMillis();
} }
public double getIronArmDamage() { public double getIronArmDamage() {
@ -164,8 +172,9 @@ public class UnarmedManager extends SkillManager {
* @return true if the defender was not disarmed, false otherwise * @return true if the defender was not disarmed, false otherwise
*/ */
private boolean hasIronGrip(Player defender) { private boolean hasIronGrip(Player defender) {
if (!Misc.isNPCEntityExcludingVillagers(defender) && Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP) if (!Misc.isNPCEntityExcludingVillagers(defender)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, getPlayer())) { && pluginRef.getPermissionTools().isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, defender)) {
pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender"); pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender");
pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker"); pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker");
@ -174,4 +183,20 @@ public class UnarmedManager extends SkillManager {
return false; return false;
} }
public long getLastAttacked() {
return lastAttacked;
}
public void setLastAttacked(long lastAttacked) {
this.lastAttacked = lastAttacked;
}
public long getAttackInterval() {
return attackInterval;
}
public void setAttackInterval(long attackInterval) {
this.attackInterval = attackInterval;
}
} }

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.behaviours.WoodcuttingBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -36,7 +35,7 @@ public class WoodcuttingManager extends SkillManager {
} }
public boolean canUseLeafBlower(ItemStack heldItem) { public boolean canUseLeafBlower(ItemStack heldItem) {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER) return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER)
&& pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER) && pluginRef.getRankTools().hasUnlockedSubskill(getPlayer(), SubSkillType.WOODCUTTING_LEAF_BLOWER)
&& pluginRef.getItemTools().isAxe(heldItem); && pluginRef.getItemTools().isAxe(heldItem);
} }
@ -46,8 +45,8 @@ public class WoodcuttingManager extends SkillManager {
&& pluginRef.getItemTools().isAxe(heldItem); && pluginRef.getItemTools().isAxe(heldItem);
} }
public boolean canGetDoubleDrops() { private boolean canGetDoubleDrops() {
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER) return pluginRef.getPermissionTools().isSubSkillEnabled(getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& pluginRef.getRankTools().hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER) && pluginRef.getRankTools().hasReachedRank(1, getPlayer(), SubSkillType.WOODCUTTING_HARVEST_LUMBER)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer()); && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.WOODCUTTING_HARVEST_LUMBER, getPlayer());
} }
@ -108,7 +107,7 @@ public class WoodcuttingManager extends SkillManager {
return; return;
} }
dropBlocks(treeFellerBlocks); dropTreeFellerLootFromBlocks(treeFellerBlocks);
treeFellerReachedThreshold = false; // Reset the value after we're done with Tree Feller each time. treeFellerReachedThreshold = false; // Reset the value after we're done with Tree Feller each time.
} }
@ -247,7 +246,7 @@ public class WoodcuttingManager extends SkillManager {
* *
* @param treeFellerBlocks List of blocks to be dropped * @param treeFellerBlocks List of blocks to be dropped
*/ */
private void dropBlocks(Set<BlockState> treeFellerBlocks) { private void dropTreeFellerLootFromBlocks(Set<BlockState> treeFellerBlocks) {
Player player = getPlayer(); Player player = getPlayer();
int xp = 0; int xp = 0;
int processedLogCount = 0; int processedLogCount = 0;

View File

@ -52,7 +52,7 @@ public final class BlockTools {
* @return true if the player succeeded in the check * @return true if the player succeeded in the check
*/ */
public boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) { public boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) {
if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) { if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && pluginRef.getPermissionTools().isSubSkillEnabled(player, subSkillType)) {
return pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkill(pluginRef, player, subSkillType, true)); return pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkill(pluginRef, player, subSkillType, true));
} }

View File

@ -36,7 +36,7 @@ public final class ChimaeraWing {
return; return;
} }
if (!Permissions.chimaeraWing(player)) { if (!pluginRef.getPermissionTools().chimaeraWing(player)) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission");
return; return;
} }

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.ItemType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe; import org.bukkit.inventory.Recipe;
@ -114,6 +115,10 @@ public final class ItemTools {
} }
} }
public static boolean hasItemInEitherHand(Player player, Material material) {
return player.getInventory().getItemInMainHand().getType() == material || player.getInventory().getItemInOffHand().getType() == material;
}
/** /**
* Checks if the item is a sword. * Checks if the item is a sword.
* *

View File

@ -36,17 +36,42 @@ public final class Misc {
private Misc() { private Misc() {
} }
/**
* Determines if an entity is an NPC but not a villager
* This method aims to establish compatibility between mcMMO and other plugins which create "NPCs"
*
* It does this by checking the following
* 1) The entity is not a Villager
* 2) The entity can be considered an NPC
*
* In this context, an NPC is a bit hard to define. Various plugins determine what an NPC is in different ways.
* @see Misc::isNPCIncludingVillagers
* @param entity target entity
* @return true if the entity is not a Villager and is not a "NPC"
*/
public static boolean isNPCEntityExcludingVillagers(Entity entity) { public static boolean isNPCEntityExcludingVillagers(Entity entity) {
return (entity == null return (!isVillager(entity)
|| (entity.hasMetadata("NPC") && !(entity instanceof Villager)) && isNPCIncludingVillagers(entity)); //Compatibility with some mod..
|| (entity instanceof NPC && !(entity instanceof Villager))
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
} }
public static boolean isNPCIncludingVillagers(Player entity) { public static boolean isNPCClassType(Entity entity) {
return entity instanceof NPC;
}
public static boolean hasNPCMetadataTag(Entity entity) {
return entity.hasMetadata("NPC");
}
public static boolean isVillager(Entity entity) {
String entityType = entity.getType().toString();
//This weird code is for 1.13 & 1.14 compatibility
return entityType.equalsIgnoreCase("wandering_trader") || entity instanceof Villager;
}
public static boolean isNPCIncludingVillagers(Entity entity) {
return (entity == null return (entity == null
|| (entity.hasMetadata("NPC")) || (hasNPCMetadataTag(entity))
|| (entity instanceof NPC) || (isNPCClassType(entity))
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake")); || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
} }

View File

@ -31,7 +31,7 @@ public final class Motd {
* @param version Plugin version * @param version Plugin version
*/ */
public static void displayVersion(Player player, String version) { public static void displayVersion(Player player, String version) {
if (Permissions.showversion(player)) { if (pluginRef.getPermissionTools().showversion(player)) {
player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version)); player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version));
} }
} }
@ -124,7 +124,7 @@ public final class Motd {
*/ */
public static void displayLuckyPerks(Player player) { public static void displayLuckyPerks(Player player) {
for (PrimarySkillType skill : PrimarySkillType.values()) { for (PrimarySkillType skill : PrimarySkillType.values()) {
if (Permissions.lucky(player, skill)) { if (pluginRef.getPermissionTools().lucky(player, skill)) {
player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login"))); player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login")));
return; return;
} }

View File

@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.ItemType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
@ -17,52 +18,55 @@ import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.SimplePluginManager; import org.bukkit.plugin.SimplePluginManager;
public final class Permissions { public final class PermissionTools {
private Permissions() { private final mcMMO pluginRef;
public PermissionTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
/* /*
* GENERAL * GENERAL
*/ */
public static boolean motd(Permissible permissible) { public boolean motd(Permissible permissible) {
return permissible.hasPermission("mcmmo.motd"); return permissible.hasPermission("mcmmo.motd");
} }
public static boolean mobHealthDisplay(Permissible permissible) { public boolean mobHealthDisplay(Permissible permissible) {
return permissible.hasPermission("mcmmo.mobhealthdisplay"); return permissible.hasPermission("mcmmo.mobhealthdisplay");
} }
public static boolean updateNotifications(Permissible permissible) { public boolean updateNotifications(Permissible permissible) {
return permissible.hasPermission("mcmmo.tools.updatecheck"); return permissible.hasPermission("mcmmo.tools.updatecheck");
} }
public static boolean chimaeraWing(Permissible permissible) { public boolean chimaeraWing(Permissible permissible) {
return permissible.hasPermission("mcmmo.item.chimaerawing"); return permissible.hasPermission("mcmmo.item.chimaerawing");
} }
public static boolean showversion(Permissible permissible) { public boolean showversion(Permissible permissible) {
return permissible.hasPermission("mcmmo.showversion"); return permissible.hasPermission("mcmmo.showversion");
} }
/* BYPASS */ /* BYPASS */
public static boolean hardcoreBypass(Permissible permissible) { public boolean hardcoreBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.hardcoremode"); return permissible.hasPermission("mcmmo.bypass.hardcoremode");
} }
public static boolean arcaneBypass(Permissible permissible) { public boolean arcaneBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.arcanebypass"); return permissible.hasPermission("mcmmo.bypass.arcanebypass");
} }
public static boolean trapsBypass(Permissible permissible) { public boolean trapsBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.fishingtraps"); return permissible.hasPermission("mcmmo.bypass.fishingtraps");
} }
/* CHAT */ /* CHAT */
public static boolean partyChat(Permissible permissible) { public boolean partyChat(Permissible permissible) {
return permissible.hasPermission("mcmmo.chat.partychat"); return permissible.hasPermission("mcmmo.chat.partychat");
} }
public static boolean adminChat(Permissible permissible) { public boolean adminChat(Permissible permissible) {
return permissible.hasPermission("mcmmo.chat.adminchat"); return permissible.hasPermission("mcmmo.chat.adminchat");
} }
@ -70,171 +74,171 @@ public final class Permissions {
* COMMANDS * COMMANDS
*/ */
public static boolean mmoinfo(Permissible permissible) { public boolean mmoinfo(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoinfo"); return permissible.hasPermission("mcmmo.commands.mmoinfo");
} }
public static boolean addlevels(Permissible permissible) { public boolean addlevels(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addlevels"); return permissible.hasPermission("mcmmo.commands.addlevels");
} }
public static boolean addlevelsOthers(Permissible permissible) { public boolean addlevelsOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addlevels.others"); return permissible.hasPermission("mcmmo.commands.addlevels.others");
} }
public static boolean addxp(Permissible permissible) { public boolean addxp(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addxp"); return permissible.hasPermission("mcmmo.commands.addxp");
} }
public static boolean addxpOthers(Permissible permissible) { public boolean addxpOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addxp.others"); return permissible.hasPermission("mcmmo.commands.addxp.others");
} }
public static boolean hardcoreModify(Permissible permissible) { public boolean hardcoreModify(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.hardcore.modify"); return permissible.hasPermission("mcmmo.commands.hardcore.modify");
} }
public static boolean hardcoreToggle(Permissible permissible) { public boolean hardcoreToggle(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.hardcore.toggle"); return permissible.hasPermission("mcmmo.commands.hardcore.toggle");
} }
public static boolean inspect(Permissible permissible) { public boolean inspect(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect")); return (permissible.hasPermission("mcmmo.commands.inspect"));
} }
public static boolean inspectFar(Permissible permissible) { public boolean inspectFar(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect.far")); return (permissible.hasPermission("mcmmo.commands.inspect.far"));
} }
public static boolean inspectHidden(Permissible permissible) { public boolean inspectHidden(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect.hidden")); return (permissible.hasPermission("mcmmo.commands.inspect.hidden"));
} }
public static boolean inspectOffline(Permissible permissible) { public boolean inspectOffline(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect.offline")); return (permissible.hasPermission("mcmmo.commands.inspect.offline"));
} }
public static boolean mcability(Permissible permissible) { public boolean mcability(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcability")); return (permissible.hasPermission("mcmmo.commands.mcability"));
} }
public static boolean mcabilityOthers(Permissible permissible) { public boolean mcabilityOthers(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcability.others")); return (permissible.hasPermission("mcmmo.commands.mcability.others"));
} }
public static boolean adminChatSpy(Permissible permissible) { public boolean adminChatSpy(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcchatspy"); return permissible.hasPermission("mcmmo.commands.mcchatspy");
} }
public static boolean adminChatSpyOthers(Permissible permissible) { public boolean adminChatSpyOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcchatspy.others"); return permissible.hasPermission("mcmmo.commands.mcchatspy.others");
} }
public static boolean mcgod(Permissible permissible) { public boolean mcgod(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcgod"); return permissible.hasPermission("mcmmo.commands.mcgod");
} }
public static boolean mcgodOthers(Permissible permissible) { public boolean mcgodOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcgod.others"); return permissible.hasPermission("mcmmo.commands.mcgod.others");
} }
public static boolean mcmmoDescription(Permissible permissible) { public boolean mcmmoDescription(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcmmo.description"); return permissible.hasPermission("mcmmo.commands.mcmmo.description");
} }
public static boolean mcmmoHelp(Permissible permissible) { public boolean mcmmoHelp(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcmmo.help"); return permissible.hasPermission("mcmmo.commands.mcmmo.help");
} }
public static boolean mcrank(Permissible permissible) { public boolean mcrank(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank")); return (permissible.hasPermission("mcmmo.commands.mcrank"));
} }
public static boolean mcrankOthers(Permissible permissible) { public boolean mcrankOthers(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank.others")); return (permissible.hasPermission("mcmmo.commands.mcrank.others"));
} }
public static boolean mcrankFar(Permissible permissible) { public boolean mcrankFar(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank.others.far")); return (permissible.hasPermission("mcmmo.commands.mcrank.others.far"));
} }
public static boolean mcrankOffline(Permissible permissible) { public boolean mcrankOffline(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank.others.offline")); return (permissible.hasPermission("mcmmo.commands.mcrank.others.offline"));
} }
public static boolean mcrefresh(Permissible permissible) { public boolean mcrefresh(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrefresh")); return (permissible.hasPermission("mcmmo.commands.mcrefresh"));
} }
public static boolean mcrefreshOthers(Permissible permissible) { public boolean mcrefreshOthers(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrefresh.others")); return (permissible.hasPermission("mcmmo.commands.mcrefresh.others"));
} }
public static boolean mctop(Permissible permissible, PrimarySkillType skill) { public boolean mctop(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.mctop." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.commands.mctop." + skill.toString().toLowerCase());
} }
public static boolean mmoedit(Permissible permissible) { public boolean mmoedit(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoedit"); return permissible.hasPermission("mcmmo.commands.mmoedit");
} }
public static boolean reload(Permissible permissible) { public boolean reload(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.reload"); return permissible.hasPermission("mcmmo.commands.reload");
} }
public static boolean mmoeditOthers(Permissible permissible) { public boolean mmoeditOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoedit.others"); return permissible.hasPermission("mcmmo.commands.mmoedit.others");
} }
public static boolean skillreset(Permissible permissible) { public boolean skillreset(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.skillreset"); return permissible.hasPermission("mcmmo.commands.skillreset");
} }
public static boolean skillreset(Permissible permissible, PrimarySkillType skill) { public boolean skillreset(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase());
} }
public static boolean skillresetOthers(Permissible permissible) { public boolean skillresetOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.skillreset.others"); return permissible.hasPermission("mcmmo.commands.skillreset.others");
} }
public static boolean skillresetOthers(Permissible permissible, PrimarySkillType skill) { public boolean skillresetOthers(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase());
} }
public static boolean xplock(Permissible permissible, PrimarySkillType skill) { public boolean xplock(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.xplock." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.commands.xplock." + skill.toString().toLowerCase());
} }
public static boolean xprateSet(Permissible permissible) { public boolean xprateSet(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.xprate.set"); return permissible.hasPermission("mcmmo.commands.xprate.set");
} }
public static boolean xprateReset(Permissible permissible) { public boolean xprateReset(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.xprate.reset"); return permissible.hasPermission("mcmmo.commands.xprate.reset");
} }
public static boolean vampirismModify(Permissible permissible) { public boolean vampirismModify(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.vampirism.modify"); return permissible.hasPermission("mcmmo.commands.vampirism.modify");
} }
public static boolean vampirismToggle(Permissible permissible) { public boolean vampirismToggle(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.vampirism.toggle"); return permissible.hasPermission("mcmmo.commands.vampirism.toggle");
} }
public static boolean mcpurge(Permissible permissible) { public boolean mcpurge(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcpurge"); return permissible.hasPermission("mcmmo.commands.mcpurge");
} }
public static boolean mcremove(Permissible permissible) { public boolean mcremove(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcremove"); return permissible.hasPermission("mcmmo.commands.mcremove");
} }
public static boolean mmoupdate(Permissible permissible) { public boolean mmoupdate(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoupdate"); return permissible.hasPermission("mcmmo.commands.mmoupdate");
} }
public static boolean reloadlocale(Permissible permissible) { public boolean reloadlocale(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.reloadlocale"); return permissible.hasPermission("mcmmo.commands.reloadlocale");
} }
@ -244,70 +248,70 @@ public final class Permissions {
/* BYPASS PERKS */ /* BYPASS PERKS */
public static boolean hasRepairEnchantBypassPerk(Permissible permissible) { public boolean hasRepairEnchantBypassPerk(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.bypass.repairenchant"); return permissible.hasPermission("mcmmo.perks.bypass.repairenchant");
} }
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { public boolean hasSalvageEnchantBypassPerk(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant");
} }
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { public boolean lucky(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase());
} }
/* XP PERKS */ /* XP PERKS */
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) { public boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase());
} }
public static boolean tripleXp(Permissible permissible, PrimarySkillType skill) { public boolean tripleXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.triple." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.xp.triple." + skill.toString().toLowerCase());
} }
public static boolean doubleAndOneHalfXp(Permissible permissible, PrimarySkillType skill) { public boolean doubleAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.150percentboost." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.xp.150percentboost." + skill.toString().toLowerCase());
} }
public static boolean doubleXp(Permissible permissible, PrimarySkillType skill) { public boolean doubleXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.double." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.xp.double." + skill.toString().toLowerCase());
} }
public static boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) { public boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.50percentboost." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.xp.50percentboost." + skill.toString().toLowerCase());
} }
public static boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) { public boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.10percentboost." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.perks.xp.10percentboost." + skill.toString().toLowerCase());
} }
public static boolean hasCustomXPPerk(Permissible permissible, CustomXPPerk customXPPerk) { public boolean hasCustomXPPerk(Permissible permissible, CustomXPPerk customXPPerk) {
return permissible.hasPermission(customXPPerk.getPerkPermissionAddress()); return permissible.hasPermission(customXPPerk.getPerkPermissionAddress());
} }
/* ACTIVATION PERKS */ /* ACTIVATION PERKS */
public static boolean twelveSecondActivationBoost(Permissible permissible) { public boolean twelveSecondActivationBoost(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.activationtime.twelveseconds"); return permissible.hasPermission("mcmmo.perks.activationtime.twelveseconds");
} }
public static boolean eightSecondActivationBoost(Permissible permissible) { public boolean eightSecondActivationBoost(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.activationtime.eightseconds"); return permissible.hasPermission("mcmmo.perks.activationtime.eightseconds");
} }
public static boolean fourSecondActivationBoost(Permissible permissible) { public boolean fourSecondActivationBoost(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.activationtime.fourseconds"); return permissible.hasPermission("mcmmo.perks.activationtime.fourseconds");
} }
/* COOLDOWN PERKS */ /* COOLDOWN PERKS */
public static boolean halvedCooldowns(Permissible permissible) { public boolean halvedCooldowns(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.cooldowns.halved"); return permissible.hasPermission("mcmmo.perks.cooldowns.halved");
} }
public static boolean thirdedCooldowns(Permissible permissible) { public boolean thirdedCooldowns(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.cooldowns.thirded"); return permissible.hasPermission("mcmmo.perks.cooldowns.thirded");
} }
public static boolean quarteredCooldowns(Permissible permissible) { public boolean quarteredCooldowns(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.cooldowns.quartered"); return permissible.hasPermission("mcmmo.perks.cooldowns.quartered");
} }
@ -315,201 +319,197 @@ public final class Permissions {
* SKILLS * SKILLS
*/ */
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) { public boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase()); return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase());
} }
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) { public boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".vanillaxpboost"); return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".vanillaxpboost");
} }
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) { public boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) {
return permissible.hasPermission(subSkillType.getPermissionNodeAddress()); return permissible.hasPermission(subSkillType.getPermissionNodeAddress(pluginRef));
} }
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) { public boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) {
return permissible.hasPermission(abstractSubSkill.getPermissionNode()); return permissible.hasPermission(abstractSubSkill.getPermissionNode());
} }
public static boolean bonusDamage(Permissible permissible, PrimarySkillType skill) { public boolean bonusDamage(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".bonusdamage"); return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".bonusdamage");
} }
/* ACROBATICS */ /* ACROBATICS */
public static boolean dodge(Permissible permissible) { public boolean dodge(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.acrobatics.dodge"); return permissible.hasPermission("mcmmo.ability.acrobatics.dodge");
} }
public static boolean gracefulRoll(Permissible permissible) { public boolean gracefulRoll(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.acrobatics.gracefulroll"); return permissible.hasPermission("mcmmo.ability.acrobatics.gracefulroll");
} }
public static boolean roll(Permissible permissible) { public boolean roll(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.acrobatics.roll"); return permissible.hasPermission("mcmmo.ability.acrobatics.roll");
} }
/* ALCHEMY */ /* ALCHEMY */
public static boolean catalysis(Permissible permissible) { public boolean catalysis(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.alchemy.catalysis"); return permissible.hasPermission("mcmmo.ability.alchemy.catalysis");
} }
public static boolean concoctions(Permissible permissible) { public boolean concoctions(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.alchemy.concoctions"); return permissible.hasPermission("mcmmo.ability.alchemy.concoctions");
} }
/* ARCHERY */ /* ARCHERY */
public static boolean arrowRetrieval(Permissible permissible) { public boolean arrowRetrieval(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.archery.trackarrows"); return permissible.hasPermission("mcmmo.ability.archery.trackarrows");
} }
public static boolean daze(Permissible permissible) { public boolean daze(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.archery.daze"); return permissible.hasPermission("mcmmo.ability.archery.daze");
} }
/* AXES */ /* AXES */
public static boolean skullSplitter(Permissible permissible) { public boolean skullSplitter(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.axes.skullsplitter"); return permissible.hasPermission("mcmmo.ability.axes.skullsplitter");
} }
/* EXCAVATION */ /* EXCAVATION */
public static boolean gigaDrillBreaker(Permissible permissible) { public boolean gigaDrillBreaker(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.excavation.gigadrillbreaker"); return permissible.hasPermission("mcmmo.ability.excavation.gigadrillbreaker");
} }
/* HERBALISM */ /* HERBALISM */
public static boolean greenTerra(Permissible permissible) { public boolean greenTerra(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.herbalism.greenterra"); return permissible.hasPermission("mcmmo.ability.herbalism.greenterra");
} }
public static boolean greenThumbBlock(Permissible permissible, Material material) { public boolean greenThumbBlock(Permissible permissible, Material material) {
return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase()); return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase());
} }
public static boolean greenThumbPlant(Permissible permissible, Material material) { public boolean greenThumbPlant(Permissible permissible, Material material) {
return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase()); return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase());
} }
/* MINING */ /* MINING */
public static boolean biggerBombs(Permissible permissible) { public boolean biggerBombs(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs"); return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs");
} }
public static boolean demolitionsExpertise(Permissible permissible) { public boolean demolitionsExpertise(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.demolitionsexpertise"); return permissible.hasPermission("mcmmo.ability.mining.blastmining.demolitionsexpertise");
} }
public static boolean remoteDetonation(Permissible permissible) { public boolean remoteDetonation(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.detonate"); return permissible.hasPermission("mcmmo.ability.mining.blastmining.detonate");
} }
public static boolean superBreaker(Permissible permissible) { public boolean superBreaker(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.superbreaker"); return permissible.hasPermission("mcmmo.ability.mining.superbreaker");
} }
/* REPAIR */ /* REPAIR */
public static boolean repairItemType(Permissible permissible, ItemType repairItemType) { public boolean repairItemType(Permissible permissible, ItemType repairItemType) {
return permissible.hasPermission("mcmmo.ability.repair." + repairItemType.toString().toLowerCase() + "repair"); return permissible.hasPermission("mcmmo.ability.repair." + repairItemType.toString().toLowerCase() + "repair");
} }
public static boolean repairMaterialType(Permissible permissible, ItemMaterialCategory repairItemMaterialCategory) { public boolean repairMaterialType(Permissible permissible, ItemMaterialCategory repairItemMaterialCategory) {
return permissible.hasPermission("mcmmo.ability.repair." + repairItemMaterialCategory.toString().toLowerCase() + "repair"); return permissible.hasPermission("mcmmo.ability.repair." + repairItemMaterialCategory.toString().toLowerCase() + "repair");
} }
/* SALVAGE */ /* SALVAGE */
public static boolean advancedSalvage(Permissible permissible) { public boolean advancedSalvage(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.salvage.advancedsalvage"); return permissible.hasPermission("mcmmo.ability.salvage.advancedsalvage");
} }
public static boolean arcaneSalvage(Permissible permissible) { public boolean arcaneSalvage(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.salvage.arcanesalvage"); return permissible.hasPermission("mcmmo.ability.salvage.arcanesalvage");
} }
public static boolean salvageItemType(Permissible permissible, ItemType salvageItemType) { public boolean salvageItemType(Permissible permissible, ItemType salvageItemType) {
return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemType.toString().toLowerCase() + "salvage"); return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemType.toString().toLowerCase() + "salvage");
} }
public static boolean salvageMaterialType(Permissible permissible, ItemMaterialCategory salvageItemMaterialCategory) { public boolean salvageMaterialType(Permissible permissible, ItemMaterialCategory salvageItemMaterialCategory) {
return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemMaterialCategory.toString().toLowerCase() + "salvage"); return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemMaterialCategory.toString().toLowerCase() + "salvage");
} }
/* SMELTING */ /* SMELTING */
public static boolean fluxMining(Permissible permissible) { public boolean fluxMining(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.smelting.fluxmining"); return permissible.hasPermission("mcmmo.ability.smelting.fluxmining");
} }
public static boolean fuelEfficiency(Permissible permissible) { public boolean fuelEfficiency(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.smelting.fuelefficiency"); return permissible.hasPermission("mcmmo.ability.smelting.fuelefficiency");
} }
/* SWORDS */ /* SWORDS */
public static boolean serratedStrikes(Permissible permissible) { public boolean serratedStrikes(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.swords.serratedstrikes"); return permissible.hasPermission("mcmmo.ability.swords.serratedstrikes");
} }
/* TAMING */ /* TAMING */
public static boolean callOfTheWild(Permissible permissible, EntityType type) { public boolean callOfTheWild(Permissible permissible, EntityType type) {
return permissible.hasPermission("mcmmo.ability.taming.callofthewild." + type.toString().toLowerCase()); return permissible.hasPermission("mcmmo.ability.taming.callofthewild." + type.toString().toLowerCase());
} }
public static boolean renamePets(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.taming.callofthewild.renamepets");
}
/* UNARMED */ /* UNARMED */
public static boolean berserk(Permissible permissible) { public boolean berserk(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.unarmed.berserk"); return permissible.hasPermission("mcmmo.ability.unarmed.berserk");
} }
/* WOODCUTTING */ /* WOODCUTTING */
public static boolean treeFeller(Permissible permissible) { public boolean treeFeller(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.woodcutting.treefeller"); return permissible.hasPermission("mcmmo.ability.woodcutting.treefeller");
} }
/* /*
* PARTY * PARTY
*/ */
public static boolean partySizeBypass(Permissible permissible) { public boolean partySizeBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.partylimit"); return permissible.hasPermission("mcmmo.bypass.partylimit");
} }
public static boolean party(Permissible permissible) { public boolean party(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.party"); return permissible.hasPermission("mcmmo.commands.party");
} }
public static boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) { public boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) {
return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase()); return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase());
} }
public static boolean friendlyFire(Permissible permissible) { public boolean friendlyFire(Permissible permissible) {
return permissible.hasPermission("mcmmo.party.friendlyfire"); return permissible.hasPermission("mcmmo.party.friendlyfire");
} }
/* TELEPORT */ /* TELEPORT */
public static boolean partyTeleportSend(Permissible permissible) { public boolean partyTeleportSend(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.send"); return permissible.hasPermission("mcmmo.commands.ptp.send");
} }
public static boolean partyTeleportAccept(Permissible permissible) { public boolean partyTeleportAccept(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.accept"); return permissible.hasPermission("mcmmo.commands.ptp.accept");
} }
public static boolean partyTeleportAcceptAll(Permissible permissible) { public boolean partyTeleportAcceptAll(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.acceptall"); return permissible.hasPermission("mcmmo.commands.ptp.acceptall");
} }
public static boolean partyTeleportToggle(Permissible permissible) { public boolean partyTeleportToggle(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.toggle"); return permissible.hasPermission("mcmmo.commands.ptp.toggle");
} }
public static boolean partyTeleportAllWorlds(Permissible permissible) { public boolean partyTeleportAllWorlds(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.world.all"); return permissible.hasPermission("mcmmo.commands.ptp.world.all");
} }
public static boolean partyTeleportWorld(Permissible permissible, World world) { public boolean partyTeleportWorld(Permissible permissible, World world) {
return permissible.hasPermission("mcmmo.commands.ptp.world." + world.getName()); return permissible.hasPermission("mcmmo.commands.ptp.world." + world.getName());
} }
public static void generateWorldTeleportPermissions() { public void generateWorldTeleportPermissions() {
Server server = pluginRef.getServer(); Server server = pluginRef.getServer();
PluginManager pluginManager = server.getPluginManager(); PluginManager pluginManager = server.getPluginManager();
@ -522,7 +522,7 @@ public final class Permissions {
* XP Perks are defined by user config files and are not known until runtime * XP Perks are defined by user config files and are not known until runtime
* This method registers Permissions with the server software as needed * This method registers Permissions with the server software as needed
*/ */
public static void addCustomXPPerks() { public void addCustomXPPerks() {
pluginRef.getLogger().info("Registering custom XP perks with server software..."); pluginRef.getLogger().info("Registering custom XP perks with server software...");
PluginManager pluginManager = pluginRef.getServer().getPluginManager(); PluginManager pluginManager = pluginRef.getServer().getPluginManager();
@ -539,7 +539,7 @@ public final class Permissions {
} }
} }
private static void addDynamicPermission(String permissionName, PluginManager pluginManager) { private void addDynamicPermission(String permissionName, PluginManager pluginManager) {
Permission permission = new Permission(permissionName); Permission permission = new Permission(permissionName);
permission.setDefault(PermissionDefault.OP); permission.setDefault(PermissionDefault.OP);
pluginManager.addPermission(permission); pluginManager.addPermission(permission);

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