mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e41adf769b | ||
|
|
e80f60ccee | ||
|
|
12b548bf46 | ||
|
|
1b461ac96a | ||
|
|
1fc3c8fab2 | ||
|
|
7c28be5e62 | ||
|
|
cbe9cae4ea | ||
|
|
c0b7f8a323 | ||
|
|
f8b4412049 | ||
|
|
10e227a5ac | ||
|
|
077431630a | ||
|
|
37395a70e6 | ||
|
|
b779258d69 | ||
|
|
d3ec976f44 | ||
|
|
79a5732c4d | ||
|
|
12c6bfc2e8 | ||
|
|
31fff0623d | ||
|
|
0d2b87834c | ||
|
|
2feba8f64c | ||
|
|
cf82ae4c66 | ||
|
|
0d7c402c01 | ||
|
|
ae8b70be0f | ||
|
|
a87336b7ee | ||
|
|
7814fa8d46 |
@@ -7,6 +7,18 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.01-dev
|
||||
= Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs
|
||||
= Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile
|
||||
= Fixed bug where Smelting would throw consistent errors due to offline players
|
||||
= Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag
|
||||
= Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly
|
||||
= Fixed bug where the wrong flag was being set when taking damage
|
||||
= Fixed bug where the PTP cooldown was set improperly
|
||||
= Fixed bug where ptp permissions weren't being handled properly
|
||||
= Fixed bug where Beast Lore wouldn't work
|
||||
= Fixed bug where Chimaera Wing would always teleport to spawn, even when the player had a valid bed spawn location
|
||||
|
||||
Version 1.4.00
|
||||
+ Added new Child Skill - Smelting!
|
||||
+ Added a version check, admins will get notified when a new version is available!
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.00</version>
|
||||
<version>1.4.01-dev1</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
|
||||
@@ -2,46 +2,47 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class AbilityAPI {
|
||||
private AbilityAPI() {}
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.UNARMED).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.EXCAVATION).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean greenTerraEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.HERBALISM).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean serratedStrikesEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.SWORDS).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.AXES).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.MINING).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean treeFellerEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER);
|
||||
return UserManager.getPlayer(player).getSkillManager(SkillType.WOODCUTTING).getAbility().getMode();
|
||||
}
|
||||
|
||||
public static boolean isAnyAbilityEnabled(Player player) {
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (profile.getAbilityMode(ability)) {
|
||||
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
|
||||
if (skillManager.getAbility().getMode()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
McMMOPlayer mcMMOPlayer;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
@@ -23,16 +23,16 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
if (mcMMOPlayer.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
mcMMOPlayer.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
@@ -41,12 +41,12 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
if (!playerProfile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -56,21 +56,20 @@ public class McabilityCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
if (mcMMOPlayer.getAbilityUse()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
mcMMOPlayer.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
McMMOPlayer mcMMOPlayer;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
@@ -27,21 +27,21 @@ public class McgodCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
@@ -50,12 +50,12 @@ public class McgodCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
if (!playerProfile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -64,7 +64,6 @@ public class McgodCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
@@ -72,14 +71,14 @@ public class McgodCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -14,16 +14,16 @@ public class McnotifyCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
PlayerProfile profile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
if (profile.useChatNotifications()) {
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
|
||||
}
|
||||
|
||||
profile.toggleChatNotifications();
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
McMMOPlayer mcMMOPlayer;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
@@ -27,12 +27,12 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = UserManager.getPlayer(sender.getName()).getProfile();
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.getProfile().resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
return true;
|
||||
@@ -43,12 +43,12 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
if (!playerProfile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
@@ -64,10 +64,10 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.getProfile().resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
||||
|
||||
@@ -146,7 +146,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
String[] newArgs = new String[args.length - 1];
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
newArgs[i - 1] = args[1];
|
||||
newArgs[i - 1] = args[i];
|
||||
}
|
||||
|
||||
return newArgs;
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -21,7 +20,6 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private Player player;
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
private Player target;
|
||||
private McMMOPlayer mcMMOTarget;
|
||||
@@ -34,10 +32,6 @@ public class PtpCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
playerProfile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
if (!Permissions.partyTeleportToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
@@ -56,9 +50,11 @@ public class PtpCommand implements CommandExecutor {
|
||||
return acceptAnyTeleportRequest();
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR;
|
||||
|
||||
if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||
if (System.currentTimeMillis() - recentlyHurt >= (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
||||
return true;
|
||||
}
|
||||
@@ -93,6 +89,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
|
||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire));
|
||||
return true;
|
||||
@@ -202,8 +199,8 @@ public class PtpCommand implements CommandExecutor {
|
||||
|
||||
private boolean handlePartyTeleportEvent(Player player, Player target) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -213,7 +210,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
player.teleport(target);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName()));
|
||||
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
|
||||
mcMMOPlayer.actualizeRecentlyHurt();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,14 @@ public class MctopCommand implements CommandExecutor {
|
||||
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||
}
|
||||
else if (SkillUtils.isSkill(args[0])) {
|
||||
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
SkillType skill = SkillType.getSkill(args[0]);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill.toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
@@ -45,7 +52,14 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (SkillUtils.isSkill(args[0])) {
|
||||
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
SkillType skill = SkillType.getSkill(args[0]);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this
|
||||
return true;
|
||||
}
|
||||
|
||||
display(Integer.parseInt(args[1]), skill.toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
@@ -27,7 +27,7 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier();
|
||||
lootTier = UserManager.getPlayer(player).getFishingManager().getLootTier();
|
||||
|
||||
// TREASURE HUNTER
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
@@ -42,7 +42,7 @@ public class FishingCommand extends SkillCommand {
|
||||
magicChanceLucky = treasureHunterStrings[1];
|
||||
|
||||
// SHAKE
|
||||
String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability());
|
||||
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability());
|
||||
shakeChance = shakeStrings[0];
|
||||
shakeChanceLucky = shakeStrings[1];
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class MiningCommand extends SkillCommand {
|
||||
private String doubleDropChance;
|
||||
@@ -45,7 +45,7 @@ public class MiningCommand extends SkillCommand {
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
|
||||
// BLAST MINING
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
blastMiningRank = miningManager.getBlastMiningTier();
|
||||
bonusTNTDrops = miningManager.getDropMultiplier();
|
||||
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
|
||||
|
||||
@@ -125,7 +125,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
protected String[] calculateLengthDisplayValues() {
|
||||
int maxLength = skill.getAbility().getMaxTicks();
|
||||
int maxLength = skill.getAbilityType().getMaxTicks();
|
||||
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SmeltingCommand extends SkillCommand {
|
||||
private String burnTimeModifier;
|
||||
@@ -41,7 +41,7 @@ public class SmeltingCommand extends SkillCommand {
|
||||
fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||
|
||||
// VANILLA XP BOOST
|
||||
vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier();
|
||||
vanillaXPModifier = UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,11 @@ public class XplockCommand extends SpoutCommand {
|
||||
|
||||
SkillType skill = SkillType.getSkill(args[0]);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.xplock(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class LeaderboardManager {
|
||||
}
|
||||
|
||||
lastUpdate = System.currentTimeMillis(); // Log when the last update was run
|
||||
powerLevels.clear(); // Clear old values from the power levels
|
||||
|
||||
// Initialize lists
|
||||
List<PlayerStat> mining = new ArrayList<PlayerStat>();
|
||||
@@ -50,7 +51,6 @@ public final class LeaderboardManager {
|
||||
List<PlayerStat> unarmed = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> taming = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||
|
||||
// Read from the FlatFile database and fill our arrays with information
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
@@ -11,11 +13,25 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.Tool;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -26,8 +42,18 @@ public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
/*
|
||||
* Since SkillManager isn't a "polymorphic type" we may prefer to have one field for each of our
|
||||
* class inheriting from SkillManager. This would also prevent the need for casting.
|
||||
* However, by using the map and the loop in the constructor
|
||||
* we make sure that all class inheriting from SkillManager are instanced.
|
||||
* Which solution is better, I let you decide. - bm01
|
||||
*/
|
||||
private Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
private int itemShareModifier;
|
||||
|
||||
private Player ptpRequest;
|
||||
private boolean ptpEnabled = true;
|
||||
@@ -36,15 +62,220 @@ public class McMMOPlayer {
|
||||
|
||||
private boolean partyChatMode;
|
||||
private boolean adminChatMode;
|
||||
private boolean displaySkillNotifications = true;
|
||||
|
||||
private int itemShareModifier;
|
||||
private boolean abilityUse = true;
|
||||
private boolean placedAnvil;
|
||||
private boolean placedSalvageAnvil;
|
||||
private boolean godMode;
|
||||
|
||||
private int recentlyHurt;
|
||||
private int respawnATS;
|
||||
|
||||
public McMMOPlayer(Player player) {
|
||||
String playerName = player.getName();
|
||||
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(playerName, true);
|
||||
this.party = PartyManager.getPlayerParty(playerName);
|
||||
profile = new PlayerProfile(playerName, true);
|
||||
party = PartyManager.getPlayerParty(playerName);
|
||||
|
||||
Map<ToolType, Tool> tools = new HashMap<ToolType, Tool>();
|
||||
|
||||
// Build Tool objects for the current player, a tool can be used by multiple skills
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
ToolType toolType = skillType.getToolType();
|
||||
|
||||
if (tools.containsKey(toolType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tools.put(toolType, new Tool());
|
||||
}
|
||||
|
||||
/*
|
||||
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
||||
* but I actually have no idea about the performance impact, if there is any.
|
||||
* If in the future someone wants to remove this, don't forget to also remove what is in the SkillType enum. - bm01
|
||||
*/
|
||||
try {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
Class<? extends SkillManager> skillManagerClass = skillType.getManagerClass();
|
||||
|
||||
// TODO: The null check is needed only because currently some SkillType doesn't have a valid skillManagerClass
|
||||
if (skillManagerClass != null) {
|
||||
SkillManager skillManager = skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this);
|
||||
|
||||
skillManager.setTool(tools.get(skillType.getToolType()));
|
||||
skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
public AcrobaticsManager getAcrobaticsManager() {
|
||||
return (AcrobaticsManager) skillManagers.get(SkillType.ACROBATICS);
|
||||
}
|
||||
|
||||
public ArcheryManager getArcheryManager() {
|
||||
return (ArcheryManager) skillManagers.get(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
public AxesManager getAxesManager() {
|
||||
return (AxesManager) skillManagers.get(SkillType.AXES);
|
||||
}
|
||||
|
||||
public ExcavationManager getExcavationManager() {
|
||||
return (ExcavationManager) skillManagers.get(SkillType.EXCAVATION);
|
||||
}
|
||||
|
||||
public FishingManager getFishingManager() {
|
||||
return (FishingManager) skillManagers.get(SkillType.FISHING);
|
||||
}
|
||||
|
||||
public HerbalismManager getHerbalismManager() {
|
||||
return (HerbalismManager) skillManagers.get(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
public MiningManager getMiningManager() {
|
||||
return (MiningManager) skillManagers.get(SkillType.MINING);
|
||||
}
|
||||
|
||||
public SmeltingManager getSmeltingManager() {
|
||||
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
||||
}
|
||||
|
||||
public SwordsManager getSwordsManager() {
|
||||
return (SwordsManager) skillManagers.get(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
public TamingManager getTamingManager() {
|
||||
return (TamingManager) skillManagers.get(SkillType.TAMING);
|
||||
}
|
||||
|
||||
public UnarmedManager getUnarmedManager() {
|
||||
return (UnarmedManager) skillManagers.get(SkillType.UNARMED);
|
||||
}
|
||||
|
||||
public SkillManager getSkillManager(SkillType skillType) {
|
||||
return skillManagers.get(skillType);
|
||||
}
|
||||
|
||||
public Map<SkillType, SkillManager> getSkillManagers() {
|
||||
return skillManagers;
|
||||
}
|
||||
|
||||
/*
|
||||
* Abilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the mode of all abilities.
|
||||
*/
|
||||
public void resetAbilityMode() {
|
||||
for (SkillManager skillManager : skillManagers.values()) {
|
||||
skillManager.getAbility().setMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getAbilityUse() {
|
||||
return abilityUse;
|
||||
}
|
||||
|
||||
public void toggleAbilityUse() {
|
||||
abilityUse = !abilityUse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tools
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the prep modes of all tools.
|
||||
*/
|
||||
public void resetToolPrepMode() {
|
||||
for (SkillManager skillManager : skillManagers.values()) {
|
||||
skillManager.getTool().setPreparationMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Recently Hurt
|
||||
*/
|
||||
|
||||
public int getRecentlyHurt() {
|
||||
return recentlyHurt;
|
||||
}
|
||||
|
||||
public void setRecentlyHurt(int value) {
|
||||
recentlyHurt = value;
|
||||
}
|
||||
|
||||
public void actualizeRecentlyHurt() {
|
||||
recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Exploit Prevention
|
||||
*/
|
||||
|
||||
public int getRespawnATS() {
|
||||
return respawnATS;
|
||||
}
|
||||
|
||||
public void actualizeRespawnATS() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
|
||||
public void togglePlacedAnvil() {
|
||||
placedAnvil = !placedAnvil;
|
||||
}
|
||||
|
||||
public Boolean getPlacedAnvil() {
|
||||
return placedAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Salvage Anvil Placement
|
||||
*/
|
||||
|
||||
public void togglePlacedSalvageAnvil() {
|
||||
placedSalvageAnvil = !placedSalvageAnvil;
|
||||
}
|
||||
|
||||
public Boolean getPlacedSalvageAnvil() {
|
||||
return placedSalvageAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* God Mode
|
||||
*/
|
||||
|
||||
public boolean getGodMode() {
|
||||
return godMode;
|
||||
}
|
||||
|
||||
public void toggleGodMode() {
|
||||
godMode = !godMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skill notifications
|
||||
*/
|
||||
|
||||
public boolean useChatNotifications() {
|
||||
return displaySkillNotifications;
|
||||
}
|
||||
|
||||
public void toggleChatNotifications() {
|
||||
displaySkillNotifications = !displaySkillNotifications;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +367,9 @@ public class McMMOPlayer {
|
||||
SkillUtils.xpCheckSkill(skillType, player, profile);
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
/*
|
||||
* Players & Profiles
|
||||
*/
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
@@ -150,7 +383,9 @@ public class McMMOPlayer {
|
||||
return profile;
|
||||
}
|
||||
|
||||
// Party Stuff
|
||||
/*
|
||||
* Party Stuff
|
||||
*/
|
||||
|
||||
public void setPartyInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
@@ -252,6 +487,10 @@ public class McMMOPlayer {
|
||||
itemShareModifier = modifier;
|
||||
}
|
||||
|
||||
/*
|
||||
* Chat modes
|
||||
*/
|
||||
|
||||
public boolean getAdminChatMode() {
|
||||
return adminChatMode;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -14,7 +15,6 @@ import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
@@ -28,51 +28,14 @@ public class PlayerProfile {
|
||||
private McMMOHud spoutHud;
|
||||
private HudType hudType;
|
||||
|
||||
// Toggles
|
||||
private boolean loaded;
|
||||
private boolean godMode;
|
||||
|
||||
private boolean placedAnvil;
|
||||
private boolean placedSalvageAnvil;
|
||||
|
||||
private boolean hoePreparationMode;
|
||||
private boolean shovelPreparationMode;
|
||||
private boolean swordsPreparationMode;
|
||||
private boolean fistsPreparationMode;
|
||||
private boolean pickaxePreparationMode;
|
||||
private boolean axePreparationMode;
|
||||
|
||||
private boolean greenTerraMode;
|
||||
private boolean treeFellerMode;
|
||||
private boolean superBreakerMode;
|
||||
private boolean gigaDrillBreakerMode;
|
||||
private boolean serratedStrikesMode;
|
||||
private boolean skullSplitterMode;
|
||||
private boolean berserkMode;
|
||||
|
||||
private boolean greenTerraInformed = true;
|
||||
private boolean berserkInformed = true;
|
||||
private boolean skullSplitterInformed = true;
|
||||
private boolean gigaDrillBreakerInformed = true;
|
||||
private boolean superBreakerInformed = true;
|
||||
private boolean blastMiningInformed = true;
|
||||
private boolean serratedStrikesInformed = true;
|
||||
private boolean treeFellerInformed = true;
|
||||
|
||||
private boolean abilityUse = true;
|
||||
private boolean displaySkillNotifications = true;
|
||||
|
||||
// Timestamps
|
||||
private long recentlyHurt;
|
||||
private int respawnATS;
|
||||
|
||||
// mySQL Stuff
|
||||
private int userId;
|
||||
|
||||
private HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skills and Levels
|
||||
private HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); // Skills and Xp
|
||||
private HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||
private HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
private boolean loaded;
|
||||
|
||||
private Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skills and Levels
|
||||
private Map<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); // Skills and Xp
|
||||
private Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||
|
||||
private final static String location = mcMMO.getUsersFilePath();
|
||||
|
||||
@@ -565,42 +528,6 @@ public class PlayerProfile {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
/*
|
||||
* God Mode
|
||||
*/
|
||||
|
||||
public boolean getGodMode() {
|
||||
return godMode;
|
||||
}
|
||||
|
||||
public void toggleGodMode() {
|
||||
godMode = !godMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
|
||||
public void togglePlacedAnvil() {
|
||||
placedAnvil = !placedAnvil;
|
||||
}
|
||||
|
||||
public Boolean getPlacedAnvil() {
|
||||
return placedAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Salvage Anvil Placement
|
||||
*/
|
||||
|
||||
public void togglePlacedSalvageAnvil() {
|
||||
placedSalvageAnvil = !placedSalvageAnvil;
|
||||
}
|
||||
|
||||
public Boolean getPlacedSalvageAnvil() {
|
||||
return placedSalvageAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* HUD Stuff
|
||||
*/
|
||||
@@ -621,315 +548,6 @@ public class PlayerProfile {
|
||||
this.hudType = hudType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tools
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the prep modes of all tools.
|
||||
*/
|
||||
public void resetToolPrepMode() {
|
||||
for (ToolType tool : ToolType.values()) {
|
||||
setToolPreparationMode(tool, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to get the mode for
|
||||
* @return true if the tool is prepped, false otherwise
|
||||
*/
|
||||
public boolean getToolPreparationMode(ToolType tool) {
|
||||
switch (tool) {
|
||||
case AXE:
|
||||
return axePreparationMode;
|
||||
|
||||
case FISTS:
|
||||
return fistsPreparationMode;
|
||||
|
||||
case HOE:
|
||||
return hoePreparationMode;
|
||||
|
||||
case PICKAXE:
|
||||
return pickaxePreparationMode;
|
||||
|
||||
case SHOVEL:
|
||||
return shovelPreparationMode;
|
||||
|
||||
case SWORD:
|
||||
return swordsPreparationMode;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to set the mode for
|
||||
* @param bool true if the tool should be prepped, false otherwise
|
||||
*/
|
||||
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
||||
switch (tool) {
|
||||
case AXE:
|
||||
axePreparationMode = bool;
|
||||
break;
|
||||
|
||||
case FISTS:
|
||||
fistsPreparationMode = bool;
|
||||
break;
|
||||
|
||||
case HOE:
|
||||
hoePreparationMode = bool;
|
||||
break;
|
||||
|
||||
case PICKAXE:
|
||||
pickaxePreparationMode = bool;
|
||||
break;
|
||||
|
||||
case SHOVEL:
|
||||
shovelPreparationMode = bool;
|
||||
break;
|
||||
|
||||
case SWORD:
|
||||
swordsPreparationMode = bool;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current prep ATS of a tool.
|
||||
*
|
||||
* @param tool Tool to get the ATS for
|
||||
* @return the ATS for the tool
|
||||
*/
|
||||
public long getToolPreparationATS(ToolType tool) {
|
||||
return toolATS.get(tool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current prep ATS of a tool.
|
||||
*
|
||||
* @param tool Tool to set the ATS for
|
||||
* @param ATS the ATS of the tool
|
||||
*/
|
||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
||||
|
||||
toolATS.put(tool, startTime);
|
||||
}
|
||||
|
||||
/*
|
||||
* Abilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the prep modes of all tools.
|
||||
*/
|
||||
public void resetAbilityMode() {
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
setAbilityMode(ability, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @return true if the ability is enabled, false otherwise
|
||||
*/
|
||||
public boolean getAbilityMode(AbilityType ability) {
|
||||
switch (ability) {
|
||||
case BERSERK:
|
||||
return berserkMode;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return superBreakerMode;
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return gigaDrillBreakerMode;
|
||||
|
||||
case GREEN_TERRA:
|
||||
return greenTerraMode;
|
||||
|
||||
case SKULL_SPLITTER:
|
||||
return skullSplitterMode;
|
||||
|
||||
case TREE_FELLER:
|
||||
return treeFellerMode;
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return serratedStrikesMode;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param bool True if the ability is active, false otherwise
|
||||
*/
|
||||
public void setAbilityMode(AbilityType ability, boolean bool) {
|
||||
switch (ability) {
|
||||
case BERSERK:
|
||||
berserkMode = bool;
|
||||
break;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
superBreakerMode = bool;
|
||||
break;
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
gigaDrillBreakerMode = bool;
|
||||
break;
|
||||
|
||||
case GREEN_TERRA:
|
||||
greenTerraMode = bool;
|
||||
break;
|
||||
|
||||
case SKULL_SPLITTER:
|
||||
skullSplitterMode = bool;
|
||||
break;
|
||||
|
||||
case TREE_FELLER:
|
||||
treeFellerMode = bool;
|
||||
break;
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
serratedStrikesMode = bool;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the informed state of an ability
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @return true if the ability is informed, false otherwise
|
||||
*/
|
||||
public boolean getAbilityInformed(AbilityType ability) {
|
||||
switch (ability) {
|
||||
case BERSERK:
|
||||
return berserkInformed;
|
||||
|
||||
case BLAST_MINING:
|
||||
return blastMiningInformed;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return superBreakerInformed;
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return gigaDrillBreakerInformed;
|
||||
|
||||
case GREEN_TERRA:
|
||||
return greenTerraInformed;
|
||||
|
||||
case SKULL_SPLITTER:
|
||||
return skullSplitterInformed;
|
||||
|
||||
case TREE_FELLER:
|
||||
return treeFellerInformed;
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return serratedStrikesInformed;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the informed state of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param bool True if the ability is informed, false otherwise
|
||||
*/
|
||||
public void setAbilityInformed(AbilityType ability, boolean bool) {
|
||||
switch (ability) {
|
||||
case BERSERK:
|
||||
berserkInformed = bool;
|
||||
break;
|
||||
|
||||
case BLAST_MINING:
|
||||
blastMiningInformed = bool;
|
||||
break;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
superBreakerInformed = bool;
|
||||
break;
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
gigaDrillBreakerInformed = bool;
|
||||
break;
|
||||
|
||||
case GREEN_TERRA:
|
||||
greenTerraInformed = bool;
|
||||
break;
|
||||
|
||||
case SKULL_SPLITTER:
|
||||
skullSplitterInformed = bool;
|
||||
break;
|
||||
|
||||
case TREE_FELLER:
|
||||
treeFellerInformed = bool;
|
||||
break;
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
serratedStrikesInformed = bool;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getAbilityUse() {
|
||||
return abilityUse;
|
||||
}
|
||||
|
||||
public void toggleAbilityUse() {
|
||||
abilityUse = !abilityUse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Recently Hurt
|
||||
*/
|
||||
|
||||
public long getRecentlyHurt() {
|
||||
return recentlyHurt;
|
||||
}
|
||||
|
||||
public void setRecentlyHurt(long value) {
|
||||
recentlyHurt = value;
|
||||
}
|
||||
|
||||
public void actualizeRecentlyHurt() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Ability Notifications
|
||||
*/
|
||||
|
||||
public boolean useChatNotifications() {
|
||||
return displaySkillNotifications;
|
||||
}
|
||||
|
||||
public void toggleChatNotifications() {
|
||||
displaySkillNotifications = !displaySkillNotifications;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cooldowns
|
||||
*/
|
||||
@@ -965,18 +583,6 @@ public class PlayerProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Exploit Prevention
|
||||
*/
|
||||
|
||||
public int getRespawnATS() {
|
||||
return respawnATS;
|
||||
}
|
||||
|
||||
public void actualizeRespawnATS() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Xp Functions
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
public class Ability {
|
||||
protected boolean mode;
|
||||
protected boolean informed = true;
|
||||
|
||||
public boolean getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(boolean mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public boolean getInformed() {
|
||||
return informed;
|
||||
}
|
||||
|
||||
public void setInformed(boolean informed) {
|
||||
this.informed = informed;
|
||||
}
|
||||
}
|
||||
@@ -3,38 +3,57 @@ package com.gmail.nossr50.datatypes.skills;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public enum SkillType {
|
||||
ACROBATICS,
|
||||
ARCHERY,
|
||||
AXES(AbilityType.SKULL_SPLITTER, ToolType.AXE),
|
||||
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL),
|
||||
FISHING,
|
||||
HERBALISM(AbilityType.GREEN_TERRA, ToolType.HOE),
|
||||
MINING(AbilityType.SUPER_BREAKER, ToolType.PICKAXE),
|
||||
REPAIR,
|
||||
SMELTING,
|
||||
SWORDS(AbilityType.SERRATED_STRIKES, ToolType.SWORD),
|
||||
TAMING,
|
||||
UNARMED(AbilityType.BERSERK, ToolType.FISTS),
|
||||
WOODCUTTING(AbilityType.TREE_FELLER, ToolType.AXE);
|
||||
ACROBATICS(AcrobaticsManager.class),
|
||||
ARCHERY(ArcheryManager.class),
|
||||
AXES(AxesManager.class, AbilityType.SKULL_SPLITTER, ToolType.AXE),
|
||||
EXCAVATION(ExcavationManager.class, AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL),
|
||||
FISHING(FishingManager.class),
|
||||
HERBALISM(HerbalismManager.class, AbilityType.GREEN_TERRA, ToolType.HOE),
|
||||
MINING(MiningManager.class, AbilityType.SUPER_BREAKER, ToolType.PICKAXE),
|
||||
REPAIR(null), // TODO: Create a proper RepairManager class
|
||||
SMELTING(SmeltingManager.class),
|
||||
SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD),
|
||||
TAMING(TamingManager.class),
|
||||
UNARMED(UnarmedManager.class, AbilityType.BERSERK, ToolType.FISTS),
|
||||
WOODCUTTING(null, AbilityType.TREE_FELLER, ToolType.AXE); // TODO: Create a proper WoodcuttingManager class
|
||||
|
||||
private AbilityType ability;
|
||||
private ToolType tool;
|
||||
private Class<? extends SkillManager> managerClass;
|
||||
private AbilityType abilityType;
|
||||
private ToolType toolType;
|
||||
|
||||
private SkillType() {
|
||||
this.ability = null;
|
||||
this.tool = null;
|
||||
private SkillType(Class<? extends SkillManager> managerClass) {
|
||||
this.managerClass = managerClass;
|
||||
abilityType = null;
|
||||
toolType = null;
|
||||
}
|
||||
|
||||
private SkillType(AbilityType ability, ToolType tool) {
|
||||
this.ability = ability;
|
||||
this.tool = tool;
|
||||
private SkillType(Class<? extends SkillManager> managerClass, AbilityType abilityType, ToolType toolType) {
|
||||
this.managerClass = managerClass;
|
||||
this.abilityType = abilityType;
|
||||
this.toolType = toolType;
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
public Class<? extends SkillManager> getManagerClass() {
|
||||
return managerClass;
|
||||
}
|
||||
|
||||
public AbilityType getAbilityType() {
|
||||
return abilityType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,8 +77,8 @@ public enum SkillType {
|
||||
return Config.getInstance().getDoubleDropsDisabled(this);
|
||||
}
|
||||
|
||||
public ToolType getTool() {
|
||||
return tool;
|
||||
public ToolType getToolType() {
|
||||
return toolType;
|
||||
}
|
||||
|
||||
public double getXpModifier() {
|
||||
|
||||
26
src/main/java/com/gmail/nossr50/datatypes/skills/Tool.java
Normal file
26
src/main/java/com/gmail/nossr50/datatypes/skills/Tool.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class Tool {
|
||||
private boolean preparationMode = true;
|
||||
private long preparationATS;
|
||||
|
||||
public boolean getPreparationMode() {
|
||||
return preparationMode;
|
||||
}
|
||||
|
||||
public void setPreparationMode(boolean preparationMode) {
|
||||
this.preparationMode = preparationMode;
|
||||
}
|
||||
|
||||
public long getPreparationATS() {
|
||||
return preparationATS;
|
||||
}
|
||||
|
||||
public void setPreparationATS(long toolPreparationATS) {
|
||||
int startTime = (int) (toolPreparationATS / Misc.TIME_CONVERSION_FACTOR);
|
||||
|
||||
preparationATS = startTime;
|
||||
}
|
||||
}
|
||||
@@ -23,20 +23,18 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
@@ -145,18 +143,17 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
||||
HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName());
|
||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||
|
||||
/* Green Terra */
|
||||
if (herbalismManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(player, SkillType.HERBALISM);
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -177,17 +174,18 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* MINING */
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
if (miningManager.getAbility().getMode()) {
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) {
|
||||
if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getAbility().getMode() && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) {
|
||||
Woodcutting.beginTreeFeller(blockState, player);
|
||||
}
|
||||
else {
|
||||
@@ -204,10 +202,11 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
ExcavationManager excavationManager = SkillManagerStore.getInstance().getExcavationManager(player.getName());
|
||||
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
|
||||
|
||||
excavationManager.excavationBlockCheck(blockState);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (excavationManager.getAbility().getMode()) {
|
||||
excavationManager.gigaDrillBreaker(blockState);
|
||||
}
|
||||
}
|
||||
@@ -235,17 +234,19 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
SmeltingManager smeltingManager = mcMMOPlayer.getSmeltingManager();
|
||||
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canUseHylianLuck()) {
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processHylianLuck(blockState)) {
|
||||
if (herbalismManager.canUseHylianLuck()) {
|
||||
if (herbalismManager.processHylianLuck(blockState)) {
|
||||
blockState.update(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if (SkillManagerStore.getInstance().getSmeltingManager(playerName).canUseFluxMining(blockState)) {
|
||||
if (SkillManagerStore.getInstance().getSmeltingManager(playerName).processFluxMining(blockState)) {
|
||||
else if (smeltingManager.canUseFluxMining(blockState)) {
|
||||
if (smeltingManager.processFluxMining(blockState)) {
|
||||
blockState.update(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -269,7 +270,7 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
/*
|
||||
@@ -281,30 +282,30 @@ public class BlockListener implements Listener {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||
if ((ItemUtils.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
|
||||
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode())) {
|
||||
SkillUtils.removeAbilityBuff(heldItem);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||
if ((mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode() && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode() && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||
SkillUtils.handleAbilitySpeedDecrease(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
SkillUtils.abilityCheck(player, SkillType.HERBALISM);
|
||||
if (mcMMOPlayer.getSkillManager(SkillType.HERBALISM).getTool().getPreparationMode() && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
||||
SkillUtils.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
else if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getTool().getPreparationMode() && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
SkillUtils.abilityCheck(player, SkillType.MINING);
|
||||
else if (mcMMOPlayer.getSkillManager(SkillType.MINING).getTool().getPreparationMode() && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillUtils.abilityCheck(player, SkillType.EXCAVATION);
|
||||
else if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getTool().getPreparationMode() && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||
SkillUtils.abilityCheck(player, SkillType.UNARMED);
|
||||
else if (mcMMOPlayer.getSkillManager(SkillType.UNARMED).getTool().getPreparationMode() && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +314,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.
|
||||
*/
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState)) {
|
||||
if (mcMMOPlayer.getSkillManager(SkillType.WOODCUTTING).getTool().getPreparationMode() && BlockUtils.isLog(blockState)) {
|
||||
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
||||
}
|
||||
}
|
||||
@@ -335,24 +336,23 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
BlockState blockState = block.getState();
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canGreenTerraBlock(blockState)) {
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processGreenTerra(blockState)) {
|
||||
if (herbalismManager.canGreenTerraBlock(blockState)) {
|
||||
if (herbalismManager.processGreenTerra(blockState)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||
else if (mcMMOPlayer.getSkillManager(SkillType.UNARMED).getTool().getPreparationMode()) {
|
||||
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (heldItem.getType() == Material.AIR) {
|
||||
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
|
||||
@@ -368,7 +368,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) {
|
||||
else if ((mcMMOPlayer.getProfile().getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) {
|
||||
if (SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemUtils.isAxe(heldItem)) {
|
||||
|
||||
@@ -28,17 +28,17 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -60,16 +60,19 @@ public class EntityListener implements Listener {
|
||||
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof FallingBlock) {
|
||||
Block block = event.getBlock();
|
||||
if (!(entity instanceof FallingBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block) && !entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
else if (entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block) && !isTracked) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
else if (isTracked) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,11 +89,16 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (Misc.isNPCEntity(defender) || defender.isDead()) {
|
||||
if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
LivingEntity target = (LivingEntity) defender;
|
||||
|
||||
if (CombatUtils.isInvincible(target, event.getDamage())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
@@ -103,37 +111,22 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
if (defender instanceof Player && attacker instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
Player attackingPlayer = (Player) attacker;
|
||||
|
||||
// TODO: Is this even possible?
|
||||
if (!defendingPlayer.isOnline()) {
|
||||
// TODO: Why?
|
||||
if (defendingPlayer == attackingPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
Player attackingPlayer = (Player) attacker;
|
||||
|
||||
if (defendingPlayer == attackingPlayer) {
|
||||
return;
|
||||
}
|
||||
else if (PartyManager.inSameParty(defendingPlayer, attackingPlayer)) {
|
||||
if (!(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (PartyManager.inSameParty(defendingPlayer, attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
if (defender instanceof LivingEntity) {
|
||||
LivingEntity livingDefender = (LivingEntity) defender;
|
||||
|
||||
if (!CombatUtils.isInvincible(livingDefender, event.getDamage())) {
|
||||
CombatUtils.combatChecks(event, attacker, livingDefender);
|
||||
}
|
||||
}
|
||||
CombatUtils.combatChecks(event, attacker, target);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,24 +156,24 @@ public class EntityListener implements Listener {
|
||||
if (livingEntity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
|
||||
// TODO: Is it even possible for the player to be off-line here?
|
||||
if (!player.isOnline() || Misc.isNPCEntity(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
/* Check for invincibility */
|
||||
if (profile.getGodMode()) {
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cause) {
|
||||
case FALL:
|
||||
if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canRoll()) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage()));
|
||||
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
||||
|
||||
if (acrobaticsManager.canRoll()) {
|
||||
event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
@@ -190,7 +183,7 @@ public class EntityListener implements Listener {
|
||||
break;
|
||||
|
||||
case BLOCK_EXPLOSION:
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
|
||||
if (miningManager.canUseDemolitionsExpertise()) {
|
||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
@@ -207,7 +200,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
profile.actualizeRecentlyHurt();
|
||||
mcMMOPlayer.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
else if (livingEntity instanceof Tameable) {
|
||||
@@ -218,24 +211,26 @@ public class EntityListener implements Listener {
|
||||
Player player = (Player) owner;
|
||||
Wolf wolf = (Wolf) pet;
|
||||
|
||||
TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager();
|
||||
|
||||
switch (cause) {
|
||||
case CONTACT:
|
||||
case FIRE:
|
||||
case LAVA:
|
||||
if (Taming.canUseEnvironmentallyAware(player)) {
|
||||
Taming.processEnvironmentallyAware(player, wolf, event.getDamage());
|
||||
if (tamingManager.canUseEnvironmentallyAware()) {
|
||||
tamingManager.processEnvironmentallyAware(wolf, event.getDamage());
|
||||
}
|
||||
return;
|
||||
|
||||
case FALL:
|
||||
if (Taming.canUseEnvironmentallyAware(player)) {
|
||||
if (tamingManager.canUseEnvironmentallyAware()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
|
||||
case ENTITY_ATTACK:
|
||||
case PROJECTILE:
|
||||
if (Taming.canUseThickFur(player)) {
|
||||
if (tamingManager.canUseThickFur()) {
|
||||
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
@@ -245,7 +240,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
|
||||
case FIRE_TICK:
|
||||
if (Taming.canUseThickFur(player)) {
|
||||
if (tamingManager.canUseThickFur()) {
|
||||
Taming.processThickFurFire(wolf);
|
||||
}
|
||||
return;
|
||||
@@ -253,7 +248,7 @@ public class EntityListener implements Listener {
|
||||
case MAGIC:
|
||||
case POISON:
|
||||
case WITHER:
|
||||
if (Taming.canUseHolyHound(player)) {
|
||||
if (tamingManager.canUseHolyHound()) {
|
||||
Taming.processHolyHound(wolf, event.getDamage());
|
||||
}
|
||||
return;
|
||||
@@ -261,7 +256,7 @@ public class EntityListener implements Listener {
|
||||
case BLOCK_EXPLOSION:
|
||||
case ENTITY_EXPLOSION:
|
||||
case LIGHTNING:
|
||||
if (Taming.canUseShockProof(player)) {
|
||||
if (tamingManager.canUseShockProof()) {
|
||||
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
@@ -302,7 +297,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (Misc.isSpawnerXPEnabled || event.getEntity() == null) {
|
||||
if (Misc.isSpawnerXPEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,12 +320,14 @@ public class EntityListener implements Listener {
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName());
|
||||
if (!plugin.tntIsTracked(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (miningManager.canUseBiggerBombs()) {
|
||||
event.setRadius(miningManager.biggerBombs(event.getRadius()));
|
||||
}
|
||||
MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager();
|
||||
|
||||
if (miningManager.canUseBiggerBombs()) {
|
||||
event.setRadius(miningManager.biggerBombs(event.getRadius()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,16 +344,18 @@ public class EntityListener implements Listener {
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName());
|
||||
|
||||
if (miningManager.canUseBlastMining()) {
|
||||
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
|
||||
event.setYield(0);
|
||||
}
|
||||
|
||||
plugin.removeFromTNTTracker(id);
|
||||
if (!plugin.tntIsTracked(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MiningManager miningManager = UserManager.getPlayer(plugin.getTNTPlayer(id)).getMiningManager();
|
||||
|
||||
if (miningManager.canUseBlastMining()) {
|
||||
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
|
||||
event.setYield(0);
|
||||
}
|
||||
|
||||
plugin.removeFromTNTTracker(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,49 +379,51 @@ public class EntityListener implements Listener {
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
|
||||
if (foodChange <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
if (foodChange > 0) {
|
||||
switch (player.getItemInHand().getType()) {
|
||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
if (Permissions.farmersDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
switch (player.getItemInHand().getType()) {
|
||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
if (Permissions.farmersDiet(player)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
if (Permissions.farmersDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
if (Permissions.farmersDiet(player)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
if (Permissions.fishermansDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
if (Permissions.fishermansDiet(player)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
if (Permissions.fishermansDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
if (Permissions.fishermansDiet(player)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,32 +436,38 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if (entity != null && !entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(entity);
|
||||
}
|
||||
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle EntityTarget events.
|
||||
*
|
||||
* @param event The event to process
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player) {
|
||||
Player player = (Player) event.getTarget();
|
||||
Tameable tameable = (Tameable) event.getEntity();
|
||||
Entity entity = event.getEntity();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (CombatUtils.isFriendlyPet(player, tameable)) {
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
Player owner = (Player) tameable.getOwner();
|
||||
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Tameable && target instanceof Player) {
|
||||
Player player = (Player) target;
|
||||
Tameable tameable = (Tameable) entity;
|
||||
|
||||
if (!CombatUtils.isFriendlyPet(player, tameable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -94,13 +93,11 @@ public class InventoryListener implements Listener {
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (!Misc.isNPCEntity(player)) {
|
||||
if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.fuelEfficiency(player)) {
|
||||
event.setBurnTime(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event.getBurnTime()));
|
||||
}
|
||||
event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,13 +112,11 @@ public class InventoryListener implements Listener {
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (!Misc.isNPCEntity(player)) {
|
||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||
event.setResult(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult()));
|
||||
}
|
||||
event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(event.getSource().getType(), event.getResult()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,10 +129,12 @@ public class InventoryListener implements Listener {
|
||||
ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemUtils.isSmelted(result)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) {
|
||||
event.setExpToDrop(SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop()));
|
||||
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
|
||||
|
||||
if (smeltingManager.canUseVanillaXpBoost()) {
|
||||
event.setExpToDrop(smeltingManager.vanillaXPBoost(event.getExpToDrop()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +30,16 @@ import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.HardcoreManager;
|
||||
@@ -100,10 +99,9 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (profile.getGodMode() && !Permissions.mcgod(player)) {
|
||||
profile.toggleGodMode();
|
||||
if (mcMMOPlayer.getGodMode() && !Permissions.mcgod(player)) {
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
|
||||
@@ -127,7 +125,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
UserManager.addUser(player).getProfile().actualizeRespawnATS();
|
||||
UserManager.addUser(player).actualizeRespawnATS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,9 +137,9 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode() || mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +160,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
FishingManager fishingManager = SkillManagerStore.getInstance().getFishingManager(player.getName());
|
||||
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||
|
||||
switch (event.getState()) {
|
||||
case CAUGHT_FISH:
|
||||
@@ -260,7 +258,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).getProfile().actualizeRespawnATS();
|
||||
UserManager.getPlayer(player).actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,6 +276,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
@@ -285,7 +285,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||
mcMMO.repairManager.handleRepair(UserManager.getPlayer(player), heldItem);
|
||||
mcMMO.repairManager.handleRepair(mcMMOPlayer, heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
@@ -296,12 +296,12 @@ public class PlayerListener implements Listener {
|
||||
player.updateInventory();
|
||||
}
|
||||
/* BLAST MINING CHECK */
|
||||
else if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) {
|
||||
else if (miningManager.canDetonate()) {
|
||||
if (blockID == Material.TNT.getId()) {
|
||||
event.setCancelled(true); // Don't detonate the TNT if they're too close
|
||||
}
|
||||
else {
|
||||
SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation();
|
||||
miningManager.remoteDetonation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,8 +309,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
/* BLAST MINING CHECK */
|
||||
if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) {
|
||||
SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation();
|
||||
if (miningManager.canDetonate()) {
|
||||
miningManager.remoteDetonation();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -334,6 +334,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
@@ -359,7 +360,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName());
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
|
||||
@@ -399,14 +400,15 @@ public class PlayerListener implements Listener {
|
||||
case LEFT_CLICK_BLOCK:
|
||||
|
||||
/* CALL OF THE WILD CHECKS */
|
||||
if (player.isSneaking()) {
|
||||
if (player.isSneaking() && Permissions.callOfTheWild(player)) {
|
||||
Material type = heldItem.getType();
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
if (type == Material.RAW_FISH) {
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot();
|
||||
tamingManager.summonOcelot();
|
||||
}
|
||||
else if (type == Material.BONE) {
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf();
|
||||
tamingManager.summonWolf();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -20,23 +19,22 @@ public class SkillMonitorTask implements Runnable {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
* MONITOR SKILLS & COOLDOWN
|
||||
*/
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.getTool() != null && skill.getAbility() != null) {
|
||||
SkillUtils.monitorSkill(player, profile, curTime, skill);
|
||||
if (skill.getAbilityType() == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (ability.getCooldown() > 0) {
|
||||
SkillUtils.watchCooldown(player, profile, ability);
|
||||
if (skill.getToolType() != null) {
|
||||
SkillUtils.monitorSkill(mcMMOPlayer, curTime, skill);
|
||||
}
|
||||
|
||||
if (skill.getAbilityType().getCooldown() > 0) {
|
||||
SkillUtils.watchCooldown(mcMMOPlayer, skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,17 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.Ability;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.Tool;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
|
||||
public abstract class SkillManager {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected int activationChance;
|
||||
protected SkillType skill;
|
||||
protected Ability ability = new Ability();
|
||||
protected Tool tool; // Because tool can be shared, it's instanced in McMMOPlayer
|
||||
|
||||
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
@@ -41,4 +45,16 @@ public abstract class SkillManager {
|
||||
public void applyXpGain(int xp) {
|
||||
mcMMOPlayer.beginXpGain(skill, xp);
|
||||
}
|
||||
|
||||
public Ability getAbility() {
|
||||
return ability;
|
||||
}
|
||||
|
||||
public Tool getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
public void setTool(Tool tool) {
|
||||
this.tool = tool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxeManager;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SkillManagerStore {
|
||||
private static SkillManagerStore instance;
|
||||
|
||||
private HashMap<String, AcrobaticsManager> acrobaticsManagers = new HashMap<String, AcrobaticsManager>();
|
||||
private HashMap<String, ArcheryManager> archeryManagers = new HashMap<String, ArcheryManager>();
|
||||
private HashMap<String, AxeManager> axeManagers = new HashMap<String, AxeManager>();
|
||||
private HashMap<String, ExcavationManager> excavationManagers = new HashMap<String, ExcavationManager>();
|
||||
private HashMap<String, FishingManager> fishingManagers = new HashMap<String, FishingManager>();
|
||||
private HashMap<String, HerbalismManager> herbalismManagers = new HashMap<String, HerbalismManager>();
|
||||
private HashMap<String, MiningManager> miningManagers = new HashMap<String, MiningManager>();
|
||||
private HashMap<String, SmeltingManager> smeltingManagers = new HashMap<String, SmeltingManager>();
|
||||
private HashMap<String, SwordsManager> swordsManagers = new HashMap<String, SwordsManager>();
|
||||
private HashMap<String, TamingManager> tamingManagers = new HashMap<String, TamingManager>();
|
||||
private HashMap<String, UnarmedManager> unarmedManagers = new HashMap<String, UnarmedManager>();
|
||||
|
||||
public static SkillManagerStore getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SkillManagerStore();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public AcrobaticsManager getAcrobaticsManager(String playerName) {
|
||||
if (!acrobaticsManagers.containsKey(playerName)) {
|
||||
acrobaticsManagers.put(playerName, new AcrobaticsManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return acrobaticsManagers.get(playerName);
|
||||
}
|
||||
|
||||
public ArcheryManager getArcheryManager(String playerName) {
|
||||
if (!archeryManagers.containsKey(playerName)) {
|
||||
archeryManagers.put(playerName, new ArcheryManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return archeryManagers.get(playerName);
|
||||
}
|
||||
|
||||
public AxeManager getAxeManager(String playerName) {
|
||||
if (!axeManagers.containsKey(playerName)) {
|
||||
axeManagers.put(playerName, new AxeManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return axeManagers.get(playerName);
|
||||
}
|
||||
|
||||
public ExcavationManager getExcavationManager(String playerName) {
|
||||
if (!excavationManagers.containsKey(playerName)) {
|
||||
excavationManagers.put(playerName, new ExcavationManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return excavationManagers.get(playerName);
|
||||
}
|
||||
|
||||
public FishingManager getFishingManager(String playerName) {
|
||||
if (!fishingManagers.containsKey(playerName)) {
|
||||
fishingManagers.put(playerName, new FishingManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return fishingManagers.get(playerName);
|
||||
}
|
||||
|
||||
public HerbalismManager getHerbalismManager(String playerName) {
|
||||
if (!herbalismManagers.containsKey(playerName)) {
|
||||
herbalismManagers.put(playerName, new HerbalismManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return herbalismManagers.get(playerName);
|
||||
}
|
||||
|
||||
public MiningManager getMiningManager(String playerName) {
|
||||
if (!miningManagers.containsKey(playerName)) {
|
||||
miningManagers.put(playerName, new MiningManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return miningManagers.get(playerName);
|
||||
}
|
||||
|
||||
public SmeltingManager getSmeltingManager(String playerName) {
|
||||
if (!smeltingManagers.containsKey(playerName)) {
|
||||
smeltingManagers.put(playerName, new SmeltingManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return smeltingManagers.get(playerName);
|
||||
}
|
||||
|
||||
public SwordsManager getSwordsManager(String playerName) {
|
||||
if (!swordsManagers.containsKey(playerName)) {
|
||||
swordsManagers.put(playerName, new SwordsManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return swordsManagers.get(playerName);
|
||||
}
|
||||
|
||||
public TamingManager getTamingManager(String playerName) {
|
||||
if (!tamingManagers.containsKey(playerName)) {
|
||||
tamingManagers.put(playerName, new TamingManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return tamingManagers.get(playerName);
|
||||
}
|
||||
|
||||
public UnarmedManager getUnarmedManager(String playerName) {
|
||||
if (!unarmedManagers.containsKey(playerName)) {
|
||||
unarmedManagers.put(playerName, new UnarmedManager(UserManager.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return unarmedManagers.get(playerName);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
@@ -52,14 +51,12 @@ public class AcrobaticsManager extends SkillManager {
|
||||
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
|
||||
ParticleEffectUtils.playDodgeEffect(player);
|
||||
|
||||
PlayerProfile playerProfile = getProfile();
|
||||
|
||||
if (playerProfile.useChatNotifications()) {
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
||||
}
|
||||
|
||||
// Why do we check respawn cooldown here?
|
||||
if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
|
||||
if (System.currentTimeMillis() >= mcMMOPlayer.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
|
||||
applyXpGain(damage * Acrobatics.dodgeXpModifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,11 +86,11 @@ public class ArcheryManager extends SkillManager {
|
||||
defender.teleport(dazedLocation);
|
||||
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
|
||||
|
||||
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
|
||||
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||
}
|
||||
|
||||
if (getProfile().useChatNotifications()) {
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
@@ -19,8 +17,8 @@ import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AxeManager extends SkillManager {
|
||||
public AxeManager(McMMOPlayer mcMMOPlayer) {
|
||||
public class AxesManager extends SkillManager {
|
||||
public AxesManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.AXES);
|
||||
}
|
||||
|
||||
@@ -41,11 +39,11 @@ public class AxeManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canUseSkullSplitter(LivingEntity target) {
|
||||
return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
|
||||
return target.isValid() && getAbility().getMode() && Permissions.skullSplitter(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
|
||||
return tool.getPreparationMode() && Permissions.skullSplitter(getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,14 +116,14 @@ public class AxeManager extends SkillManager {
|
||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
||||
|
||||
if (getProfile().useChatNotifications()) {
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
|
||||
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
||||
@@ -30,7 +27,6 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class HerbalismManager extends SkillManager {
|
||||
@@ -62,15 +58,15 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canGreenTerraBlock(BlockState blockState) {
|
||||
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState);
|
||||
return getAbility().getMode() && BlockUtils.canMakeMossy(blockState);
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
|
||||
return tool.getPreparationMode() && Permissions.greenTerra(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canGreenTerraPlant() {
|
||||
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
return getAbility().getMode();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,9 +284,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (getAbility().getMode()) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ public class MiningManager extends SkillManager{
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = getProfile();
|
||||
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
|
||||
|
||||
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
|
||||
@@ -97,8 +96,8 @@ public class MiningManager extends SkillManager{
|
||||
targetBlock.setData((byte) 0x0);
|
||||
targetBlock.setType(Material.AIR);
|
||||
|
||||
profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
profile.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
||||
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
getAbility().setInformed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -204,9 +204,9 @@ public class Repair {
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!profile.getPlacedAnvil()) {
|
||||
if (!mcMMOPlayer.getPlacedAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
@@ -219,7 +219,7 @@ public class Repair {
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
profile.togglePlacedAnvil();
|
||||
mcMMOPlayer.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
@@ -59,9 +59,9 @@ public class Salvage {
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(final Player player, final int anvilID) {
|
||||
final PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!profile.getPlacedSalvageAnvil()) {
|
||||
if (!mcMMOPlayer.getPlacedSalvageAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Salvage {
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
profile.togglePlacedSalvageAnvil();
|
||||
mcMMOPlayer.togglePlacedSalvageAnvil();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SimpleRepairManager implements RepairManager {
|
||||
private HashMap<Integer, Repairable> repairables;
|
||||
@@ -108,6 +109,9 @@ public class SimpleRepairManager implements RepairManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear ability buffs before trying to repair.
|
||||
SkillUtils.removeAbilityBuff(item);
|
||||
|
||||
// Lets get down to business,
|
||||
// To defeat, the huns.
|
||||
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -17,6 +18,18 @@ public class SwordsManager extends SkillManager {
|
||||
super(mcMMOPlayer, SkillType.SWORDS);
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return tool.getPreparationMode() && Permissions.serratedStrikes(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseBleed() {
|
||||
return Permissions.bleed(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseSerratedStrike() {
|
||||
return getAbility().getMode() && Permissions.serratedStrikes(getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Bleed effect.
|
||||
*
|
||||
@@ -34,14 +47,14 @@ public class SwordsManager extends SkillManager {
|
||||
BleedTimerTask.add(target, Swords.bleedBaseTicks);
|
||||
}
|
||||
|
||||
if (getProfile().useChatNotifications()) {
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
|
||||
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class BeastLoreEventHandler {
|
||||
private Player player;
|
||||
private LivingEntity livingEntity;
|
||||
private Tameable beast;
|
||||
|
||||
protected BeastLoreEventHandler(Player player, LivingEntity livingEntity) {
|
||||
this.player = player;
|
||||
this.livingEntity = livingEntity;
|
||||
this.beast = (Tameable) livingEntity;
|
||||
}
|
||||
|
||||
protected void sendInspectMessage() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
|
||||
|
||||
if (beast.isTamed()) {
|
||||
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", getOwnerName()) + " ");
|
||||
}
|
||||
|
||||
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", livingEntity.getHealth(), livingEntity.getMaxHealth()));
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of a tameable animal's owner.
|
||||
*
|
||||
* @return the name of the animal's owner
|
||||
*/
|
||||
private String getOwnerName() {
|
||||
AnimalTamer tamer = beast.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
return ((Player) tamer).getName();
|
||||
}
|
||||
else if (tamer instanceof OfflinePlayer) {
|
||||
return ((OfflinePlayer) tamer).getName();
|
||||
}
|
||||
|
||||
return "Unknown Master";
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class CallOfTheWildEventHandler {
|
||||
protected Player player;
|
||||
protected ItemStack inHand;
|
||||
protected EntityType type;
|
||||
protected int summonAmount;
|
||||
|
||||
protected CallOfTheWildEventHandler(Player player, EntityType type, int summonAmount) {
|
||||
this.player = player;
|
||||
this.inHand = player.getItemInHand();
|
||||
this.type = type;
|
||||
this.summonAmount = summonAmount;
|
||||
}
|
||||
|
||||
protected void sendInsufficientAmountMessage() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId())));
|
||||
}
|
||||
|
||||
protected boolean nearbyEntityExists() {
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean entityExists = false;
|
||||
|
||||
for (Entity entity : player.getNearbyEntities(40, 40, 40)) {
|
||||
if (entity.getType() == type) {
|
||||
entityExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entityExists;
|
||||
}
|
||||
|
||||
protected void sendFailureMessage() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == EntityType.OCELOT) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf"));
|
||||
}
|
||||
}
|
||||
|
||||
protected void spawnCreature() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
|
||||
((Tameable) entity).setOwner(player);
|
||||
|
||||
if (type == EntityType.OCELOT) {
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
|
||||
}
|
||||
else {
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
}
|
||||
}
|
||||
|
||||
protected void processResourceCost() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newAmount = inHand.getAmount() - summonAmount;
|
||||
|
||||
if (newAmount == 0) {
|
||||
player.setItemInHand(new ItemStack(Material.AIR));
|
||||
}
|
||||
else {
|
||||
player.getItemInHand().setAmount(inHand.getAmount() - summonAmount);
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendSuccessMessage() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.entity.Wolf;
|
||||
|
||||
public class FastFoodServiceEventHandler {
|
||||
private Wolf wolf;
|
||||
|
||||
public FastFoodServiceEventHandler(Wolf wolf) {
|
||||
this.wolf = wolf;
|
||||
}
|
||||
|
||||
protected void modifyHealth(int damage) {
|
||||
int health = wolf.getHealth();
|
||||
int maxHealth = wolf.getMaxHealth();
|
||||
|
||||
if (health < maxHealth) {
|
||||
int newHealth = health + damage;
|
||||
|
||||
if (newHealth <= maxHealth) {
|
||||
wolf.setHealth(newHealth);
|
||||
}
|
||||
else {
|
||||
wolf.setHealth(maxHealth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class GoreEventHandler {
|
||||
private TamingManager manager;
|
||||
private EntityDamageEvent event;
|
||||
private Entity entity;
|
||||
protected int skillModifier;
|
||||
|
||||
protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
this.entity = event.getEntity();
|
||||
calculateSkillModifier();
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = SkillUtils.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel);
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(event.getDamage() * Taming.goreModifier);
|
||||
}
|
||||
|
||||
protected void sendAbilityMessage() {
|
||||
if (entity instanceof Player) {
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||
}
|
||||
|
||||
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||
}
|
||||
|
||||
protected void applyBleed() {
|
||||
BleedTimerTask.add((LivingEntity) entity, Taming.goreBleedTicks);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class SharpenedClawsEventHandler {
|
||||
private EntityDamageEvent event;
|
||||
|
||||
public SharpenedClawsEventHandler(EntityDamageEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(event.getDamage() + Taming.sharpenedClawsBonusDamage);
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,26 @@ package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class Taming {
|
||||
public static int environmentallyAwareUnlockLevel = AdvancedConfig.getInstance().getEnviromentallyAwareUnlock();
|
||||
public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock();
|
||||
|
||||
public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock();
|
||||
public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock();
|
||||
public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance();
|
||||
|
||||
public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks();
|
||||
public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks();
|
||||
public static int goreMaxBonusLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
|
||||
public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier();
|
||||
public static double goreMaxChance = AdvancedConfig.getInstance().getGoreChanceMax();
|
||||
public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier();
|
||||
public static double goreMaxChance = AdvancedConfig.getInstance().getGoreChanceMax();
|
||||
|
||||
public static int sharpenedClawsUnlockLevel = AdvancedConfig.getInstance().getSharpenedClawsUnlock();
|
||||
public static int sharpenedClawsBonusDamage = AdvancedConfig.getInstance().getSharpenedClawsBonus();
|
||||
@@ -41,22 +39,6 @@ public class Taming {
|
||||
return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;
|
||||
}
|
||||
|
||||
public static boolean canUseThickFur(Player player) {
|
||||
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player);
|
||||
}
|
||||
|
||||
public static boolean canUseEnvironmentallyAware(Player player) {
|
||||
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player);
|
||||
}
|
||||
|
||||
public static boolean canUseShockProof(Player player) {
|
||||
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player);
|
||||
}
|
||||
|
||||
public static boolean canUseHolyHound(Player player) {
|
||||
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player);
|
||||
}
|
||||
|
||||
public static int processThickFur(Wolf wolf, int damage) {
|
||||
wolf.playEffect(EntityEffect.WOLF_SHAKE);
|
||||
return damage / thickFurModifier;
|
||||
@@ -67,24 +49,37 @@ public class Taming {
|
||||
wolf.setFireTicks(0);
|
||||
}
|
||||
|
||||
public static void processEnvironmentallyAware(Player player, Wolf wolf, int damage) {
|
||||
if (damage > wolf.getHealth()) {
|
||||
return;
|
||||
}
|
||||
|
||||
wolf.teleport(player);
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
|
||||
}
|
||||
|
||||
public static int processShockProof(Wolf wolf, int damage) {
|
||||
wolf.playEffect(EntityEffect.WOLF_SHAKE);
|
||||
return damage / shockProofModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Sharpened Claws ability.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static int sharpenedClaws(int damage) {
|
||||
return damage + Taming.sharpenedClawsBonusDamage;
|
||||
}
|
||||
|
||||
public static void processHolyHound(Wolf wolf, int damage) {
|
||||
int modifiedHealth = Math.min(wolf.getHealth() + damage, wolf.getMaxHealth());
|
||||
|
||||
wolf.setHealth(modifiedHealth);
|
||||
wolf.playEffect(EntityEffect.WOLF_HEARTS);
|
||||
}
|
||||
|
||||
protected static String getCallOfTheWildFailureMessage(EntityType type) {
|
||||
switch (type) {
|
||||
case OCELOT:
|
||||
return LocaleLoader.getString("Taming.Summon.Fail.Ocelot");
|
||||
|
||||
case WOLF:
|
||||
return LocaleLoader.getString("Taming.Summon.Fail.Wolf");
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class TamingManager extends SkillManager {
|
||||
@@ -19,6 +26,26 @@ public class TamingManager extends SkillManager {
|
||||
super(mcMMOPlayer, SkillType.TAMING);
|
||||
}
|
||||
|
||||
public boolean canUseThickFur() {
|
||||
return getSkillLevel() > Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseEnvironmentallyAware() {
|
||||
return getSkillLevel() > Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseShockProof() {
|
||||
return getSkillLevel() > Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseHolyHound() {
|
||||
return getSkillLevel() > Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseBeastLore(LivingEntity target) {
|
||||
return target instanceof Tameable && Permissions.beastLore(getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Award XP for taming.
|
||||
*
|
||||
@@ -58,34 +85,26 @@ public class TamingManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Sharpened Claws ability.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void sharpenedClaws(EntityDamageEvent event) {
|
||||
SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event);
|
||||
eventHandler.modifyEventDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Gore ability.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void gore(EntityDamageEvent event) {
|
||||
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
||||
public int gore(LivingEntity target, int damage) {
|
||||
Player owner = getPlayer();
|
||||
|
||||
float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel());
|
||||
if (chance > Taming.goreMaxChance) {
|
||||
chance = (float) Taming.goreMaxChance;
|
||||
if (SkillUtils.activationSuccessful(owner, skill, Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
||||
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
||||
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||
}
|
||||
|
||||
owner.sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||
return damage * Taming.goreModifier;
|
||||
}
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.applyBleed();
|
||||
eventHandler.sendAbilityMessage();
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,11 +124,31 @@ public class TamingManager extends SkillManager {
|
||||
/**
|
||||
* Handle the Beast Lore ability.
|
||||
*
|
||||
* @param livingEntity The entity to examine
|
||||
* @param target The entity to examine
|
||||
*/
|
||||
public void beastLore(LivingEntity livingEntity) {
|
||||
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity);
|
||||
eventHandler.sendInspectMessage();
|
||||
public void beastLore(LivingEntity target) {
|
||||
Player player = getPlayer();
|
||||
Tameable beast = (Tameable) target;
|
||||
|
||||
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
|
||||
|
||||
if (beast.isTamed()) {
|
||||
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " ");
|
||||
}
|
||||
|
||||
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
public void processEnvironmentallyAware(Wolf wolf, int damage) {
|
||||
if (damage > wolf.getHealth()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player owner = getPlayer();
|
||||
|
||||
wolf.teleport(owner);
|
||||
owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,27 +158,36 @@ public class TamingManager extends SkillManager {
|
||||
* @param summonAmount The amount of material needed to summon the entity
|
||||
*/
|
||||
private void callOfTheWild(EntityType type, int summonAmount) {
|
||||
if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) {
|
||||
Player player = getPlayer();
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
int heldItemAmount = heldItem.getAmount();
|
||||
|
||||
if (heldItemAmount < summonAmount) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getTypeId())));
|
||||
return;
|
||||
}
|
||||
|
||||
CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount);
|
||||
|
||||
ItemStack inHand = eventHandler.inHand;
|
||||
int inHandAmount = inHand.getAmount();
|
||||
|
||||
if (inHandAmount < summonAmount) {
|
||||
eventHandler.sendInsufficientAmountMessage();
|
||||
return;
|
||||
for (Entity entity : player.getNearbyEntities(40, 40, 40)) {
|
||||
if (entity.getType() == type) {
|
||||
player.sendMessage(Taming.getCallOfTheWildFailureMessage(type));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (eventHandler.nearbyEntityExists()) {
|
||||
eventHandler.sendFailureMessage();
|
||||
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
|
||||
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
((Tameable) entity).setOwner(player);
|
||||
|
||||
if (type == EntityType.OCELOT) {
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
|
||||
}
|
||||
else {
|
||||
eventHandler.spawnCreature();
|
||||
eventHandler.processResourceCost();
|
||||
eventHandler.sendSuccessMessage();
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
}
|
||||
|
||||
player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -19,6 +20,22 @@ public class UnarmedManager extends SkillManager {
|
||||
super(mcMMOPlayer, SkillType.UNARMED);
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return tool.getPreparationMode() && Permissions.berserk(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canUseIronArm() {
|
||||
return Permissions.bonusDamage(getPlayer(), skill);
|
||||
}
|
||||
|
||||
public boolean canUseBerserk() {
|
||||
return getAbility().getMode() && Permissions.berserk(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canDisarm(LivingEntity target) {
|
||||
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for disarm.
|
||||
*
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -27,10 +26,9 @@ public final class ChimaeraWing {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
Block block = player.getLocation().getBlock();
|
||||
int amount = inHand.getAmount();
|
||||
long recentlyHurt = profile.getRecentlyHurt();
|
||||
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR;
|
||||
|
||||
if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||
if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||
@@ -44,7 +42,7 @@ public final class ChimaeraWing {
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType() == Material.BED_BLOCK) {
|
||||
if (player.getBedSpawnLocation() != null) {
|
||||
player.teleport(player.getBedSpawnLocation());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -331,7 +331,7 @@ public final class CommandRegistrationManager {
|
||||
public static void registerPtpCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("ptp");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
|
||||
command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle");
|
||||
command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "<toggle|accept|acceptall>"));
|
||||
|
||||
@@ -21,20 +21,21 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.axes.AxeManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||
import com.gmail.nossr50.skills.swords.Swords;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
@@ -50,131 +51,119 @@ public final class CombatUtils {
|
||||
* @param event The event to run the combat checks on.
|
||||
*/
|
||||
public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
|
||||
boolean targetIsPlayer = (target.getType() == EntityType.PLAYER);
|
||||
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
|
||||
Entity damager = event.getDamager();
|
||||
|
||||
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
|
||||
Player player = (Player) attacker;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target instanceof Tameable && isFriendlyPet(player, (Tameable) target)) {
|
||||
return;
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (target instanceof Tameable) {
|
||||
if (heldItem.getType() == Material.BONE && Permissions.beastLore(player)) {
|
||||
mcMMOPlayer.getTamingManager().beastLore(target);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else if (isFriendlyPet(player, (Tameable) target)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
Material heldItemType = heldItem.getType();
|
||||
|
||||
if (ItemUtils.isSword(heldItem)) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
if (!SkillType.SWORDS.getPVPEnabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!SkillType.SWORDS.getPVEEnabled()) {
|
||||
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
String playerName = player.getName();
|
||||
boolean canSerratedStrike = Permissions.serratedStrikes(player); // So we don't have to check the same permission twice
|
||||
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
|
||||
SkillUtils.abilityCheck(player, SkillType.SWORDS);
|
||||
if (swordsManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.SWORDS);
|
||||
}
|
||||
|
||||
if (Permissions.bleed(player)) {
|
||||
SkillManagerStore.getInstance().getSwordsManager(playerName).bleedCheck(target);
|
||||
if (swordsManager.canUseBleed()) {
|
||||
swordsManager.bleedCheck(target);
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) {
|
||||
SkillManagerStore.getInstance().getSwordsManager(playerName).serratedStrikes(target, event.getDamage());
|
||||
if (swordsManager.canUseSerratedStrike()) {
|
||||
swordsManager.serratedStrikes(target, event.getDamage());
|
||||
}
|
||||
|
||||
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
|
||||
startGainXp(swordsManager.getMcMMOPlayer(), target, SkillType.SWORDS);
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isAxe(heldItem)) {
|
||||
if (((targetIsPlayer || targetIsTamedPet) && !SkillType.AXES.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.AXES.getPVEEnabled())) {
|
||||
if (!shouldProcessSkill(target, SkillType.AXES)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.AXES)) {
|
||||
AxeManager axeManager = SkillManagerStore.getInstance().getAxeManager(player.getName());
|
||||
AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
||||
|
||||
if (axeManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(player, SkillType.AXES);
|
||||
if (axesManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.AXES);
|
||||
}
|
||||
|
||||
if (axeManager.canUseAxeMastery()) {
|
||||
event.setDamage(axeManager.axeMasteryCheck(event.getDamage()));
|
||||
if (axesManager.canUseAxeMastery()) {
|
||||
event.setDamage(axesManager.axeMasteryCheck(event.getDamage()));
|
||||
}
|
||||
|
||||
if (axeManager.canCriticalHit(target)) {
|
||||
event.setDamage(axeManager.criticalHitCheck(target, event.getDamage()));
|
||||
if (axesManager.canCriticalHit(target)) {
|
||||
event.setDamage(axesManager.criticalHitCheck(target, event.getDamage()));
|
||||
}
|
||||
|
||||
if (axeManager.canImpact(target)) {
|
||||
axeManager.impactCheck(target);
|
||||
if (axesManager.canImpact(target)) {
|
||||
axesManager.impactCheck(target);
|
||||
}
|
||||
else if (axeManager.canGreaterImpact(target)) {
|
||||
event.setDamage(axeManager.greaterImpactCheck(target, event.getDamage()));
|
||||
else if (axesManager.canGreaterImpact(target)) {
|
||||
event.setDamage(axesManager.greaterImpactCheck(target, event.getDamage()));
|
||||
}
|
||||
|
||||
if (axeManager.canUseSkullSplitter(target)) {
|
||||
axeManager.skullSplitterCheck(target, event.getDamage());
|
||||
if (axesManager.canUseSkullSplitter(target)) {
|
||||
axesManager.skullSplitterCheck(target, event.getDamage());
|
||||
}
|
||||
|
||||
startGainXp(axeManager.getMcMMOPlayer(), target, SkillType.AXES);
|
||||
startGainXp(axesManager.getMcMMOPlayer(), target, SkillType.AXES);
|
||||
}
|
||||
}
|
||||
else if (heldItemType == Material.AIR) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
if (!SkillType.UNARMED.getPVPEnabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!SkillType.UNARMED.getPVEEnabled()) {
|
||||
else if (heldItem.getType() == Material.AIR) {
|
||||
if (!shouldProcessSkill(target, SkillType.UNARMED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
String playerName = player.getName();
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
|
||||
boolean canBerserk = Permissions.berserk(player); // So we don't have to check the same permission twice
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
|
||||
SkillUtils.abilityCheck(player, SkillType.UNARMED);
|
||||
if (unarmedManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
||||
}
|
||||
|
||||
if (Permissions.bonusDamage(player, SkillType.UNARMED)) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).ironArmCheck(event.getDamage()));
|
||||
if (unarmedManager.canUseIronArm()) {
|
||||
event.setDamage(unarmedManager.ironArmCheck(event.getDamage()));
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event.getDamage()));
|
||||
if (unarmedManager.canUseBerserk()) {
|
||||
event.setDamage(unarmedManager.berserkDamage(event.getDamage()));
|
||||
}
|
||||
|
||||
if (target instanceof Player && Permissions.disarm(player)) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (defender.getItemInHand().getType() != Material.AIR) {
|
||||
SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck((Player) target);
|
||||
}
|
||||
if (unarmedManager.canDisarm(target)) {
|
||||
unarmedManager.disarmCheck((Player) target);
|
||||
}
|
||||
|
||||
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||
startGainXp(unarmedManager.getMcMMOPlayer(), target, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) {
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target);
|
||||
else if (heldItem.getType() == Material.BONE) {
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
if (tamingManager.canUseBeastLore(target)) {
|
||||
tamingManager.beastLore(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,29 +178,25 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
if (!SkillType.TAMING.getPVPEnabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!SkillType.TAMING.getPVEEnabled()) {
|
||||
if (!shouldProcessSkill(target, SkillType.TAMING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
||||
int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel();
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
int skillLevel = tamingManager.getSkillLevel();
|
||||
|
||||
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) {
|
||||
SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage());
|
||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||
}
|
||||
|
||||
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) {
|
||||
SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event);
|
||||
event.setDamage(Taming.sharpenedClaws(event.getDamage()));
|
||||
}
|
||||
|
||||
if (Permissions.gore(master)) {
|
||||
SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event);
|
||||
event.setDamage(tamingManager.gore(target, event.getDamage()));
|
||||
}
|
||||
|
||||
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
|
||||
@@ -228,12 +213,7 @@ public final class CombatUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
if (!SkillType.ARCHERY.getPVPEnabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!SkillType.ARCHERY.getPVEEnabled()) {
|
||||
if (!shouldProcessSkill(target, SkillType.ARCHERY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,27 +224,30 @@ public final class CombatUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetIsPlayer) {
|
||||
if (target instanceof Player) {
|
||||
Player player = (Player) target;
|
||||
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
||||
|
||||
if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canDodge(damager)) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event.getDamage()));
|
||||
if (acrobaticsManager.canDodge(damager)) {
|
||||
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
||||
}
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (damager instanceof Player) {
|
||||
if (SkillType.SWORDS.getPVPEnabled() && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) {
|
||||
SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||
mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) {
|
||||
SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||
mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,29 +266,30 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) {
|
||||
String playerName = shooter.getName();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(shooter);
|
||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||
|
||||
if (SkillManagerStore.getInstance().getArcheryManager(playerName).canSkillShot()) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).skillShotCheck(event.getDamage()));
|
||||
if (archeryManager.canSkillShot()) {
|
||||
event.setDamage(archeryManager.skillShotCheck(event.getDamage()));
|
||||
}
|
||||
|
||||
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) {
|
||||
event.setCancelled(SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck());
|
||||
event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (SkillManagerStore.getInstance().getArcheryManager(playerName).canDaze(target)) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).dazeCheck((Player) target, event.getDamage()));
|
||||
if (archeryManager.canDaze(target)) {
|
||||
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
||||
}
|
||||
|
||||
if (SkillManagerStore.getInstance().getArcheryManager(playerName).canTrackArrows()) {
|
||||
SkillManagerStore.getInstance().getArcheryManager(playerName).trackArrows(target);
|
||||
if (archeryManager.canTrackArrows()) {
|
||||
archeryManager.trackArrows(target);
|
||||
}
|
||||
|
||||
SkillManagerStore.getInstance().getArcheryManager(playerName).distanceXpBonus(target);
|
||||
archeryManager.distanceXpBonus(target);
|
||||
startGainXp(UserManager.getPlayer(shooter), target, SkillType.ARCHERY);
|
||||
}
|
||||
}
|
||||
@@ -437,7 +421,7 @@ public final class CombatUtils {
|
||||
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (System.currentTimeMillis() >= UserManager.getPlayer(defender).getProfile().getRespawnATS() + 5) {
|
||||
if (System.currentTimeMillis() >= UserManager.getPlayer(defender).getRespawnATS() + 5) {
|
||||
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
|
||||
}
|
||||
}
|
||||
@@ -525,7 +509,7 @@ public final class CombatUtils {
|
||||
if (entity instanceof Player) {
|
||||
Player defender = (Player) entity;
|
||||
|
||||
if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getProfile().getGodMode()) {
|
||||
if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getGodMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -597,4 +581,17 @@ public final class CombatUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean shouldProcessSkill(LivingEntity target, SkillType skill) {
|
||||
boolean process;
|
||||
|
||||
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
|
||||
process = skill.getPVPEnabled();
|
||||
}
|
||||
else {
|
||||
process = skill.getPVEEnabled();
|
||||
}
|
||||
|
||||
return process;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,19 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.Ability;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.Tool;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
@@ -87,18 +91,21 @@ public class SkillUtils {
|
||||
/**
|
||||
* Sends a message to the player when the cooldown expires.
|
||||
*
|
||||
* @param player The player to send a message to
|
||||
* @param profile The profile of the player
|
||||
* @param ability The ability to watch cooldowns for
|
||||
* @param mcMMOPlayer The player to send a message to
|
||||
* @param skill The skill type to watch cooldowns for
|
||||
*/
|
||||
public static void watchCooldown(Player player, PlayerProfile profile, AbilityType ability) {
|
||||
if (player == null || profile == null || ability == null) {
|
||||
public static void watchCooldown(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
profile.setAbilityInformed(ability, true);
|
||||
player.sendMessage(ability.getAbilityRefresh());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Ability ability = mcMMOPlayer.getSkillManager(skill).getAbility();
|
||||
AbilityType abilityType = skill.getAbilityType();
|
||||
|
||||
if (!ability.getInformed() && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)) {
|
||||
ability.setInformed(true);
|
||||
player.sendMessage(abilityType.getAbilityRefresh());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,96 +120,95 @@ public class SkillUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
AbilityType ability = skill.getAbility();
|
||||
ToolType tool = skill.getTool();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if any abilities are active */
|
||||
if (profile == null) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.getAbilityUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profile.getAbilityUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AbilityType x : AbilityType.values()) {
|
||||
if (profile.getAbilityMode(x)) {
|
||||
for (SkillManager skillManager : mcMMOPlayer.getSkillManagers().values()) {
|
||||
if (skillManager.getAbility().getMode()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||
Tool tool = skillManager.getTool();
|
||||
ToolType toolType = skill.getToolType();
|
||||
AbilityType abilityType = skill.getAbilityType();
|
||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||
|
||||
/*
|
||||
* Woodcutting & Axes need to be treated differently.
|
||||
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
|
||||
*/
|
||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !profile.getToolPreparationMode(tool)) {
|
||||
if (abilityType.getPermissions(player) && toolType.inHand(inHand) && !tool.getPreparationMode()) {
|
||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
|
||||
if (!skillManager.getAbility().getMode() && !cooldownOver(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||
player.sendMessage(tool.getRaiseTool());
|
||||
player.sendMessage(toolType.getRaiseTool());
|
||||
}
|
||||
|
||||
profile.setToolPreparationATS(tool, System.currentTimeMillis());
|
||||
profile.setToolPreparationMode(tool, true);
|
||||
tool.setPreparationATS(System.currentTimeMillis());
|
||||
tool.setPreparationMode(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitors various things relating to skill abilities.
|
||||
*
|
||||
* @param player The player using the skill
|
||||
* @param mcMMOPlayer The player using the skill
|
||||
* @param profile The profile of the player
|
||||
* @param curTime The current system time
|
||||
* @param skill The skill being monitored
|
||||
*/
|
||||
public static void monitorSkill(Player player, PlayerProfile profile, long curTime, SkillType skill) {
|
||||
public static void monitorSkill(McMMOPlayer mcMMOPlayer, long curTime, SkillType skill) {
|
||||
final int FOUR_SECONDS = 4000;
|
||||
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||
Tool tool = skillManager.getTool();
|
||||
|
||||
ToolType tool = skill.getTool();
|
||||
AbilityType ability = skill.getAbility();
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
|
||||
profile.setToolPreparationMode(tool, false);
|
||||
if (tool.getPreparationMode() && curTime - (tool.getPreparationATS() * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
|
||||
tool.setPreparationMode(false);
|
||||
|
||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||
player.sendMessage(tool.getLowerTool());
|
||||
mcMMOPlayer.getPlayer().sendMessage(skill.getToolType().getLowerTool());
|
||||
}
|
||||
}
|
||||
|
||||
if (ability.getPermissions(player)) {
|
||||
if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
|
||||
if (ability == AbilityType.BERSERK) {
|
||||
Ability ability = skillManager.getAbility();
|
||||
AbilityType abilityType = skill.getAbilityType();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (abilityType.getPermissions(player)) {
|
||||
if (ability.getMode() && (mcMMOPlayer.getProfile().getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
|
||||
if (abilityType == AbilityType.BERSERK) {
|
||||
player.setCanPickupItems(true);
|
||||
}
|
||||
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
|
||||
else if (abilityType == AbilityType.SUPER_BREAKER || abilityType == AbilityType.GIGA_DRILL_BREAKER) {
|
||||
handleAbilitySpeedDecrease(player);
|
||||
}
|
||||
|
||||
profile.setAbilityMode(ability, false);
|
||||
profile.setAbilityInformed(ability, false);
|
||||
ability.setMode(false);
|
||||
ability.setInformed(false);
|
||||
|
||||
ParticleEffectUtils.playAbilityDisabledEffect(player);
|
||||
|
||||
if (profile.useChatNotifications()) {
|
||||
player.sendMessage(ability.getAbilityOff());
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
player.sendMessage(abilityType.getAbilityOff());
|
||||
}
|
||||
|
||||
sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
||||
sendSkillMessage(player, abilityType.getAbilityPlayerOff(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,45 +374,47 @@ public class SkillUtils {
|
||||
/**
|
||||
* Check to see if an ability can be activated.
|
||||
*
|
||||
* @param player The player activating the ability
|
||||
* @param type The skill the ability is based on
|
||||
* @param mcMMOPlayer The player activating the ability
|
||||
* @param skill The skill the ability is based on
|
||||
*/
|
||||
public static void abilityCheck(Player player, SkillType type) {
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
ToolType tool = type.getTool();
|
||||
AbilityType ability = type.getAbility();
|
||||
public static void abilityCheck(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||
SkillManager skillManager = mcMMOPlayer.getSkillManager(skill);
|
||||
Ability ability = skillManager.getAbility();
|
||||
AbilityType abilityType = skill.getAbilityType();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||
|
||||
profile.setToolPreparationMode(tool, false);
|
||||
skillManager.getTool().setPreparationMode(false);
|
||||
|
||||
/*
|
||||
* Axes and Woodcutting are odd because they share the same tool.
|
||||
* We show them the too tired message when they take action.
|
||||
*/
|
||||
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
||||
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
|
||||
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
|
||||
if (!ability.getMode() && !cooldownOver(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(abilityType) * Misc.TIME_CONVERSION_FACTOR, abilityType.getCooldown(), player)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
|
||||
if (!ability.getMode() && cooldownOver(playerProfile.getSkillDATS(abilityType), abilityType.getCooldown(), player)) {
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), abilityType.getMaxTicks());
|
||||
|
||||
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
||||
|
||||
if (profile.useChatNotifications()) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
player.sendMessage(abilityType.getAbilityOn());
|
||||
}
|
||||
|
||||
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
||||
SkillUtils.sendSkillMessage(player, abilityType.getAbilityPlayer(player));
|
||||
|
||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
profile.setAbilityMode(ability, true);
|
||||
playerProfile.setSkillDATS(abilityType, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
ability.setMode(true);
|
||||
|
||||
if (ability == AbilityType.BERSERK) {
|
||||
if (abilityType == AbilityType.BERSERK) {
|
||||
player.setCanPickupItems(false);
|
||||
}
|
||||
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
|
||||
else if (abilityType == AbilityType.SUPER_BREAKER || abilityType == AbilityType.GIGA_DRILL_BREAKER) {
|
||||
handleAbilitySpeedIncrease(player);
|
||||
}
|
||||
}
|
||||
@@ -514,14 +522,14 @@ public class SkillUtils {
|
||||
}
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
int ticks = 0;
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
ticks = ((int) (profile.getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
|
||||
if (mcMMOPlayer.getSkillManager(SkillType.MINING).getAbility().getMode()) {
|
||||
ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
ticks = ((int) (profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
|
||||
else if (mcMMOPlayer.getSkillManager(SkillType.EXCAVATION).getAbility().getMode()) {
|
||||
ticks = ((int) (mcMMOPlayer.getProfile().getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
|
||||
}
|
||||
|
||||
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
|
||||
|
||||
@@ -336,7 +336,7 @@ Experience:
|
||||
Wither: 7.0
|
||||
Witch: 4.0
|
||||
Iron_Golem: 2.0
|
||||
Wither_Skeleton: 4.0;
|
||||
Wither_Skeleton: 4.0
|
||||
#
|
||||
# Settings for commands
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user