mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 01:42:32 +01:00
Compare commits
43 Commits
2.0.0
...
dev-1.4.09
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b791649432 | ||
|
|
306ac5d949 | ||
|
|
fb75eac1f7 | ||
|
|
44a4448527 | ||
|
|
001ea19b1c | ||
|
|
3f347091c4 | ||
|
|
f4dbbd7e57 | ||
|
|
e4d3cb5f4d | ||
|
|
e455b41ab9 | ||
|
|
ea704a87db | ||
|
|
813d9049c2 | ||
|
|
67314e1320 | ||
|
|
0e6611c7e9 | ||
|
|
7d82d5ff7b | ||
|
|
eb51081a66 | ||
|
|
00c89d2cf6 | ||
|
|
d88afaf696 | ||
|
|
c6be608e5e | ||
|
|
9def3d5eb4 | ||
|
|
a052bfda7e | ||
|
|
c35c3c0dab | ||
|
|
23f5946cac | ||
|
|
813eeb8873 | ||
|
|
8e60403fc1 | ||
|
|
23b4ff7134 | ||
|
|
b16dec4532 | ||
|
|
271ba2e5f1 | ||
|
|
c9ab2bebd6 | ||
|
|
ef4bbca36a | ||
|
|
ad789ea2bf | ||
|
|
b848968094 | ||
|
|
c572054e67 | ||
|
|
2e6a43ac97 | ||
|
|
837e59d187 | ||
|
|
7f7aa9e799 | ||
|
|
10c18de9bf | ||
|
|
0b92023937 | ||
|
|
04f02ca7f4 | ||
|
|
d701553efe | ||
|
|
e812a949db | ||
|
|
f88dd29926 | ||
|
|
c588708056 | ||
|
|
a9f800ac68 |
@@ -7,6 +7,25 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.09-dev
|
||||
+ Added new child skill; Salvage
|
||||
+ Added new feature to Herbalism. Instantly-regrown crops are protected from being broken for 1 second
|
||||
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
|
||||
+ Added option to config.yml for Alchemy. Skills.Alchemy.Prevent_Hopper_Transfer_Bottles
|
||||
+ Added support for `MATERIAL|data` format in treasures.yml
|
||||
+ Added API to experience events to get XP gain reason
|
||||
+ Added API to check if an entity is bleeding
|
||||
= Fixed bug where the Updater was running on the main thread.
|
||||
= Fixed bug when players would use /ptp without being in a party
|
||||
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent
|
||||
= Fixed bug where dodge would check the wrong player skill level
|
||||
= Fixed bug which causes /party teleport to stop working
|
||||
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
|
||||
! Changed player data saving. Save tasks are now asynchronous
|
||||
! Vanished players no longer get hit by AoE effects
|
||||
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
|
||||
- Removed salvage ability from Repair, salvage has it's own (child) skill now
|
||||
|
||||
Version 1.4.08
|
||||
+ Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
|
||||
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
|
||||
|
||||
@@ -34,7 +34,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
||||
|
||||
### Special thanks
|
||||
[]
|
||||
(https://github.com/EasyMFnE)
|
||||
(https://github.com/EasyMFnE)
|
||||
Added the Alchemy skill
|
||||
|
||||
## Compiling
|
||||
|
||||
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.08</version>
|
||||
<version>1.4.09-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class AbilityAPI {
|
||||
@@ -80,4 +82,8 @@ public final class AbilityAPI {
|
||||
public static void setTreeFellerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
|
||||
}
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
return BleedTimerTask.isBleeding(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidXPGainReasonException;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -62,8 +64,26 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addRawXP(Player player, String skillType, float XP) {
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
|
||||
addRawXP(player, skillType, XP, "UNKNOWN");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param xpGainReason The reason to gain XP
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||
*/
|
||||
public static void addRawXP(Player player, String skillType, float XP, String xpGainReason) {
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -98,8 +118,26 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
addMultipliedXP(player, skillType, XP, "UNKNOWN");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param xpGainReason The reason to gain XP
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, String skillType, int XP, String xpGainReason) {
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,10 +167,28 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addModifiedXP(Player player, String skillType, int XP) {
|
||||
addModifiedXP(player, skillType, XP, "UNKNOWN");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate and skill modifier.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param xpGainReason The reason to gain XP
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||
*/
|
||||
public static void addModifiedXP(Player player, String skillType, int XP, String xpGainReason) {
|
||||
SkillType skill = getSkillType(skillType);
|
||||
|
||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,8 +221,27 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addXP(Player player, String skillType, int XP) {
|
||||
UserManager.getPlayer(player).beginXpGain(getSkillType(skillType), XP);
|
||||
addXP(player, skillType, XP, "UNKNOWN");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills,
|
||||
* and party sharing.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @param xpGainReason The reason to gain XP
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||
*/
|
||||
public static void addXP(Player player, String skillType, int XP, String xpGainReason) {
|
||||
UserManager.getPlayer(player).beginXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,12 +422,12 @@ public final class ExperienceAPI {
|
||||
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
||||
}
|
||||
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
return;
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -581,7 +656,7 @@ public final class ExperienceAPI {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
profile.addXp(skill, XP);
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
}
|
||||
|
||||
private static PlayerProfile getOfflineProfile(String playerName) {
|
||||
@@ -613,4 +688,14 @@ public final class ExperienceAPI {
|
||||
|
||||
return skill;
|
||||
}
|
||||
|
||||
private static XPGainReason getXPGainReason(String reason) throws InvalidXPGainReasonException {
|
||||
XPGainReason xpGainReason = XPGainReason.getXPGainReason(reason);
|
||||
|
||||
if (xpGainReason == null) {
|
||||
throw new InvalidXPGainReasonException();
|
||||
}
|
||||
|
||||
return xpGainReason;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public final class PartyAPI {
|
||||
}
|
||||
|
||||
public static boolean hasAlly(String partyName) {
|
||||
return PartyManager.getParty(partyName).getAlly() != null;
|
||||
return getAllyName(partyName) != null;
|
||||
}
|
||||
|
||||
public static String getAllyName(String partyName) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidXPGainReasonException extends RuntimeException {
|
||||
private static final long serialVersionUID = 4427052841957931157L;
|
||||
|
||||
public InvalidXPGainReasonException() {
|
||||
super("That is not a valid XPGainReason.");
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -26,11 +27,11 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
profile.addLevels(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -23,11 +24,11 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
|
||||
if (player != null) {
|
||||
UserManager.getPlayer(player).applyXpGain(skill, value);
|
||||
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND);
|
||||
}
|
||||
else {
|
||||
profile.addXp(skill, value);
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -28,7 +29,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
profile.modifySkill(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
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.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -109,11 +110,11 @@ public class SkillresetCommand implements TabExecutor {
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (player == null) {
|
||||
profile.save();
|
||||
profile.scheduleAsyncSave();
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
|
||||
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false, XPGainReason.COMMAND);
|
||||
}
|
||||
|
||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
@@ -56,7 +55,7 @@ public class PartyCommand implements TabExecutor {
|
||||
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private CommandExecutor partyTeleportCommand = mcMMO.p.getCommand("ptp").getExecutor();
|
||||
private CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
||||
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@ public class PtpCommand implements TabExecutor {
|
||||
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
|
||||
@@ -109,9 +115,13 @@ public class PtpCommand implements TabExecutor {
|
||||
|
||||
if (matches.size() == 0) {
|
||||
Player player = (Player) sender;
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
List<String> playerNames = party.getOnlinePlayerNames(player);
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
List<String> playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -26,7 +27,6 @@ public class RepairCommand extends SkillCommand {
|
||||
private boolean canSuperRepair;
|
||||
private boolean canMasterRepair;
|
||||
private boolean canArcaneForge;
|
||||
private boolean canSalvage;
|
||||
private boolean canRepairStone;
|
||||
private boolean canRepairIron;
|
||||
private boolean canRepairGold;
|
||||
@@ -77,14 +77,13 @@ public class RepairCommand extends SkillCommand {
|
||||
canSuperRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SUPER_REPAIR);
|
||||
canMasterRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.REPAIR_MASTERY);
|
||||
canArcaneForge = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARCANE_FORGING);
|
||||
canSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE);
|
||||
canRepairDiamond = Permissions.repairDiamond(player);
|
||||
canRepairGold = Permissions.repairGold(player);
|
||||
canRepairIron = Permissions.repairIron(player);
|
||||
canRepairStone = Permissions.repairStone(player);
|
||||
canRepairString = Permissions.repairString(player);
|
||||
canRepairLeather = Permissions.repairLeather(player);
|
||||
canRepairWood = Permissions.repairWood(player);
|
||||
canRepairDiamond = Permissions.repairMaterialType(player, MaterialType.DIAMOND);
|
||||
canRepairGold = Permissions.repairMaterialType(player, MaterialType.GOLD);
|
||||
canRepairIron = Permissions.repairMaterialType(player, MaterialType.IRON);
|
||||
canRepairStone = Permissions.repairMaterialType(player, MaterialType.STONE);
|
||||
canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING);
|
||||
canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER);
|
||||
canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD);
|
||||
arcaneBypass = Permissions.arcaneBypass(player);
|
||||
}
|
||||
|
||||
@@ -122,10 +121,6 @@ public class RepairCommand extends SkillCommand {
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||
}
|
||||
|
||||
if (canSalvage && Repair.salvageUnlockLevel > 0) {
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SalvageCommand extends SkillCommand {
|
||||
private boolean canAdvancedSalvage;
|
||||
private boolean canArcaneSalvage;
|
||||
|
||||
public SalvageCommand() {
|
||||
super(SkillType.SALVAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canAdvancedSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ADVANCED_SALVAGE);
|
||||
canArcaneSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARCANE_SALVAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> effectsDisplay() {
|
||||
List<String> messages = new ArrayList<String>();
|
||||
|
||||
if (canAdvancedSalvage) {
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Salvage.Effect.0"), LocaleLoader.getString("Salvage.Effect.1")));
|
||||
}
|
||||
|
||||
if (canArcaneSalvage) {
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Salvage.Effect.2"), LocaleLoader.getString("Salvage.Effect.3")));
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
List<String> messages = new ArrayList<String>();
|
||||
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
|
||||
|
||||
if (canAdvancedSalvage) {
|
||||
if (skillValue < Salvage.advancedSalvageUnlockLevel) {
|
||||
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Salvage.Ability.Locked.0", Salvage.advancedSalvageUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Ability.Bonus.0"), LocaleLoader.getString("Salvage.Ability.Bonus.1", percent.format(salvageManager.getMaxSalvagePercentage()))));
|
||||
}
|
||||
}
|
||||
|
||||
if (canArcaneSalvage) {
|
||||
messages.add(LocaleLoader.getString("Salvage.Arcane.Rank", salvageManager.getArcaneSalvageRank(), Salvage.Tier.values().length));
|
||||
|
||||
if (Salvage.arcaneSalvageEnchantLoss) {
|
||||
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100)));
|
||||
}
|
||||
|
||||
if (Salvage.arcaneSalvageDowngrades) {
|
||||
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractPartial"), percent.format(salvageManager.getExtractPartialEnchantChance() / 100)));
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
|
||||
// IRON ARM
|
||||
if (canIronArm) {
|
||||
ironArmBonus = Math.min(3 + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||
ironArmBonus = Math.min(Unarmed.ironArmMinBonusDamage + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||
}
|
||||
|
||||
// IRON GRIP
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
@@ -378,10 +379,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSalvageUnlockLevel() < 0) {
|
||||
reason.add("Skills.Repair.Salvage.UnlockLevel should be at least 0!");
|
||||
}
|
||||
|
||||
List<ArcaneForging.Tier> arcaneForgingTierList = Arrays.asList(ArcaneForging.Tier.values());
|
||||
|
||||
for (ArcaneForging.Tier tier : arcaneForgingTierList) {
|
||||
@@ -414,6 +411,51 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/* SALVAGE */
|
||||
if (getSalvageMaxPercentage() < 1) {
|
||||
reason.add("Skills.Salvage.MaxPercentage should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSalvageMaxPercentageLevel() < 1) {
|
||||
reason.add("Skills.Salvage.MaxPercentageLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getAdvancedSalvageUnlockLevel() < 1) {
|
||||
reason.add("Skills.Salvage.AdvancedSalvage.UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
List<Salvage.Tier> salvageTierList = Arrays.asList(Salvage.Tier.values());
|
||||
|
||||
for (Salvage.Tier tier : salvageTierList) {
|
||||
if (getArcaneSalvageRankLevel(tier) < 0) {
|
||||
reason.add("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
|
||||
}
|
||||
|
||||
if (getArcaneSalvageExtractFullEnchantsChance(tier) < 0 || getArcaneSalvageExtractFullEnchantsChance(tier) > 100) {
|
||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + tier.toNumerical() + " only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneSalvageExtractPartialEnchantsChance(tier) < 0 || getArcaneSalvageExtractPartialEnchantsChance(tier) > 100) {
|
||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + tier.toNumerical() + " only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (tier != Salvage.Tier.EIGHT) {
|
||||
Salvage.Tier nextTier = salvageTierList.get(salvageTierList.indexOf(tier) - 1);
|
||||
|
||||
if (getArcaneSalvageRankLevel(tier) >= getArcaneSalvageRankLevel(nextTier)) {
|
||||
reason.add("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
|
||||
}
|
||||
|
||||
if (getArcaneSalvageExtractFullEnchantsChance(tier) > getArcaneSalvageExtractFullEnchantsChance(nextTier)) {
|
||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + nextTier.toNumerical() + "!");
|
||||
}
|
||||
|
||||
if (getArcaneSalvageExtractPartialEnchantsChance(tier) > getArcaneSalvageExtractPartialEnchantsChance(nextTier)) {
|
||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + nextTier.toNumerical() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* SMELTING */
|
||||
if (getBurnModifierMaxLevel() < 1) {
|
||||
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
||||
@@ -725,7 +767,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
/* REPAIR */
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 1000); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage.UnlockLevel", 600); }
|
||||
|
||||
/* Arcane Forging */
|
||||
public int getArcaneForgingRankLevel(ArcaneForging.Tier tier) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + tier.toNumerical()); }
|
||||
@@ -736,6 +777,19 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
|
||||
public double getArcaneForgingDowngradeChance(ArcaneForging.Tier tier) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + tier.toNumerical()); }
|
||||
|
||||
/* SALVAGE */
|
||||
public double getSalvageMaxPercentage() { return config.getDouble("Skills.Salvage.MaxPercentage", 100.0D); }
|
||||
public int getSalvageMaxPercentageLevel() { return config.getInt("Skills.Salvage.MaxPercentageLevel", 1000); }
|
||||
|
||||
public int getAdvancedSalvageUnlockLevel() { return config.getInt("Skills.Salvage.AdvancedSalvage.UnlockLevel", 350); }
|
||||
|
||||
public boolean getArcaneSalvageEnchantDowngradeEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true); }
|
||||
public boolean getArcaneSalvageEnchantLossEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true); }
|
||||
|
||||
public int getArcaneSalvageRankLevel(Salvage.Tier tier) { return config.getInt("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + tier.toNumerical()); }
|
||||
public double getArcaneSalvageExtractFullEnchantsChance(Salvage.Tier tier) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + tier.toNumerical()); }
|
||||
public double getArcaneSalvageExtractPartialEnchantsChance(Salvage.Tier tier) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + tier.toNumerical()); }
|
||||
|
||||
/* SMELTING */
|
||||
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency.MaxBonusLevel", 1000); }
|
||||
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency.Multiplier", 3.0D); }
|
||||
|
||||
@@ -265,6 +265,11 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||
|
||||
/* Scoreboards */
|
||||
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
||||
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
||||
public boolean getShowStatsAfterLogin() { return config.getBoolean("Scoreboard.Show_Stats_After_Login", false); }
|
||||
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
||||
|
||||
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
||||
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
||||
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
||||
@@ -290,11 +295,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
|
||||
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
|
||||
|
||||
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
||||
|
||||
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
||||
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
||||
@@ -447,10 +447,12 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
/* Alchemy */
|
||||
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
|
||||
public boolean getPreventHopperTransfer() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer", false); }
|
||||
public boolean getPreventHopperTransferIngredients() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer_Ingredients", false); }
|
||||
public boolean getPreventHopperTransferBottles() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer_Bottles", false); }
|
||||
|
||||
/* Fishing */
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
|
||||
|
||||
/* Mining */
|
||||
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
||||
@@ -460,11 +462,15 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
|
||||
public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
|
||||
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
|
||||
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_Material", "GOLD_BLOCK")); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
|
||||
|
||||
/* Salvage */
|
||||
public boolean getSalvageAnvilMessagesEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Messages", true); }
|
||||
public boolean getSalvageAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Placed_Sounds", true); }
|
||||
public boolean getSalvageAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Use_Sounds", true); }
|
||||
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Salvage.Anvil_Material", "GOLD_BLOCK")); }
|
||||
public boolean getSalvageConfirmRequired() { return config.getBoolean("Skills.Salvage.Confirm_Required", true); }
|
||||
|
||||
/* Unarmed */
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
@@ -164,7 +164,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
/* Curve values */
|
||||
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
|
||||
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
|
||||
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) +"_Values.exponent"); }
|
||||
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
|
||||
|
||||
/* Global modifier */
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
|
||||
@@ -216,7 +216,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/* Repair */
|
||||
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
||||
public double getRepairXP(RepairMaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
|
||||
|
||||
@@ -9,11 +9,11 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
@@ -79,7 +79,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
|
||||
if (repairable) {
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
|
||||
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
||||
int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
||||
|
||||
if (repairQuantity == 0) {
|
||||
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
||||
@@ -91,7 +91,7 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
||||
}
|
||||
|
||||
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
|
||||
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, 1.0));
|
||||
}
|
||||
|
||||
materialList.add(armorMaterial);
|
||||
|
||||
@@ -68,39 +68,61 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||
|
||||
if (blockMaterial == null) {
|
||||
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
|
||||
plugin.getLogger().warning("Invalid material name. [" + blockInfo[0] + "] This item will be skipped. - " + blockName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockInfo.length == 2) {
|
||||
String[] dataInfo = blockInfo[1].split("[-]");
|
||||
|
||||
if (dataInfo.length == 2) {
|
||||
byte startData = Byte.valueOf(dataInfo[0]);
|
||||
byte endData = Byte.valueOf(dataInfo[1]);
|
||||
System.out.println(blockName + " Data range; [" + startData + " - " + endData + "]");
|
||||
|
||||
for (byte blockData = startData; blockData <= endData; blockData++) {
|
||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||
loadBlock(skillType, blockList, blockName, blockMaterialData);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
||||
|
||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||
|
||||
if (blockList != null) {
|
||||
blockList.add(blockMaterialData);
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||
int smeltingXp = 0;
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterialData);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockMaterialData);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockMaterialData);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
loadBlock(skillType, blockList, blockName, blockMaterialData);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlock(String skillType, List<MaterialData> blockList, String blockName, MaterialData blockMaterialData) {
|
||||
System.out.println("Loading block: " + blockMaterialData.getItemType() + " " + blockMaterialData.getData());
|
||||
if (blockList != null) {
|
||||
blockList.add(blockMaterialData);
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
return;
|
||||
}
|
||||
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||
int smeltingXp = 0;
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterialData);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockMaterialData);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockMaterialData);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
@@ -87,7 +87,7 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
|
||||
if (repairable) {
|
||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
|
||||
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
|
||||
int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
|
||||
|
||||
if (repairQuantity == 0) {
|
||||
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
|
||||
@@ -99,7 +99,7 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
||||
}
|
||||
|
||||
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.OTHER, 1.0));
|
||||
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, 1.0));
|
||||
}
|
||||
|
||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||
|
||||
@@ -9,12 +9,12 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private List<Repairable> repairables;
|
||||
@@ -48,37 +48,37 @@ public class RepairConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
// Repair Material Type
|
||||
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
|
||||
MaterialType repairMaterialType = MaterialType.OTHER;
|
||||
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
|
||||
|
||||
if (!config.contains("Repairables." + key + ".MaterialType") && itemMaterial != null) {
|
||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||
|
||||
if (ItemUtils.isWoodTool(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.WOOD;
|
||||
repairMaterialType = MaterialType.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.STONE;
|
||||
repairMaterialType = MaterialType.STONE;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.STRING;
|
||||
repairMaterialType = MaterialType.STRING;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.LEATHER;
|
||||
repairMaterialType = MaterialType.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.IRON;
|
||||
repairMaterialType = MaterialType.IRON;
|
||||
}
|
||||
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.GOLD;
|
||||
repairMaterialType = MaterialType.GOLD;
|
||||
}
|
||||
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
||||
repairMaterialType = RepairMaterialType.DIAMOND;
|
||||
repairMaterialType = MaterialType.DIAMOND;
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
|
||||
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
@@ -87,7 +87,7 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
// Repair Material
|
||||
String repairMaterialName = config.getString("Repairables." + key + ".RepairMaterial");
|
||||
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultRepairMaterial() : Material.matchMaterial(repairMaterialName));
|
||||
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
|
||||
|
||||
if (repairMaterial == null) {
|
||||
reason.add(key + " has an invalid repair material: " + repairMaterialName);
|
||||
@@ -105,22 +105,22 @@ public class RepairConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
// Item Type
|
||||
RepairItemType repairItemType = RepairItemType.OTHER;
|
||||
ItemType repairItemType = ItemType.OTHER;
|
||||
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
|
||||
|
||||
if (!config.contains("Repairables." + key + ".ItemType") && itemMaterial != null) {
|
||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||
|
||||
if (ItemUtils.isMinecraftTool(repairItem)) {
|
||||
repairItemType = RepairItemType.TOOL;
|
||||
repairItemType = ItemType.TOOL;
|
||||
}
|
||||
else if (ItemUtils.isArmor(repairItem)) {
|
||||
repairItemType = RepairItemType.ARMOR;
|
||||
repairItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
repairItemType = RepairItemType.valueOf(repairItemTypeString);
|
||||
repairItemType = ItemType.valueOf(repairItemTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
@@ -136,7 +136,7 @@ public class RepairConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
// Minimum Quantity
|
||||
int minimumQuantity = (itemMaterial != null ? Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity", 2));
|
||||
int minimumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity", 2));
|
||||
|
||||
if (minimumQuantity <= 0 && itemMaterial != null) {
|
||||
minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SalvageConfig extends ConfigLoader {
|
||||
private List<Salvageable> salvageables;
|
||||
|
||||
public SalvageConfig(String fileName) {
|
||||
super(fileName);
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
salvageables = new ArrayList<Salvageable>();
|
||||
|
||||
ConfigurationSection section = config.getConfigurationSection("Salvageables");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
for (String key : keys) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
// Item Material
|
||||
Material itemMaterial = Material.matchMaterial(key);
|
||||
|
||||
if (itemMaterial == null) {
|
||||
reason.add("Invalid material: " + key);
|
||||
}
|
||||
|
||||
// Salvage Material Type
|
||||
MaterialType salvageMaterialType = MaterialType.OTHER;
|
||||
String salvageMaterialTypeString = config.getString("Salvageables." + key + ".MaterialType", "OTHER");
|
||||
|
||||
if (!config.contains("Salvageables." + key + ".MaterialType") && itemMaterial != null) {
|
||||
ItemStack salvageItem = new ItemStack(itemMaterial);
|
||||
|
||||
if (ItemUtils.isWoodTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.STONE;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.STRING;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.IRON;
|
||||
}
|
||||
else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.GOLD;
|
||||
}
|
||||
else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
||||
salvageMaterialType = MaterialType.DIAMOND;
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
// Salvage Material
|
||||
String salvageMaterialName = config.getString("Salvageables." + key + ".SalvageMaterial");
|
||||
Material salvageMaterial = (salvageMaterialName == null ? salvageMaterialType.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName));
|
||||
|
||||
if (salvageMaterial == null) {
|
||||
reason.add(key + " has an invalid salvage material: " + salvageMaterialName);
|
||||
}
|
||||
|
||||
// Maximum Durability
|
||||
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Salvageables." + key + ".MaximumDurability"));
|
||||
|
||||
// Item Type
|
||||
ItemType salvageItemType = ItemType.OTHER;
|
||||
String salvageItemTypeString = config.getString("Salvageables." + key + ".ItemType", "OTHER");
|
||||
|
||||
if (!config.contains("Salvageables." + key + ".ItemType") && itemMaterial != null) {
|
||||
ItemStack salvageItem = new ItemStack(itemMaterial);
|
||||
|
||||
if (ItemUtils.isMinecraftTool(salvageItem)) {
|
||||
salvageItemType = ItemType.TOOL;
|
||||
}
|
||||
else if (ItemUtils.isArmor(salvageItem)) {
|
||||
salvageItemType = ItemType.ARMOR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
salvageItemType = ItemType.valueOf(salvageItemTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
byte salvageMetadata = (byte) config.getInt("Salvageables." + key + ".SalvageMaterialMetadata", -1);
|
||||
int minimumLevel = config.getInt("Salvageables." + key + ".MinimumLevel");
|
||||
double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1);
|
||||
|
||||
if (minimumLevel < 0) {
|
||||
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
}
|
||||
|
||||
// Maximum Quantity
|
||||
int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata) : config.getInt("Salvageables." + key + ".MaximumQuantity", 2));
|
||||
|
||||
if (maximumQuantity <= 0 && itemMaterial != null) {
|
||||
maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", 2);
|
||||
}
|
||||
|
||||
int configMaximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", -1);
|
||||
|
||||
if (configMaximumQuantity > 0) {
|
||||
maximumQuantity = configMaximumQuantity;
|
||||
}
|
||||
|
||||
if (maximumQuantity <= 0) {
|
||||
reason.add("Maximum quantity of " + key + " must be greater than 0!");
|
||||
}
|
||||
|
||||
if (noErrorsInSalvageable(reason)) {
|
||||
Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier);
|
||||
salvageables.add(salvageable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables == null ? new ArrayList<Salvageable>() : salvageables;
|
||||
}
|
||||
|
||||
private boolean noErrorsInSalvageable(List<String> issues) {
|
||||
if (!issues.isEmpty()) {
|
||||
plugin.getLogger().warning("Errors have been found in: " + fileName);
|
||||
plugin.getLogger().warning("The following issues were found:");
|
||||
}
|
||||
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
|
||||
return issues.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
|
||||
public class SalvageConfigManager {
|
||||
private final List<Salvageable> salvageables = new ArrayList<Salvageable>();
|
||||
|
||||
public SalvageConfigManager(mcMMO plugin) {
|
||||
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "salvage.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("salvage.vanilla.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SalvageConfig salvageConfig = new SalvageConfig(fileName);
|
||||
salvageables.addAll(salvageConfig.getLoadedSalvageables());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Salvageable> getLoadedSalvageables() {
|
||||
return salvageables;
|
||||
}
|
||||
}
|
||||
@@ -158,26 +158,29 @@ public class TreasureConfig extends ConfigLoader {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
String[] treasureInfo = treasureName.split("[|]");
|
||||
String materialName = treasureInfo[0];
|
||||
|
||||
/*
|
||||
* Material, Amount, and Data
|
||||
*/
|
||||
Material material;
|
||||
|
||||
if (treasureName.contains("POTION")) {
|
||||
if (materialName.contains("POTION")) {
|
||||
material = Material.POTION;
|
||||
}
|
||||
else if (treasureName.contains("INK_SACK")) {
|
||||
else if (materialName.contains("INK_SACK")) {
|
||||
material = Material.INK_SACK;
|
||||
}
|
||||
else {
|
||||
material = Material.matchMaterial(treasureName);
|
||||
material = Material.matchMaterial(materialName);
|
||||
}
|
||||
|
||||
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
||||
int data = config.getInt(type + "." + treasureName + ".Data");
|
||||
short data = (treasureInfo.length == 2) ? Byte.valueOf(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||
|
||||
if (material == null) {
|
||||
reason.add("Invalid material: " + treasureName);
|
||||
reason.add("Invalid material: " + materialName);
|
||||
}
|
||||
|
||||
if (amount <= 0) {
|
||||
@@ -226,8 +229,8 @@ public class TreasureConfig extends ConfigLoader {
|
||||
*/
|
||||
ItemStack item = null;
|
||||
|
||||
if (treasureName.contains("POTION")) {
|
||||
String potionType = treasureName.substring(7);
|
||||
if (materialName.contains("POTION")) {
|
||||
String potionType = materialName.substring(7);
|
||||
|
||||
try {
|
||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
||||
@@ -236,8 +239,8 @@ public class TreasureConfig extends ConfigLoader {
|
||||
reason.add("Invalid Potion_Type: " + potionType);
|
||||
}
|
||||
}
|
||||
else if (treasureName.contains("INK_SACK")) {
|
||||
String color = treasureName.substring(9);
|
||||
else if (materialName.contains("INK_SACK")) {
|
||||
String color = materialName.substring(9);
|
||||
|
||||
try {
|
||||
Dye dye = new Dye();
|
||||
@@ -250,7 +253,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
else if (material != null) {
|
||||
item = new ItemStack(material, amount, (short) data);
|
||||
item = new ItemStack(material, amount, data);
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
@@ -185,7 +185,7 @@ public class Party {
|
||||
|
||||
public String getXpToLevelPercentage() {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
return percent.format( this.getXp() / getXpToLevel());
|
||||
return percent.format(this.getXp() / getXpToLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
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.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
@@ -40,6 +41,7 @@ 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.RepairManager;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
@@ -223,6 +225,10 @@ public class McMMOPlayer {
|
||||
return (RepairManager) skillManagers.get(SkillType.REPAIR);
|
||||
}
|
||||
|
||||
public SalvageManager getSalvageManager() {
|
||||
return (SalvageManager) skillManagers.get(SkillType.SALVAGE);
|
||||
}
|
||||
|
||||
public SmeltingManager getSmeltingManager() {
|
||||
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
||||
}
|
||||
@@ -453,7 +459,7 @@ public class McMMOPlayer {
|
||||
* @param skill Skill being used
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginXpGain(SkillType skill, float xp) {
|
||||
public void beginXpGain(SkillType skill, float xp, XPGainReason xpGainReason) {
|
||||
Validate.isTrue(xp >= 0.0, "XP gained should be greater than or equal to zero.");
|
||||
|
||||
if (xp <= 0.0) {
|
||||
@@ -466,7 +472,7 @@ public class McMMOPlayer {
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
if (parentSkill.getPermissions(player)) {
|
||||
beginXpGain(parentSkill, splitXp);
|
||||
beginXpGain(parentSkill, splitXp, xpGainReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,11 +480,11 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
// Return if the experience has been shared
|
||||
if (party != null && ShareHandler.handleXpShare(xp, this, skill)) {
|
||||
if (party != null && ShareHandler.handleXpShare(xp, this, skill, ShareHandler.getSharedXpGainReason(xpGainReason))) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginUnsharedXpGain(skill, xp);
|
||||
beginUnsharedXpGain(skill, xp, xpGainReason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,8 +493,8 @@ public class McMMOPlayer {
|
||||
* @param skill Skill being used
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginUnsharedXpGain(SkillType skill, float xp) {
|
||||
applyXpGain(skill, modifyXpGain(skill, xp));
|
||||
public void beginUnsharedXpGain(SkillType skill, float xp, XPGainReason xpGainReason) {
|
||||
applyXpGain(skill, modifyXpGain(skill, xp), xpGainReason);
|
||||
|
||||
if (party == null) {
|
||||
return;
|
||||
@@ -505,7 +511,7 @@ public class McMMOPlayer {
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(SkillType skillType, float xp) {
|
||||
public void applyXpGain(SkillType skillType, float xp, XPGainReason xpGainReason) {
|
||||
if (!skillType.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -514,18 +520,18 @@ public class McMMOPlayer {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
applyXpGain(parentSkill, xp / parentSkills.size());
|
||||
applyXpGain(parentSkill, xp / parentSkills.size(), xpGainReason);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
|
||||
if (!EventUtils.handleXpGainEvent(player, skillType, xp, xpGainReason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
isUsingUnarmed = (skillType == SkillType.UNARMED);
|
||||
checkXp(skillType);
|
||||
checkXp(skillType, xpGainReason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,7 +539,7 @@ public class McMMOPlayer {
|
||||
*
|
||||
* @param skillType The skill to check
|
||||
*/
|
||||
private void checkXp(SkillType skillType) {
|
||||
private void checkXp(SkillType skillType, XPGainReason xpGainReason) {
|
||||
if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
|
||||
return;
|
||||
}
|
||||
@@ -551,7 +557,7 @@ public class McMMOPlayer {
|
||||
levelsGained++;
|
||||
}
|
||||
|
||||
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
|
||||
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -19,7 +20,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
public class PlayerProfile {
|
||||
private final String playerName;
|
||||
private boolean loaded;
|
||||
private boolean changed;
|
||||
private volatile boolean changed;
|
||||
|
||||
/* HUDs */
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
@@ -60,12 +61,18 @@ public class PlayerProfile {
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public void scheduleAsyncSave() {
|
||||
new PlayerProfileSaveTask(this).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!changed || !loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(new PlayerProfile(playerName, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType));
|
||||
// TODO should this part be synchronized?
|
||||
PlayerProfile profileCopy = new PlayerProfile(playerName, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType);
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||
|
||||
if (changed) {
|
||||
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
public enum ItemType {
|
||||
ARMOR,
|
||||
TOOL,
|
||||
OTHER;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum MaterialType {
|
||||
STRING,
|
||||
LEATHER,
|
||||
WOOD,
|
||||
STONE,
|
||||
IRON,
|
||||
GOLD,
|
||||
DIAMOND,
|
||||
OTHER;
|
||||
|
||||
public Material getDefaultMaterial() {
|
||||
switch (this) {
|
||||
case STRING:
|
||||
return Material.STRING;
|
||||
|
||||
case LEATHER:
|
||||
return Material.LEATHER;
|
||||
|
||||
case WOOD:
|
||||
return Material.WOOD;
|
||||
|
||||
case STONE:
|
||||
return Material.COBBLESTONE;
|
||||
|
||||
case IRON:
|
||||
return Material.IRON_INGOT;
|
||||
|
||||
case GOLD:
|
||||
return Material.GOLD_INGOT;
|
||||
|
||||
case DIAMOND:
|
||||
return Material.DIAMOND;
|
||||
|
||||
case OTHER:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,12 @@ public enum SecondaryAbility {
|
||||
/* Repair */
|
||||
ARCANE_FORGING,
|
||||
REPAIR_MASTERY,
|
||||
SALVAGE,
|
||||
SUPER_REPAIR,
|
||||
|
||||
/* Salvage */
|
||||
ADVANCED_SALVAGE,
|
||||
ARCANE_SALVAGE,
|
||||
|
||||
/* Smelting */
|
||||
FLUX_MINING,
|
||||
FUEL_EFFICIENCY,
|
||||
|
||||
@@ -23,6 +23,7 @@ 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.RepairManager;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
@@ -43,7 +44,8 @@ public enum SkillType {
|
||||
FISHING(FishingManager.class, Color.NAVY, ImmutableList.of(SecondaryAbility.FISHERMANS_DIET, SecondaryAbility.FISHING_TREASURE_HUNTER, SecondaryAbility.ICE_FISHING, SecondaryAbility.MAGIC_HUNTER, SecondaryAbility.MASTER_ANGLER, SecondaryAbility.SHAKE)),
|
||||
HERBALISM(HerbalismManager.class, Color.GREEN, AbilityType.GREEN_TERRA, ToolType.HOE, ImmutableList.of(SecondaryAbility.FARMERS_DIET, SecondaryAbility.GREEN_THUMB_PLANT, SecondaryAbility.GREEN_THUMB_BLOCK, SecondaryAbility.HERBALISM_DOUBLE_DROPS, SecondaryAbility.HYLIAN_LUCK, SecondaryAbility.SHROOM_THUMB)),
|
||||
MINING(MiningManager.class, Color.GRAY, AbilityType.SUPER_BREAKER, ToolType.PICKAXE, ImmutableList.of(SecondaryAbility.MINING_DOUBLE_DROPS)),
|
||||
REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SecondaryAbility.ARCANE_FORGING, SecondaryAbility.REPAIR_MASTERY, SecondaryAbility.SALVAGE, SecondaryAbility.SUPER_REPAIR)),
|
||||
REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SecondaryAbility.ARCANE_FORGING, SecondaryAbility.REPAIR_MASTERY, SecondaryAbility.SUPER_REPAIR)),
|
||||
SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SecondaryAbility.ADVANCED_SALVAGE, SecondaryAbility.ARCANE_SALVAGE)),
|
||||
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SecondaryAbility.FLUX_MINING, SecondaryAbility.FUEL_EFFICIENCY, SecondaryAbility.SECOND_SMELT)),
|
||||
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
|
||||
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIROMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR)),
|
||||
@@ -63,7 +65,7 @@ public enum SkillType {
|
||||
|
||||
public static final List<SkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
|
||||
public static final List<SkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
|
||||
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SMELTING);
|
||||
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SALVAGE, SMELTING);
|
||||
|
||||
static {
|
||||
List<SkillType> childSkills = new ArrayList<SkillType>();
|
||||
@@ -182,6 +184,7 @@ public enum SkillType {
|
||||
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
|
||||
public boolean isChildSkill() {
|
||||
switch (this) {
|
||||
case SALVAGE:
|
||||
case SMELTING:
|
||||
return true;
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
public enum XPGainReason {
|
||||
PVP,
|
||||
PVE,
|
||||
VAMPIRISM,
|
||||
SHARED_PVP,
|
||||
SHARED_PVE,
|
||||
COMMAND,
|
||||
UNKNOWN;
|
||||
|
||||
public static XPGainReason getXPGainReason(String reason) {
|
||||
for (XPGainReason type : values()) {
|
||||
if (type.name().equalsIgnoreCase(reason)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
/**
|
||||
@@ -15,11 +16,21 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
||||
private boolean cancelled;
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
protected XPGainReason xpGainReason;
|
||||
|
||||
@Deprecated
|
||||
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||
this.xpGainReason = XPGainReason.UNKNOWN;
|
||||
}
|
||||
|
||||
protected McMMOPlayerExperienceEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||
this.xpGainReason = xpGainReason;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,6 +47,13 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The combat type involved in this event
|
||||
*/
|
||||
public XPGainReason getXpGainReason() {
|
||||
return xpGainReason;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@@ -3,12 +3,18 @@ package com.gmail.nossr50.events.experience;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
|
||||
/**
|
||||
* Called when a user levels change
|
||||
*/
|
||||
public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent {
|
||||
@Deprecated
|
||||
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
super(player, skill, XPGainReason.UNKNOWN);
|
||||
}
|
||||
|
||||
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||
super(player, skill, xpGainReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.events.experience;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
|
||||
/**
|
||||
* Called when a user loses levels in a skill
|
||||
@@ -10,13 +11,25 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
|
||||
private int levelsLost;
|
||||
|
||||
@Deprecated
|
||||
public McMMOPlayerLevelDownEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
super(player, skill, XPGainReason.UNKNOWN);
|
||||
this.levelsLost = 1;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost) {
|
||||
super(player, skill);
|
||||
super(player, skill, XPGainReason.UNKNOWN);
|
||||
this.levelsLost = levelsLost;
|
||||
}
|
||||
|
||||
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||
super(player, skill, xpGainReason);
|
||||
this.levelsLost = 1;
|
||||
}
|
||||
|
||||
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost, XPGainReason xpGainReason) {
|
||||
super(player, skill, xpGainReason);
|
||||
this.levelsLost = levelsLost;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.events.experience;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
|
||||
/**
|
||||
* Called when a user levels up in a skill
|
||||
@@ -10,13 +11,25 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
|
||||
private int levelsGained;
|
||||
|
||||
@Deprecated
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
super(player, skill, XPGainReason.UNKNOWN);
|
||||
this.levelsGained = 1;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
|
||||
super(player, skill);
|
||||
super(player, skill, XPGainReason.UNKNOWN);
|
||||
this.levelsGained = levelsGained;
|
||||
}
|
||||
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||
super(player, skill, xpGainReason);
|
||||
this.levelsGained = 1;
|
||||
}
|
||||
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained, XPGainReason xpGainReason) {
|
||||
super(player, skill, xpGainReason);
|
||||
this.levelsGained = levelsGained;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.events.experience;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
|
||||
/**
|
||||
* Called when a player gains XP in a skill
|
||||
@@ -10,8 +11,14 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
|
||||
private float xpGained;
|
||||
|
||||
@Deprecated
|
||||
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained) {
|
||||
super(player, skill);
|
||||
super(player, skill, XPGainReason.UNKNOWN);
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained, XPGainReason xpGainReason) {
|
||||
super(player, skill, xpGainReason);
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ import org.bukkit.event.entity.EntityTameEvent;
|
||||
*/
|
||||
public class FakeEntityTameEvent extends EntityTameEvent {
|
||||
public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) {
|
||||
super (entity, owner);
|
||||
super(entity, owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,11 @@ import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
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.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
@@ -120,8 +123,13 @@ public class BlockListener implements Listener {
|
||||
mcMMO.getPlaceStore().setTrue(blockState);
|
||||
}
|
||||
|
||||
if (BlockUtils.isMcMMOAnvil(blockState)) {
|
||||
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getType());
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (blockState.getType() == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player)) {
|
||||
mcMMOPlayer.getRepairManager().placedAnvilCheck();
|
||||
}
|
||||
else if (blockState.getType() == Salvage.anvilMaterial && SkillType.SALVAGE.getPermissions(player)) {
|
||||
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +235,11 @@ public class BlockListener implements Listener {
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (Herbalism.isRecentlyRegrown(blockState)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemUtils.isSword(heldItem)) {
|
||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -31,6 +32,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -75,7 +77,9 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBow().containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
ItemStack bow = event.getBow();
|
||||
|
||||
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
|
||||
}
|
||||
|
||||
@@ -121,6 +125,9 @@ public class EntityListener implements Listener {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
}
|
||||
}
|
||||
else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
@@ -51,7 +51,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
Block furnaceBlock = processInventoryOpenorCloseEvent(event.getInventory());
|
||||
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
|
||||
|
||||
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||
return;
|
||||
@@ -68,7 +68,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
Block furnaceBlock = processInventoryOpenorCloseEvent(event.getInventory());
|
||||
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
|
||||
|
||||
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||
return;
|
||||
@@ -295,7 +295,12 @@ public class InventoryListener implements Listener {
|
||||
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if (Config.getInstance().getPreventHopperTransfer() && item.getType() != Material.POTION) {
|
||||
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -327,7 +332,7 @@ public class InventoryListener implements Listener {
|
||||
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
|
||||
}
|
||||
|
||||
private Block processInventoryOpenorCloseEvent(Inventory inventory) {
|
||||
private Block processInventoryOpenOrCloseEvent(Inventory inventory) {
|
||||
if (!(inventory instanceof FurnaceInventory)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,16 +37,18 @@ import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
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.RepairManager;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
@@ -353,7 +355,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
BleedTimerTask.bleedOut(player);
|
||||
mcMMOPlayer.getProfile().save();
|
||||
mcMMOPlayer.getProfile().scheduleAsyncSave();
|
||||
UserManager.remove(player);
|
||||
ScoreboardManager.teardownPlayer(player);
|
||||
}
|
||||
@@ -391,6 +393,11 @@ public class PlayerListener implements Listener {
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getShowStatsAfterLogin()) {
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,24 +444,24 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||
/* REPAIR CHECKS */
|
||||
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
event.setCancelled(true);
|
||||
|
||||
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(true)) {
|
||||
repairManager.handleRepair(heldItem);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (type == Repair.salvageAnvilMaterial && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE) && Repair.isSalvageable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
else if (type == Salvage.anvilMaterial && SkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
|
||||
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
|
||||
event.setCancelled(true);
|
||||
|
||||
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
|
||||
repairManager.handleSalvage(block.getLocation(), heldItem);
|
||||
if (!(heldItem.getEnchantments().size() > 0) || salvageManager.checkConfirmation(true)) {
|
||||
salvageManager.handleSalvage(block.getLocation(), heldItem);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
@@ -476,22 +483,22 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||
/* REPAIR CHECKS */
|
||||
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
// Cancel repairing an enchanted item
|
||||
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||
repairManager.setLastAnvilUse(Repair.repairAnvilMaterial, 0);
|
||||
if (repairManager.checkConfirmation(false)) {
|
||||
repairManager.setLastAnvilUse(0);
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||
}
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (type == Repair.salvageAnvilMaterial && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE) && Repair.isSalvageable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
else if (type == Salvage.anvilMaterial && SkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
|
||||
SalvageManager salvageManager = mcMMOPlayer.getSalvageManager();
|
||||
|
||||
// Cancel salvaging an enchanted item
|
||||
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||
repairManager.setLastAnvilUse(Repair.salvageAnvilMaterial, 0);
|
||||
if (salvageManager.checkConfirmation(false)) {
|
||||
salvageManager.setLastAnvilUse(0);
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||
}
|
||||
}
|
||||
@@ -623,7 +630,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.gmail.nossr50.config.mods.EntityConfigManager;
|
||||
import com.gmail.nossr50.config.mods.ToolConfigManager;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
@@ -29,11 +30,11 @@ import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.SelfListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.CheckDateTask;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.UpdaterResultAsyncTask;
|
||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||
@@ -44,6 +45,9 @@ import com.gmail.nossr50.skills.child.ChildConfig;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.HolidayManager;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
@@ -57,19 +61,17 @@ import com.gmail.nossr50.util.experience.FormulaManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater;
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateResult;
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateType;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
/* Managers */
|
||||
private static ChunkManager placeStore;
|
||||
private static RepairableManager repairableManager;
|
||||
private static ModManager modManager;
|
||||
private static DatabaseManager databaseManager;
|
||||
private static FormulaManager formulaManager;
|
||||
private static HolidayManager holidayManager;
|
||||
private static ChunkManager placeStore;
|
||||
private static RepairableManager repairableManager;
|
||||
private static SalvageableManager salvageableManager;
|
||||
private static ModManager modManager;
|
||||
private static DatabaseManager databaseManager;
|
||||
private static FormulaManager formulaManager;
|
||||
private static HolidayManager holidayManager;
|
||||
|
||||
/* File Paths */
|
||||
private static String mainDirectory;
|
||||
@@ -86,7 +88,6 @@ public class mcMMO extends JavaPlugin {
|
||||
private boolean updateAvailable;
|
||||
|
||||
/* Plugin Checks */
|
||||
private static boolean combatTagEnabled;
|
||||
private static boolean healthBarPluginEnabled;
|
||||
|
||||
// Config Validation Check
|
||||
@@ -110,6 +111,7 @@ public class mcMMO extends JavaPlugin {
|
||||
public final static String customDamageKey = "mcMMO: Custom Damage";
|
||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||
public final static String playerDataKey = "mcMMO: Player Data";
|
||||
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
|
||||
@@ -124,7 +126,6 @@ public class mcMMO extends JavaPlugin {
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
combatTagEnabled = pluginManager.getPlugin("CombatTag") != null;
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
|
||||
setupFilePaths();
|
||||
@@ -202,6 +203,7 @@ public class mcMMO extends JavaPlugin {
|
||||
try {
|
||||
Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
|
||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||
UserManager.clearAll();
|
||||
PartyManager.saveParties(); // Save our parties
|
||||
ScoreboardManager.teardownAll();
|
||||
formulaManager.saveFormula();
|
||||
@@ -258,6 +260,10 @@ public class mcMMO extends JavaPlugin {
|
||||
return updateAvailable;
|
||||
}
|
||||
|
||||
public void setUpdateAvailable(boolean available) {
|
||||
this.updateAvailable = available;
|
||||
}
|
||||
|
||||
public boolean isXPEventEnabled() {
|
||||
return xpEventEnabled;
|
||||
}
|
||||
@@ -290,6 +296,10 @@ public class mcMMO extends JavaPlugin {
|
||||
return repairableManager;
|
||||
}
|
||||
|
||||
public static SalvageableManager getSalvageableManager() {
|
||||
return salvageableManager;
|
||||
}
|
||||
|
||||
public static DatabaseManager getDatabaseManager() {
|
||||
return databaseManager;
|
||||
}
|
||||
@@ -303,10 +313,6 @@ public class mcMMO extends JavaPlugin {
|
||||
mcMMO.databaseManager = databaseManager;
|
||||
}
|
||||
|
||||
public static boolean isCombatTagEnabled() {
|
||||
return combatTagEnabled;
|
||||
}
|
||||
|
||||
public static boolean isHealthBarPluginEnabled() {
|
||||
return healthBarPluginEnabled;
|
||||
}
|
||||
@@ -377,21 +383,7 @@ public class mcMMO extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);
|
||||
|
||||
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
|
||||
this.updateAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
||||
this.updateAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateAvailable = true;
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||
new UpdaterResultAsyncTask(this).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
private void loadConfigFiles() {
|
||||
@@ -403,6 +395,7 @@ public class mcMMO extends JavaPlugin {
|
||||
new ChildConfig();
|
||||
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
List<Salvageable> salvageables = new ArrayList<Salvageable>();
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
new ToolConfigManager(this);
|
||||
@@ -425,6 +418,12 @@ public class mcMMO extends JavaPlugin {
|
||||
repairables.addAll(modManager.getLoadedRepairables());
|
||||
repairableManager = new SimpleRepairableManager(repairables.size());
|
||||
repairableManager.registerRepairables(repairables);
|
||||
|
||||
// Load salvage configs, make manager and register them at this time
|
||||
SalvageConfigManager sManager = new SalvageConfigManager(this);
|
||||
salvageables.addAll(sManager.getLoadedSalvageables());
|
||||
salvageableManager = new SimpleSalvageableManager(salvageables.size());
|
||||
salvageableManager.registerSalvageables(salvageables);
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -27,7 +28,7 @@ public final class ShareHandler {
|
||||
* @param skillType Skill being used
|
||||
* @return True is the xp has been shared
|
||||
*/
|
||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType, XPGainReason xpGainReason) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getXpShareMode() != ShareMode.EQUAL) {
|
||||
@@ -47,7 +48,7 @@ public final class ShareHandler {
|
||||
float splitXp = (float) (xp / partySize * shareBonus);
|
||||
|
||||
for (Player member : nearMembers) {
|
||||
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
|
||||
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp, xpGainReason);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -142,6 +143,18 @@ public final class ShareHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {
|
||||
if (xpGainReason == XPGainReason.PVE) {
|
||||
return XPGainReason.SHARED_PVE;
|
||||
}
|
||||
else if (xpGainReason == XPGainReason.PVP) {
|
||||
return XPGainReason.SHARED_PVP;
|
||||
}
|
||||
else {
|
||||
return xpGainReason;
|
||||
}
|
||||
}
|
||||
|
||||
private static void awardDrop(Player winningPlayer, ItemStack drop) {
|
||||
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
|
||||
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), drop);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import net.gravitydevelopment.updater.mcmmo.Updater;
|
||||
|
||||
public class UpdaterResultAsyncTask extends BukkitRunnable {
|
||||
private mcMMO plugin;
|
||||
|
||||
public UpdaterResultAsyncTask(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Updater updater = new Updater(plugin, 31030, plugin.mcmmo, Updater.UpdateType.NO_DOWNLOAD, false);
|
||||
|
||||
if (updater.getResult() != Updater.UpdateResult.UPDATE_AVAILABLE) {
|
||||
plugin.setUpdateAvailable(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
||||
plugin.setUpdateAvailable(false);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.setUpdateAvailable(true);
|
||||
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class McScoreboardKeepTask extends BukkitRunnable {
|
||||
private Player player;
|
||||
|
||||
public McScoreboardKeepTask(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.isValid() && ScoreboardManager.isBoardShown(player.getName())) {
|
||||
ScoreboardManager.keepBoard(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
displayBoard();
|
||||
}
|
||||
|
||||
if (useChat){
|
||||
if (useChat) {
|
||||
displayChat();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,5 @@ public class DatabaseConversionTask extends BukkitRunnable {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ public class FormulaConversionTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
editValues(profile);
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
// Since this is a temporary profile, we save it here.
|
||||
profile.scheduleAsyncSave();
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
package com.gmail.nossr50.runnables.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -5,19 +5,22 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
|
||||
public class AwardCombatXpTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private double baseXp;
|
||||
private SkillType skillType;
|
||||
private LivingEntity target;
|
||||
private XPGainReason xpGainReason;
|
||||
private double baseHealth;
|
||||
|
||||
public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target, XPGainReason xpGainReason) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
this.skillType = skillType;
|
||||
this.baseXp = baseXp;
|
||||
this.target = target;
|
||||
this.xpGainReason = xpGainReason;
|
||||
baseHealth = target.getHealth();
|
||||
}
|
||||
|
||||
@@ -36,6 +39,6 @@ public class AwardCombatXpTask extends BukkitRunnable {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
mcMMOPlayer.beginXpGain(skillType, (int) (damage * baseXp));
|
||||
mcMMOPlayer.beginXpGain(skillType, (int) (damage * baseXp), xpGainReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BleedTimerTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Iterator<Entry<LivingEntity, Integer>> bleedIterator = bleedList.entrySet().iterator(); bleedIterator.hasNext();) {
|
||||
for (Iterator<Entry<LivingEntity, Integer>> bleedIterator = bleedList.entrySet().iterator(); bleedIterator.hasNext(); ) {
|
||||
Entry<LivingEntity, Integer> entry = bleedIterator.next();
|
||||
LivingEntity entity = entry.getKey();
|
||||
|
||||
@@ -107,4 +107,8 @@ public class BleedTimerTask extends BukkitRunnable {
|
||||
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
return bleedList.containsKey(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
|
||||
public abstract class SkillManager {
|
||||
@@ -25,7 +28,11 @@ public abstract class SkillManager {
|
||||
return mcMMOPlayer.getSkillLevel(skill);
|
||||
}
|
||||
|
||||
public void applyXpGain(float xp) {
|
||||
mcMMOPlayer.beginXpGain(skill, xp);
|
||||
public void applyXpGain(float xp, XPGainReason xpGainReason) {
|
||||
mcMMOPlayer.beginXpGain(skill, xp, xpGainReason);
|
||||
}
|
||||
|
||||
public XPGainReason getXPGainReason(LivingEntity target, Entity damager) {
|
||||
return (damager instanceof Player && target instanceof Player) ? XPGainReason.PVP : XPGainReason.PVE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -62,7 +63,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
// Why do we check respawn cooldown here?
|
||||
if (SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier));
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVP);
|
||||
}
|
||||
|
||||
return modifiedDamage;
|
||||
@@ -88,12 +89,12 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(SecondaryAbility.ROLL, player, getSkillLevel(), activationChance)) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
||||
applyXpGain(calculateRollXP(damage, true));
|
||||
applyXpGain(calculateRollXP(damage, true), XPGainReason.PVE);
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(damage)) {
|
||||
applyXpGain(calculateRollXP(damage, false));
|
||||
applyXpGain(calculateRollXP(damage, false), XPGainReason.PVE);
|
||||
}
|
||||
|
||||
lastFallLocation = player.getLocation();
|
||||
@@ -112,12 +113,12 @@ public class AcrobaticsManager extends SkillManager {
|
||||
|
||||
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(SecondaryAbility.GRACEFUL_ROLL, getPlayer(), getSkillLevel(), activationChance)) {
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
||||
applyXpGain(calculateRollXP(damage, true));
|
||||
applyXpGain(calculateRollXP(damage, true), XPGainReason.PVE);
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(damage)) {
|
||||
applyXpGain(calculateRollXP(damage, false));
|
||||
applyXpGain(calculateRollXP(damage, false), XPGainReason.PVE);
|
||||
}
|
||||
|
||||
return damage;
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
@@ -64,6 +65,6 @@ public class AlchemyManager extends SkillManager {
|
||||
}
|
||||
|
||||
public void handlePotionBrewSuccesses(int amount) {
|
||||
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount));
|
||||
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount), XPGainReason.PVE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.runnables.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ArcheryManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER));
|
||||
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -44,7 +45,7 @@ public class ExcavationManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
@@ -347,11 +348,15 @@ public class FishingManager extends SkillManager {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicFound"));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getFishingExtraFish()) {
|
||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||
}
|
||||
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingBaseXP() + treasureXp);
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingBaseXP() + treasureXp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -439,7 +444,7 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
Misc.dropItem(target.getLocation(), drop);
|
||||
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP());
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.material.SmoothBrick;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class Herbalism {
|
||||
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
||||
@@ -93,4 +94,14 @@ public class Herbalism {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the block has a recently grown crop from Green Thumb
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check green thumb regrown for
|
||||
* @return true if the block is recently regrown, false otherwise
|
||||
*/
|
||||
public static boolean isRecentlyRegrown(BlockState blockState) {
|
||||
return blockState.hasMetadata(mcMMO.greenThumbDataKey) && !SkillUtils.cooldownExpired(blockState.getMetadata(mcMMO.greenThumbDataKey).get(0).asInt(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
import org.bukkit.material.Crops;
|
||||
import org.bukkit.material.NetherWarts;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@@ -25,6 +26,7 @@ import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
||||
@@ -113,8 +115,6 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
@@ -160,7 +160,7 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
|
||||
if (drops == null) {
|
||||
return;
|
||||
@@ -325,6 +325,8 @@ public class HerbalismManager extends SkillManager {
|
||||
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
|
||||
byte greenThumbStage = getGreenThumbStage();
|
||||
|
||||
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case CROPS:
|
||||
Crops crops = (Crops) blockState.getData();
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
@@ -57,7 +58,7 @@ public class MiningManager extends SkillManager {
|
||||
public void miningBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
applyXpGain(Mining.getBlockXp(blockState));
|
||||
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
|
||||
|
||||
if (!Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MINING_DOUBLE_DROPS)) {
|
||||
return;
|
||||
@@ -164,7 +165,7 @@ public class MiningManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,108 +1,13 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
|
||||
public class Repair {
|
||||
public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel();
|
||||
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
||||
|
||||
public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel();
|
||||
|
||||
public static Material salvageAnvilMaterial = Config.getInstance().getSalvageAnvilMaterial();
|
||||
public static Material repairAnvilMaterial = Config.getInstance().getRepairAnvilMaterial();
|
||||
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
|
||||
|
||||
/**
|
||||
* Checks if the item is salvageable.
|
||||
*
|
||||
* @param item Item to check
|
||||
*
|
||||
* @return true if the item is salvageable, false otherwise
|
||||
*/
|
||||
public static boolean isSalvageable(ItemStack item) {
|
||||
return (Config.getInstance().getSalvageTools() && ItemUtils.isMinecraftTool(item)) || (Config.getInstance().getSalvageArmor() && !ItemUtils.isChainmailArmor(item) && ItemUtils.isMinecraftArmor(item));
|
||||
}
|
||||
|
||||
public static String getAnvilMessage(Material type) {
|
||||
if (type == repairAnvilMaterial) {
|
||||
return LocaleLoader.getString("Repair.Listener.Anvil");
|
||||
}
|
||||
|
||||
if (type == salvageAnvilMaterial) {
|
||||
return LocaleLoader.getString("Repair.Listener.Anvil2");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
protected static Material getRepairAndSalvageItem(ItemStack inHand) {
|
||||
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
|
||||
return Material.DIAMOND;
|
||||
}
|
||||
else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
|
||||
return Material.GOLD_INGOT;
|
||||
}
|
||||
else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
|
||||
return Material.IRON_INGOT;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(inHand)) {
|
||||
return Material.COBBLESTONE;
|
||||
}
|
||||
else if (ItemUtils.isWoodTool(inHand)) {
|
||||
return Material.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(inHand)) {
|
||||
return Material.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(inHand)) {
|
||||
return Material.STRING;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getRepairAndSalvageQuantities(ItemStack item) {
|
||||
return getRepairAndSalvageQuantities(item, getRepairAndSalvageItem(item), (byte) -1);
|
||||
}
|
||||
|
||||
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
|
||||
int quantity = 0;
|
||||
MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null;
|
||||
List<Recipe> recipes = mcMMO.p.getServer().getRecipesFor(item);
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
Recipe recipe = recipes.get(0);
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return quantity;
|
||||
}
|
||||
public static Material anvilMaterial = Config.getInstance().getRepairAnvilMaterial();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.repair;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -18,6 +17,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
||||
@@ -29,10 +29,8 @@ import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class RepairManager extends SkillManager {
|
||||
private boolean placedRepairAnvil;
|
||||
private int lastRepairClick;
|
||||
private boolean placedSalvageAnvil;
|
||||
private int lastSalvageClick;
|
||||
private boolean placedAnvil;
|
||||
private int lastClick;
|
||||
|
||||
public RepairManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.REPAIR);
|
||||
@@ -40,25 +38,23 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
* @param anvilType The {@link Material} of the anvil block
|
||||
*/
|
||||
public void placedAnvilCheck(Material anvilType) {
|
||||
public void placedAnvilCheck() {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (getPlacedAnvil(anvilType)) {
|
||||
if (getPlacedAnvil()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Repair.anvilMessagesEnabled) {
|
||||
player.sendMessage(Repair.getAnvilMessage(anvilType));
|
||||
if (Config.getInstance().getRepairAnvilMessagesEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
}
|
||||
|
||||
togglePlacedAnvil(anvilType);
|
||||
togglePlacedAnvil();
|
||||
}
|
||||
|
||||
public void handleRepair(ItemStack item) {
|
||||
@@ -66,12 +62,12 @@ public class RepairManager extends SkillManager {
|
||||
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
|
||||
|
||||
// Permissions checks on material and item types
|
||||
if (!repairable.getRepairItemType().getPermissions(player)) {
|
||||
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!repairable.getRepairMaterialType().getPermissions(player)) {
|
||||
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
@@ -90,7 +86,7 @@ public class RepairManager extends SkillManager {
|
||||
Material repairMaterial = repairable.getRepairMaterial();
|
||||
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
|
||||
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
|
||||
|
||||
|
||||
short startDurability = item.getDurability();
|
||||
|
||||
// Do not repair if at full durability
|
||||
@@ -98,7 +94,7 @@ public class RepairManager extends SkillManager {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if they have the proper material to repair with
|
||||
if (!inventory.contains(repairMaterial)) {
|
||||
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial));
|
||||
@@ -144,7 +140,7 @@ public class RepairManager extends SkillManager {
|
||||
inventory.removeItem(toRemove);
|
||||
|
||||
// Give out XP like candy
|
||||
applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())));
|
||||
applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE);
|
||||
|
||||
// BWONG BWONG BWONG
|
||||
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
|
||||
@@ -159,39 +155,14 @@ public class RepairManager extends SkillManager {
|
||||
return ((startDurability - newDurability) / (float) totalDurability);
|
||||
}
|
||||
|
||||
public void handleSalvage(Location location, ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (getSkillLevel() < Repair.salvageUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getDurability() == 0) {
|
||||
player.setItemInHand(new ItemStack(Material.AIR));
|
||||
location.setY(location.getY() + 1);
|
||||
|
||||
Misc.dropItems(location, new ItemStack(Repair.getRepairAndSalvageItem(item)), Repair.getRepairAndSalvageQuantities(item) * item.getAmount());
|
||||
|
||||
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has tried to use an Anvil before.
|
||||
*
|
||||
* @return true if the player has confirmed using an Anvil
|
||||
*/
|
||||
public boolean checkConfirmation(Material anvilType, boolean actualize) {
|
||||
public boolean checkConfirmation(boolean actualize) {
|
||||
Player player = getPlayer();
|
||||
long lastUse = getLastAnvilUse(anvilType);
|
||||
long lastUse = getLastAnvilUse();
|
||||
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) {
|
||||
return true;
|
||||
@@ -201,14 +172,8 @@ public class RepairManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
actualizeLastAnvilUse(anvilType);
|
||||
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||
}
|
||||
else if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||
}
|
||||
actualizeLastAnvilUse();
|
||||
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -367,61 +332,27 @@ public class RepairManager extends SkillManager {
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
|
||||
public boolean getPlacedAnvil(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
return placedRepairAnvil;
|
||||
}
|
||||
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
return placedSalvageAnvil;
|
||||
}
|
||||
|
||||
return true;
|
||||
public boolean getPlacedAnvil() {
|
||||
return placedAnvil;
|
||||
}
|
||||
|
||||
public void togglePlacedAnvil(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
placedRepairAnvil = !placedRepairAnvil;
|
||||
}
|
||||
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
placedSalvageAnvil = !placedSalvageAnvil;
|
||||
}
|
||||
public void togglePlacedAnvil() {
|
||||
placedAnvil = !placedAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Usage
|
||||
*/
|
||||
|
||||
public int getLastAnvilUse(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
return lastRepairClick;
|
||||
}
|
||||
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
return lastSalvageClick;
|
||||
}
|
||||
|
||||
return 0;
|
||||
public int getLastAnvilUse() {
|
||||
return lastClick;
|
||||
}
|
||||
|
||||
public void setLastAnvilUse(Material anvilType, int value) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
lastRepairClick = value;
|
||||
}
|
||||
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
lastSalvageClick = value;
|
||||
}
|
||||
public void setLastAnvilUse(int value) {
|
||||
lastClick = value;
|
||||
}
|
||||
|
||||
public void actualizeLastAnvilUse(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
public void actualizeLastAnvilUse() {
|
||||
lastClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public enum RepairItemType {
|
||||
ARMOR,
|
||||
TOOL,
|
||||
OTHER;
|
||||
|
||||
/**
|
||||
* Get the base permissions associated with this RepairItemType.
|
||||
*
|
||||
* @param player The player to check the permissions for
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case ARMOR:
|
||||
return Permissions.repairArmor(player);
|
||||
|
||||
case TOOL:
|
||||
return Permissions.repairTools(player);
|
||||
|
||||
case OTHER:
|
||||
return Permissions.repairOtherItems(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public enum RepairMaterialType {
|
||||
STRING,
|
||||
LEATHER,
|
||||
WOOD,
|
||||
STONE,
|
||||
IRON,
|
||||
GOLD,
|
||||
DIAMOND,
|
||||
OTHER;
|
||||
|
||||
/**
|
||||
* Get the base permissions associated with this RepairMaterialType.
|
||||
*
|
||||
* @param player The player to check the permissions for
|
||||
*
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case STRING:
|
||||
return Permissions.repairString(player);
|
||||
|
||||
case LEATHER:
|
||||
return Permissions.repairLeather(player);
|
||||
|
||||
case WOOD:
|
||||
return Permissions.repairWood(player);
|
||||
|
||||
case STONE:
|
||||
return Permissions.repairStone(player);
|
||||
|
||||
case IRON:
|
||||
return Permissions.repairIron(player);
|
||||
|
||||
case GOLD:
|
||||
return Permissions.repairGold(player);
|
||||
|
||||
case DIAMOND:
|
||||
return Permissions.repairDiamond(player);
|
||||
|
||||
case OTHER:
|
||||
return Permissions.repairOtherMaterials(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Material getDefaultRepairMaterial() {
|
||||
switch (this) {
|
||||
case STRING:
|
||||
return Material.STRING;
|
||||
|
||||
case LEATHER:
|
||||
return Material.LEATHER;
|
||||
|
||||
case WOOD:
|
||||
return Material.WOOD;
|
||||
|
||||
case STONE:
|
||||
return Material.COBBLESTONE;
|
||||
|
||||
case IRON:
|
||||
return Material.IRON_INGOT;
|
||||
|
||||
case GOLD:
|
||||
return Material.GOLD_INGOT;
|
||||
|
||||
case DIAMOND:
|
||||
return Material.DIAMOND;
|
||||
|
||||
case OTHER:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@ package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
|
||||
|
||||
public interface Repairable {
|
||||
/**
|
||||
@@ -30,14 +33,14 @@ public interface Repairable {
|
||||
*
|
||||
* @return the RepairItemType for this repairable
|
||||
*/
|
||||
public RepairItemType getRepairItemType();
|
||||
public ItemType getRepairItemType();
|
||||
|
||||
/**
|
||||
* Gets the RepairMaterialType value for this repairable item
|
||||
*
|
||||
* @return the RepairMaterialType for this repairable
|
||||
*/
|
||||
public RepairMaterialType getRepairMaterialType();
|
||||
public MaterialType getRepairMaterialType();
|
||||
|
||||
/**
|
||||
* Gets the minimum quantity of repair materials ignoring all other repair bonuses
|
||||
|
||||
@@ -2,13 +2,16 @@ package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
|
||||
|
||||
public class RepairableFactory {
|
||||
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) {
|
||||
return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, RepairItemType.OTHER, RepairMaterialType.OTHER, 1);
|
||||
return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1);
|
||||
}
|
||||
|
||||
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
|
||||
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
||||
// TODO: Add in loading from config what type of repairable we want.
|
||||
return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||
}
|
||||
|
||||
@@ -2,17 +2,20 @@ package com.gmail.nossr50.skills.repair.repairables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
|
||||
|
||||
public class SimpleRepairable implements Repairable {
|
||||
private final Material itemMaterial, repairMaterial;
|
||||
private final int minimumQuantity, minimumLevel;
|
||||
private final short maximumDurability, baseRepairDurability;
|
||||
private final byte repairMetadata;
|
||||
private final RepairItemType repairItemType;
|
||||
private final RepairMaterialType repairMaterialType;
|
||||
private final ItemType repairItemType;
|
||||
private final MaterialType repairMaterialType;
|
||||
private final double xpMultiplier;
|
||||
|
||||
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
|
||||
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
||||
this.itemMaterial = type;
|
||||
this.repairMaterial = repairMaterial;
|
||||
this.repairMetadata = repairMetadata;
|
||||
@@ -41,12 +44,12 @@ public class SimpleRepairable implements Repairable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepairItemType getRepairItemType() {
|
||||
public ItemType getRepairItemType() {
|
||||
return repairItemType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepairMaterialType getRepairMaterialType() {
|
||||
public MaterialType getRepairMaterialType() {
|
||||
return repairMaterialType;
|
||||
}
|
||||
|
||||
|
||||
58
src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java
Normal file
58
src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.gmail.nossr50.skills.salvage;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
|
||||
public class Salvage {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
public enum Tier {
|
||||
EIGHT(8),
|
||||
SEVEN(7),
|
||||
SIX(6),
|
||||
FIVE(5),
|
||||
FOUR(4),
|
||||
THREE(3),
|
||||
TWO(2),
|
||||
ONE(1);
|
||||
|
||||
int numerical;
|
||||
|
||||
private Tier(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
public int toNumerical() {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
protected int getLevel() {
|
||||
return AdvancedConfig.getInstance().getArcaneSalvageRankLevel(this);
|
||||
}
|
||||
|
||||
protected double getExtractFullEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneSalvageExtractFullEnchantsChance(this);
|
||||
}
|
||||
|
||||
protected double getExtractPartialEnchantChance() {
|
||||
return AdvancedConfig.getInstance().getArcaneSalvageExtractPartialEnchantsChance(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static Material anvilMaterial = Config.getInstance().getSalvageAnvilMaterial();
|
||||
|
||||
public static int salvageMaxPercentageLevel = AdvancedConfig.getInstance().getSalvageMaxPercentageLevel();
|
||||
public static double salvageMaxPercentage = AdvancedConfig.getInstance().getSalvageMaxPercentage();
|
||||
|
||||
public static int advancedSalvageUnlockLevel = AdvancedConfig.getInstance().getAdvancedSalvageUnlockLevel();
|
||||
|
||||
public static boolean arcaneSalvageDowngrades = AdvancedConfig.getInstance().getArcaneSalvageEnchantDowngradeEnabled();
|
||||
public static boolean arcaneSalvageEnchantLoss = AdvancedConfig.getInstance().getArcaneSalvageEnchantLossEnabled();
|
||||
|
||||
protected static int calculateSalvageableAmount(short currentDurability, short maxDurability, int baseAmount) {
|
||||
double percentDamaged = (maxDurability <= 0) ? 1D : (double) (maxDurability - currentDurability) / maxDurability;
|
||||
|
||||
return (int) Math.floor(baseAmount * percentDamaged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package com.gmail.nossr50.skills.salvage;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
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.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage.Tier;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
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 SalvageManager extends SkillManager {
|
||||
private boolean placedAnvil;
|
||||
private int lastClick;
|
||||
|
||||
public SalvageManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.SALVAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*/
|
||||
public void placedAnvilCheck() {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (getPlacedAnvil()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSalvageAnvilMessagesEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Listener.Anvil"));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
}
|
||||
|
||||
togglePlacedAnvil();
|
||||
}
|
||||
|
||||
public void handleSalvage(Location location, ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
|
||||
Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
|
||||
|
||||
// Permissions checks on material and item types
|
||||
if (!Permissions.salvageItemType(player, salvageable.getSalvageItemType())) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.salvageMaterialType(player, salvageable.getSalvageMaterialType())) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = getSkillLevel();
|
||||
int minimumSalvageableLevel = salvageable.getMinimumLevel();
|
||||
|
||||
// Level check
|
||||
if (skillLevel < minimumSalvageableLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Adept.Level", minimumSalvageableLevel, StringUtils.getPrettyItemString(item.getType())));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getDurability() != 0 && (getSkillLevel() < Salvage.advancedSalvageUnlockLevel || !Permissions.advancedSalvage(player))) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Adept.Damaged"));
|
||||
return;
|
||||
}
|
||||
|
||||
byte salvageMaterialMetadata = salvageable.getSalvageMaterialMetadata();
|
||||
|
||||
int salvageableAmount = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
|
||||
|
||||
if (salvageableAmount == 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.TooDamaged"));
|
||||
return;
|
||||
}
|
||||
|
||||
salvageableAmount = Math.max((int) (salvageableAmount * getMaxSalvagePercentage()), 1); // Always get at least something back, if you're capable of salvaging it.
|
||||
|
||||
player.setItemInHand(new ItemStack(Material.AIR));
|
||||
location.add(0, 1, 0);
|
||||
|
||||
Map<Enchantment, Integer> enchants = item.getEnchantments();
|
||||
|
||||
if (!enchants.isEmpty()) {
|
||||
ItemStack enchantBook = arcaneSalvageCheck(enchants);
|
||||
|
||||
if (enchantBook != null) {
|
||||
Misc.dropItem(location, enchantBook);
|
||||
}
|
||||
}
|
||||
|
||||
Misc.dropItems(location, new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount), 1);
|
||||
|
||||
// BWONG BWONG BWONG - CLUNK!
|
||||
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Success"));
|
||||
}
|
||||
|
||||
public double getMaxSalvagePercentage() {
|
||||
return Math.min((((Salvage.salvageMaxPercentage / Salvage.salvageMaxPercentageLevel) * getSkillLevel()) / 100.0D), Salvage.salvageMaxPercentage / 100.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Arcane Salvage rank
|
||||
*
|
||||
* @return the current Arcane Salvage rank
|
||||
*/
|
||||
public int getArcaneSalvageRank() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getExtractFullEnchantChance() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getExtractFullEnchantChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getExtractPartialEnchantChance() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getExtractPartialEnchantChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private ItemStack arcaneSalvageCheck(Map<Enchantment, Integer> enchants) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (getArcaneSalvageRank() == 0 || !Permissions.arcaneSalvage(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.ArcaneFailed"));
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) book.getItemMeta();
|
||||
|
||||
boolean downgraded = false;
|
||||
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
int successChance = Misc.getRandom().nextInt(activationChance);
|
||||
|
||||
if (!Salvage.arcaneSalvageEnchantLoss || getExtractFullEnchantChance() > successChance) {
|
||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true);
|
||||
}
|
||||
else if (enchant.getValue() > 1 && Salvage.arcaneSalvageDowngrades && getExtractPartialEnchantChance() > successChance) {
|
||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue() - 1, true);
|
||||
downgraded = true;
|
||||
}
|
||||
else {
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> newEnchants = enchantMeta.getStoredEnchants();
|
||||
|
||||
if (newEnchants.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.ArcaneFailed"));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (downgraded || newEnchants.size() < enchants.size()) {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.ArcanePartial"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.ArcaneSuccess"));
|
||||
}
|
||||
|
||||
book.setItemMeta(enchantMeta);
|
||||
return book;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has tried to use an Anvil before.
|
||||
* @param actualize
|
||||
*
|
||||
* @return true if the player has confirmed using an Anvil
|
||||
*/
|
||||
public boolean checkConfirmation(boolean actualize) {
|
||||
Player player = getPlayer();
|
||||
long lastUse = getLastAnvilUse();
|
||||
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getSalvageConfirmRequired()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!actualize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
actualizeLastAnvilUse();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Salvage Anvil Placement
|
||||
*/
|
||||
|
||||
public boolean getPlacedAnvil() {
|
||||
return placedAnvil;
|
||||
}
|
||||
|
||||
public void togglePlacedAnvil() {
|
||||
placedAnvil = !placedAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Salvage Anvil Usage
|
||||
*/
|
||||
|
||||
public int getLastAnvilUse() {
|
||||
return lastClick;
|
||||
}
|
||||
|
||||
public void setLastAnvilUse(int value) {
|
||||
lastClick = value;
|
||||
}
|
||||
|
||||
public void actualizeLastAnvilUse() {
|
||||
lastClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.gmail.nossr50.skills.salvage.salvageables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
|
||||
public interface Salvageable {
|
||||
/**
|
||||
* Gets the type of this repairable item
|
||||
*
|
||||
* @return the type of this repairable
|
||||
*/
|
||||
public Material getItemMaterial();
|
||||
|
||||
/**
|
||||
* Gets the id of the material used to repair this item
|
||||
*
|
||||
* @return the id of the repair material
|
||||
*/
|
||||
public Material getSalvageMaterial();
|
||||
|
||||
/**
|
||||
* Gets the metadata byte value of the material used to repair this item
|
||||
*
|
||||
* @return the byte metadata of the repair material
|
||||
*/
|
||||
public byte getSalvageMaterialMetadata();
|
||||
|
||||
/**
|
||||
* Gets the RepairItemType value for this repairable item
|
||||
*
|
||||
* @return the RepairItemType for this repairable
|
||||
*/
|
||||
public ItemType getSalvageItemType();
|
||||
|
||||
/**
|
||||
* Gets the RepairMaterialType value for this repairable item
|
||||
*
|
||||
* @return the RepairMaterialType for this repairable
|
||||
*/
|
||||
public MaterialType getSalvageMaterialType();
|
||||
|
||||
/**
|
||||
* Gets the maximum quantity of salvage materials ignoring all other salvage bonuses
|
||||
*
|
||||
* This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords
|
||||
*
|
||||
* @return the maximum number of items
|
||||
*/
|
||||
public int getMaximumQuantity();
|
||||
|
||||
/**
|
||||
* Gets the maximum durability of this item before it breaks
|
||||
*
|
||||
* @return the maximum durability
|
||||
*/
|
||||
public short getMaximumDurability();
|
||||
|
||||
/**
|
||||
* Gets the base repair durability on which to calculate bonuses.
|
||||
*
|
||||
* This is actually the maximum durability divided by the minimum quantity
|
||||
*
|
||||
* @return the base repair durability
|
||||
*/
|
||||
public short getBaseSalvageDurability();
|
||||
|
||||
/**
|
||||
* Gets the minimum repair level needed to repair this item
|
||||
*
|
||||
* @return the minimum level to repair this item, or 0 for no minimum
|
||||
*/
|
||||
public int getMinimumLevel();
|
||||
|
||||
/**
|
||||
* Gets the xpMultiplier for this repairable
|
||||
*
|
||||
* @return the xpMultiplier of this repairable
|
||||
*/
|
||||
public double getXpMultiplier();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gmail.nossr50.skills.salvage.salvageables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
|
||||
public class SalvageableFactory {
|
||||
public static Salvageable getSalvageable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int maximumQuantity, short maximumDurability) {
|
||||
return getSalvageable(itemMaterial, repairMaterial, repairMetadata, 0, maximumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1);
|
||||
}
|
||||
|
||||
public static Salvageable getSalvageable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
||||
// TODO: Add in loading from config what type of repairable we want.
|
||||
return new SimpleSalvageable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, maximumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gmail.nossr50.skills.salvage.salvageables;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface SalvageableManager {
|
||||
/**
|
||||
* Register a salvageable with the SalvageManager
|
||||
*
|
||||
* @param salvageable Salvageable to register
|
||||
*/
|
||||
public void registerSalvageable(Salvageable salvageable);
|
||||
|
||||
/**
|
||||
* Register a list of salvageables with the SalvageManager
|
||||
*
|
||||
* @param salvageables List<Salvageable> to register
|
||||
*/
|
||||
public void registerSalvageables(List<Salvageable> salvageables);
|
||||
|
||||
/**
|
||||
* Checks if an item is salvageable
|
||||
*
|
||||
* @param type Material to check if salvageable
|
||||
*
|
||||
* @return true if salvageable, false if not
|
||||
*/
|
||||
public boolean isSalvageable(Material type);
|
||||
|
||||
/**
|
||||
* Checks if an item is salvageable
|
||||
*
|
||||
* @param itemStack Item to check if salvageable
|
||||
*
|
||||
* @return true if salvageable, false if not
|
||||
*/
|
||||
public boolean isSalvageable(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Gets the salvageable with this type
|
||||
*
|
||||
* @param type Material of the salvageable to look for
|
||||
*
|
||||
* @return the salvageable, can be null
|
||||
*/
|
||||
public Salvageable getSalvageable(Material type);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.gmail.nossr50.skills.salvage.salvageables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
|
||||
|
||||
public class SimpleSalvageable implements Salvageable {
|
||||
private final Material itemMaterial, salvageMaterial;
|
||||
private final int maximumQuantity, minimumLevel;
|
||||
private final short maximumDurability, baseSalvageDurability;
|
||||
private final byte salvageMetadata;
|
||||
private final ItemType salvageItemType;
|
||||
private final MaterialType salvageMaterialType;
|
||||
private final double xpMultiplier;
|
||||
|
||||
protected SimpleSalvageable(Material type, Material salvageMaterial, byte salvageMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType salvageItemType, MaterialType salvageMaterialType, double xpMultiplier) {
|
||||
this.itemMaterial = type;
|
||||
this.salvageMaterial = salvageMaterial;
|
||||
this.salvageMetadata = salvageMetadata;
|
||||
this.salvageItemType = salvageItemType;
|
||||
this.salvageMaterialType = salvageMaterialType;
|
||||
this.minimumLevel = minimumLevel;
|
||||
this.maximumQuantity = maximumQuantity;
|
||||
this.maximumDurability = maximumDurability;
|
||||
this.baseSalvageDurability = (short) (maximumDurability / maximumQuantity);
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getItemMaterial() {
|
||||
return itemMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getSalvageMaterial() {
|
||||
return salvageMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSalvageMaterialMetadata() {
|
||||
return salvageMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemType getSalvageItemType() {
|
||||
return salvageItemType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialType getSalvageMaterialType() {
|
||||
return salvageMaterialType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumQuantity() {
|
||||
return maximumQuantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaximumDurability() {
|
||||
return maximumDurability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getBaseSalvageDurability() {
|
||||
return baseSalvageDurability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumLevel() {
|
||||
return minimumLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getXpMultiplier() {
|
||||
return xpMultiplier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gmail.nossr50.skills.salvage.salvageables;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class SimpleSalvageableManager implements SalvageableManager {
|
||||
private HashMap<Material, Salvageable> salvageables;
|
||||
|
||||
public SimpleSalvageableManager() {
|
||||
this(55);
|
||||
}
|
||||
|
||||
public SimpleSalvageableManager(int salvageablesSize) {
|
||||
this.salvageables = new HashMap<Material, Salvageable>(salvageablesSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSalvageable(Salvageable salvageable) {
|
||||
Material item = salvageable.getItemMaterial();
|
||||
salvageables.put(item, salvageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSalvageables(List<Salvageable> salvageables) {
|
||||
for (Salvageable salvageable : salvageables) {
|
||||
registerSalvageable(salvageable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSalvageable(Material type) {
|
||||
return salvageables.containsKey(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSalvageable(ItemStack itemStack) {
|
||||
return isSalvageable(itemStack.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Salvageable getSalvageable(Material type) {
|
||||
return salvageables.get(type);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
@@ -85,7 +86,7 @@ public class SmeltingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) {
|
||||
applyXpGain(Smelting.getResourceXp(smelting));
|
||||
applyXpGain(Smelting.getResourceXp(smelting), XPGainReason.PVE);
|
||||
|
||||
if (isSecondSmeltSuccessful()) {
|
||||
ItemStack newResult = result.clone();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Taming {
|
||||
|
||||
case WOLF:
|
||||
return LocaleLoader.getString("Taming.Summon.Fail.Wolf");
|
||||
|
||||
|
||||
case HORSE:
|
||||
return LocaleLoader.getString("Taming.Summon.Fail.Horse");
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -72,15 +73,15 @@ public class TamingManager extends SkillManager {
|
||||
public void awardTamingXP(LivingEntity entity) {
|
||||
switch (entity.getType()) {
|
||||
case HORSE:
|
||||
applyXpGain(Taming.horseXp);
|
||||
applyXpGain(Taming.horseXp, XPGainReason.PVE);
|
||||
return;
|
||||
|
||||
case WOLF:
|
||||
applyXpGain(Taming.wolfXp);
|
||||
applyXpGain(Taming.wolfXp, XPGainReason.PVE);
|
||||
return;
|
||||
|
||||
case OCELOT:
|
||||
applyXpGain(Taming.ocelotXp);
|
||||
applyXpGain(Taming.ocelotXp, XPGainReason.PVE);
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Unarmed {
|
||||
if (inventory.containsAtLeast(dropStack, 1)) {
|
||||
int nextSlot = 0;
|
||||
|
||||
for (ItemStack itemstack: inventory) {
|
||||
for (ItemStack itemstack : inventory) {
|
||||
if (dropStack.isSimilar(itemstack)) {
|
||||
int itemAmount = itemstack.getAmount();
|
||||
int itemMax = itemstack.getMaxStackSize();
|
||||
@@ -57,7 +57,7 @@ public class Unarmed {
|
||||
if (firstEmpty == inventory.getHeldItemSlot()) {
|
||||
int nextSlot = firstEmpty + 1;
|
||||
|
||||
for (Iterator<ItemStack> iterator = inventory.iterator(nextSlot); iterator.hasNext();) {
|
||||
for (Iterator<ItemStack> iterator = inventory.iterator(nextSlot); iterator.hasNext(); ) {
|
||||
ItemStack itemstack = iterator.next();
|
||||
|
||||
if (itemstack == null) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||
@@ -63,7 +64,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +166,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
blockState.update(true);
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.material.SmoothBrick;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
|
||||
public final class BlockUtils {
|
||||
private BlockUtils() {}
|
||||
@@ -297,7 +298,7 @@ public final class BlockUtils {
|
||||
public static boolean isMcMMOAnvil(BlockState blockState) {
|
||||
Material type = blockState.getType();
|
||||
|
||||
return type == Repair.repairAnvilMaterial || type == Repair.salvageAnvilMaterial;
|
||||
return type == Repair.anvilMaterial || type == Salvage.anvilMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class ChimaeraWing {
|
||||
long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
|
||||
int cooldown = Config.getInstance().getChimaeraCooldown();
|
||||
|
||||
if (cooldown > 0 ) {
|
||||
if (cooldown > 0) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
@@ -142,7 +142,7 @@ public final class ChimaeraWing {
|
||||
if (Config.getInstance().getChimaeraSoundEnabled()) {
|
||||
player.playSound(location, Sound.BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
|
||||
}
|
||||
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.XPGainReason;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelChangeEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
@@ -52,8 +53,8 @@ public class EventUtils {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static boolean handleLevelChangeEvent(Player player, SkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp) {
|
||||
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged);
|
||||
public static boolean handleLevelChangeEvent(Player player, SkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) {
|
||||
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
boolean isCancelled = event.isCancelled();
|
||||
@@ -139,8 +140,8 @@ public class EventUtils {
|
||||
return !isCancelled;
|
||||
}
|
||||
|
||||
public static boolean handleXpGainEvent(Player player, SkillType skill, float xpGained) {
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained);
|
||||
public static boolean handleXpGainEvent(Player player, SkillType skill, float xpGained, XPGainReason xpGainReason) {
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
boolean isCancelled = event.isCancelled();
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -82,7 +83,7 @@ public final class HardcoreManager {
|
||||
totalLevelsStolen += levelsStolen;
|
||||
|
||||
killerPlayer.addLevels(skillType, levelsStolen);
|
||||
killerPlayer.beginUnsharedXpGain(skillType, xpStolen);
|
||||
killerPlayer.beginUnsharedXpGain(skillType, xpStolen, XPGainReason.VAMPIRISM);
|
||||
|
||||
victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
|
||||
victimProfile.removeXp(skillType, xpStolen);
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Random;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.NPC;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -51,7 +50,7 @@ public final class Misc {
|
||||
}
|
||||
|
||||
public static boolean isNPCEntity(Entity entity) {
|
||||
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || (mcMMO.isCombatTagEnabled() && entity instanceof HumanEntity && ((HumanEntity) entity).getName().contains("PvpLogger")) || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
@@ -162,18 +164,19 @@ public final class Permissions {
|
||||
public static boolean superBreaker(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.superbreaker"); }
|
||||
|
||||
/* REPAIR */
|
||||
public static boolean repairArmor(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.armorrepair"); }
|
||||
public static boolean repairTools(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.toolrepair"); }
|
||||
public static boolean repairOtherItems(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.otherrepair"); }
|
||||
public static boolean repairItemType(Permissible permissible, ItemType repairItemType) { return permissible.hasPermission("mcmmo.ability.repair." + repairItemType.toString().toLowerCase() + "repair"); }
|
||||
public static boolean repairMaterialType(Permissible permissible, MaterialType repairMaterialType) { return permissible.hasPermission("mcmmo.ability.repair." + repairMaterialType.toString().toLowerCase() + "repair"); }
|
||||
|
||||
public static boolean repairDiamond(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.diamondrepair"); }
|
||||
public static boolean repairGold(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.goldrepair"); }
|
||||
public static boolean repairIron(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.ironrepair"); }
|
||||
public static boolean repairLeather(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.leatherrepair"); }
|
||||
public static boolean repairOtherMaterials(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.othermaterialrepair"); }
|
||||
public static boolean repairString(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.stringrepair"); }
|
||||
public static boolean repairStone(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.stonerepair"); }
|
||||
public static boolean repairWood(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.repair.woodrepair"); }
|
||||
/* SALVAGE */
|
||||
public static boolean advancedSalvage(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.salvage.advancedsalvage"); }
|
||||
public static boolean arcaneSalvage(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.salvage.arcanesalvage"); }
|
||||
|
||||
public static boolean salvageItemType(Permissible permissible, ItemType salvageItemType) { return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemType.toString().toLowerCase() + "salvage"); }
|
||||
public static boolean salvageMaterialType(Permissible permissible, MaterialType salvageMaterialType) { return permissible.hasPermission("mcmmo.ability.salvage." + salvageMaterialType.toString().toLowerCase() + "salvage"); }
|
||||
|
||||
/* SMELTING */
|
||||
public static boolean fluxMining(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.smelting.fluxmining"); }
|
||||
public static boolean fuelEfficiency(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.smelting.fuelefficiency"); }
|
||||
|
||||
/* SWORDS */
|
||||
public static boolean serratedStrikes(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.swords.serratedstrikes"); }
|
||||
|
||||
@@ -29,7 +29,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void closeAll() {
|
||||
for (UUID uid : regionFiles.keySet()) {
|
||||
HashMap<Long, McMMOSimpleRegionFile> worldRegions = regionFiles.get(uid);
|
||||
for (Iterator<McMMOSimpleRegionFile> worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) {
|
||||
for (Iterator<McMMOSimpleRegionFile> worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext(); ) {
|
||||
McMMOSimpleRegionFile rf = worldRegionIterator.next();
|
||||
if (rf != null) {
|
||||
rf.close();
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.gmail.nossr50.commands.skills.FishingCommand;
|
||||
import com.gmail.nossr50.commands.skills.HerbalismCommand;
|
||||
import com.gmail.nossr50.commands.skills.MiningCommand;
|
||||
import com.gmail.nossr50.commands.skills.RepairCommand;
|
||||
import com.gmail.nossr50.commands.skills.SalvageCommand;
|
||||
import com.gmail.nossr50.commands.skills.SmeltingCommand;
|
||||
import com.gmail.nossr50.commands.skills.SwordsCommand;
|
||||
import com.gmail.nossr50.commands.skills.TamingCommand;
|
||||
@@ -109,6 +110,10 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new RepairCommand());
|
||||
break;
|
||||
|
||||
case SALVAGE:
|
||||
command.setExecutor(new SalvageCommand());
|
||||
break;
|
||||
|
||||
case SMELTING:
|
||||
command.setExecutor(new SmeltingCommand());
|
||||
break;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class FormulaManager {
|
||||
experience -= experienceToNextLevel;
|
||||
}
|
||||
|
||||
return new int[]{newLevel, remainder};
|
||||
return new int[]{ newLevel, remainder };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class UserManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all users.
|
||||
* Save all users ON THIS THREAD.
|
||||
*/
|
||||
public static void saveAll() {
|
||||
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
|
||||
@@ -59,10 +59,12 @@ public final class UserManager {
|
||||
}
|
||||
|
||||
public static Collection<McMMOPlayer> getPlayers() {
|
||||
Collection<McMMOPlayer> playerCollection = new ArrayList<McMMOPlayer>();
|
||||
Collection<McMMOPlayer> playerCollection = new ArrayList<McMMOPlayer>();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
playerCollection.add(getPlayer(player));
|
||||
if (hasPlayerDataKey(player)) {
|
||||
playerCollection.add(getPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
return playerCollection;
|
||||
|
||||
@@ -490,11 +490,10 @@ public class ScoreboardWrapper {
|
||||
|
||||
// Calculate power level here
|
||||
int powerLevel = 0;
|
||||
for (SkillType skill : SkillType.values()) { // Include child skills, but not in power level
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { // Don't include child skills, makes the list too long
|
||||
int level = newProfile.getSkillLevel(skill);
|
||||
|
||||
if (!skill.isChildSkill())
|
||||
powerLevel += level;
|
||||
powerLevel += level;
|
||||
|
||||
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
||||
if (!skill.getPermissions(player)) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -282,7 +283,7 @@ public final class CombatUtils {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
||||
|
||||
if (acrobaticsManager.canDodge(damager)) {
|
||||
if (acrobaticsManager.canDodge(target)) {
|
||||
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
||||
}
|
||||
|
||||
@@ -398,12 +399,14 @@ public final class CombatUtils {
|
||||
*/
|
||||
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType, double multiplier) {
|
||||
double baseXP = 0;
|
||||
XPGainReason xpGainReason;
|
||||
|
||||
if (target instanceof Player) {
|
||||
if (!ExperienceConfig.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
xpGainReason = XPGainReason.PVP;
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
@@ -472,13 +475,15 @@ public final class CombatUtils {
|
||||
baseXP *= ExperienceConfig.getInstance().getSpawnedMobXpMultiplier();
|
||||
}
|
||||
|
||||
xpGainReason = XPGainReason.PVE;
|
||||
|
||||
baseXP *= 10;
|
||||
}
|
||||
|
||||
baseXP *= multiplier;
|
||||
|
||||
if (baseXP != 0) {
|
||||
new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0);
|
||||
new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,6 +506,11 @@ public final class CombatUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Vanished players should not be able to get hit by AoE effects
|
||||
if (!player.canSee(defender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
|
||||
if (callFakeDamageEvent(player, entity, 1.0) == 0) {
|
||||
return false;
|
||||
|
||||
@@ -8,7 +8,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@@ -219,4 +223,68 @@ public class SkillUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static Material getRepairAndSalvageItem(ItemStack inHand) {
|
||||
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
|
||||
return Material.DIAMOND;
|
||||
}
|
||||
else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
|
||||
return Material.GOLD_INGOT;
|
||||
}
|
||||
else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
|
||||
return Material.IRON_INGOT;
|
||||
}
|
||||
else if (ItemUtils.isStoneTool(inHand)) {
|
||||
return Material.COBBLESTONE;
|
||||
}
|
||||
else if (ItemUtils.isWoodTool(inHand)) {
|
||||
return Material.WOOD;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(inHand)) {
|
||||
return Material.LEATHER;
|
||||
}
|
||||
else if (ItemUtils.isStringTool(inHand)) {
|
||||
return Material.STRING;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getRepairAndSalvageQuantities(ItemStack item) {
|
||||
return getRepairAndSalvageQuantities(item, getRepairAndSalvageItem(item), (byte) -1);
|
||||
}
|
||||
|
||||
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
|
||||
// Workaround for Bukkit bug where damaged items would not return any recipes
|
||||
item = item.clone();
|
||||
item.setDurability((short) 0);
|
||||
|
||||
int quantity = 0;
|
||||
MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null;
|
||||
List<Recipe> recipes = mcMMO.p.getServer().getRecipesFor(item);
|
||||
|
||||
if (recipes.isEmpty()) {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
Recipe recipe = recipes.get(0);
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return quantity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,10 +314,6 @@ Skills:
|
||||
ChanceMax: 100.0
|
||||
MaxBonusLevel: 1000
|
||||
|
||||
Salvage:
|
||||
# UnlockLevel: Level when Salvage become available
|
||||
UnlockLevel: 600
|
||||
|
||||
ArcaneForging:
|
||||
May_Lose_Enchants: true
|
||||
Rank_Levels:
|
||||
@@ -349,6 +345,55 @@ Skills:
|
||||
Rank_7: 15.0
|
||||
Rank_8: 10.0
|
||||
#
|
||||
# Settings for Salvage
|
||||
###
|
||||
Salvage:
|
||||
# MaxPercentage: Maximum percentage of materials to be returned when Salvaging
|
||||
# MaxPercentageLevel: On this level, the Salvage percentage will be <MaxPercentage>
|
||||
MaxPercentage: 100.0
|
||||
MaxPercentageLevel: 1000
|
||||
|
||||
# AdvancedSalvage_UnlockLevel: The level at which Advance Salvage become available
|
||||
AdvancedSalvage:
|
||||
UnlockLevel: 350
|
||||
|
||||
ArcaneSalvage:
|
||||
# EnchantLossEnabled: When salvaging enchanted items, the enchants may be lost
|
||||
# EnchantDowngradeEnabled: When salvaging enchanted items, the enchants may be downgraded
|
||||
EnchantLossEnabled: true
|
||||
EnchantDowngradeEnabled: true
|
||||
Rank_Levels:
|
||||
Rank_1: 125
|
||||
Rank_2: 250
|
||||
Rank_3: 375
|
||||
Rank_4: 500
|
||||
Rank_5: 625
|
||||
Rank_6: 750
|
||||
Rank_7: 875
|
||||
Rank_8: 1000
|
||||
|
||||
# ExtractFullEnchant: Chance to extract the full enchant at each ArcaneSalvage rank
|
||||
ExtractFullEnchant:
|
||||
Rank_1: 2.5
|
||||
Rank_2: 5.0
|
||||
Rank_3: 7.5
|
||||
Rank_4: 10.0
|
||||
Rank_5: 12.5
|
||||
Rank_6: 17.5
|
||||
Rank_7: 25.0
|
||||
Rank_8: 32.5
|
||||
|
||||
# ExtractPartialEnchant: Chance to extract the partial enchant at each ArcaneSalvage rank
|
||||
ExtractPartialEnchant:
|
||||
Rank_1: 2.0
|
||||
Rank_2: 2.5
|
||||
Rank_3: 5.0
|
||||
Rank_4: 7.5
|
||||
Rank_5: 10.0
|
||||
Rank_6: 12.5
|
||||
Rank_7: 15.0
|
||||
Rank_8: 17.5
|
||||
#
|
||||
# Settings for Smelting
|
||||
###
|
||||
Smelting:
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
# WARNING: THIS IS NOT SUPPORTED, IF YOU DO SO YOU ARE RESPONSIBLE FOR THE ISSUES THAT MAY ARISE. That said, watch out for circular dependencies, those are bad.
|
||||
#
|
||||
#####
|
||||
Salvage:
|
||||
- Fishing
|
||||
- Repair
|
||||
Smelting:
|
||||
- Mining
|
||||
- Repair
|
||||
@@ -37,6 +37,9 @@ Scoreboard:
|
||||
# Allow players to use "/mcscoreboard keep" to keep the scoreboard up
|
||||
Allow_Keep: true
|
||||
|
||||
# Show the /mcstats scoreboard automatically after logging in
|
||||
Show_Stats_After_Login: false
|
||||
|
||||
# Add some more color on the board :-)
|
||||
Rainbows: false
|
||||
|
||||
@@ -274,7 +277,9 @@ Skills:
|
||||
# Allow Hoppers to transfer ingredients and brew Rank 1 Alchemy potions
|
||||
Enabled_for_Hoppers: true
|
||||
# Prevent Hoppers from transferring ingredients into Brewing Stands
|
||||
Prevent_Hopper_Transfer: false
|
||||
Prevent_Hopper_Transfer_Ingredients: false
|
||||
# Prevent Hoppers from transferring bottles into Brewing Stands
|
||||
Prevent_Hopper_Transfer_Bottles: false
|
||||
Level_Cap: 0
|
||||
Archery:
|
||||
Enabled_For_PVP: true
|
||||
@@ -287,8 +292,10 @@ Skills:
|
||||
Excavation:
|
||||
Level_Cap: 0
|
||||
Fishing:
|
||||
Drops_Enabled: true
|
||||
Level_Cap: 0
|
||||
Drops_Enabled: true
|
||||
# Always catch fish, even when treasure is found
|
||||
Extra_Fish: false
|
||||
Herbalism:
|
||||
Level_Cap: 0
|
||||
Prevent_AFK_Leveling: true
|
||||
@@ -301,11 +308,16 @@ Skills:
|
||||
Anvil_Placed_Sounds: true
|
||||
Anvil_Use_Sounds: true
|
||||
Anvil_Material: IRON_BLOCK
|
||||
Salvage_Anvil_Material: GOLD_BLOCK
|
||||
Salvage_tools: true
|
||||
Salvage_armor: true
|
||||
# Ask for a confirmation when a player tries to repair an enchanted item
|
||||
Confirm_Required: true
|
||||
Salvage:
|
||||
Level_Cap: 0
|
||||
Anvil_Messages: true
|
||||
Anvil_Placed_Sounds: true
|
||||
Anvil_Use_Sounds: true
|
||||
Anvil_Material: GOLD_BLOCK
|
||||
# Ask for a confirmation when a player tries to salvage an enchanted item
|
||||
Confirm_Required: true
|
||||
Smelting:
|
||||
Level_Cap: 0
|
||||
Swords:
|
||||
@@ -439,4 +451,4 @@ Particles:
|
||||
# These settings determine if fireworks should get launched when a player levels-up,
|
||||
# this will happen by default for every 100 levels.
|
||||
LevelUp_Enabled: true
|
||||
LevelUp_Tier: 100
|
||||
LevelUp_Tier: 100
|
||||
|
||||
@@ -235,14 +235,10 @@ Repair.Effect.6=Diamond Repair ({0}+ SKILL)
|
||||
Repair.Effect.7=Repair Diamond Tools & Armor
|
||||
Repair.Effect.8=Arcane Forging
|
||||
Repair.Effect.9=Repair magic items
|
||||
Repair.Effect.16=Salvage ({0}+ SKILL)
|
||||
Repair.Effect.17=Salvage Tools & Armor
|
||||
Repair.Error=[[DARK_RED]]mcMMO encountered an error attempting to repair this item!
|
||||
Repair.Listener.Anvil=[[DARK_RED]]You have placed an anvil, anvils can repair tools and armor.
|
||||
Repair.Listener.Anvil2=[[DARK_RED]]You have placed a Salvage anvil, use this to Salvage tools and armor.
|
||||
Repair.Listener=Repair:
|
||||
Repair.SkillName=REPAIR
|
||||
Repair.Skills.AdeptSalvage=[[DARK_RED]]You're not skilled enough to Salvage items.
|
||||
Repair.Skills.AdeptDiamond=[[DARK_RED]]You're not skilled enough to repair Diamond.
|
||||
Repair.Skills.AdeptGold=[[DARK_RED]]You're not skilled enough to repair Gold.
|
||||
Repair.Skills.AdeptIron=[[DARK_RED]]You're not skilled enough to repair Iron.
|
||||
@@ -250,14 +246,11 @@ Repair.Skills.AdeptStone=[[DARK_RED]]You're not skilled enough to repair Stone.
|
||||
Repair.Skills.Adept=[[RED]]You must be level [[YELLOW]]{0}[[RED]] to repair [[YELLOW]]{1}
|
||||
Repair.Skills.FeltEasy=[[GRAY]]That felt easy.
|
||||
Repair.Skills.FullDurability=[[GRAY]]That is at full durability.
|
||||
Repair.Skills.SalvageSuccess=[[GRAY]]Item salvaged!
|
||||
Repair.Skills.NotFullDurability=[[DARK_RED]]You can't salvage damaged items.
|
||||
Repair.Skills.Mastery=[[RED]]Repair Mastery: [[YELLOW]]Extra {0} durability restored
|
||||
Repair.Skills.StackedItems=[[DARK_RED]]You can't repair stacked items.
|
||||
Repair.Skills.Super.Chance=[[RED]]Super Repair Chance: [[YELLOW]]{0}
|
||||
Repair.Skillup=[[YELLOW]]Repair skill increased by {0}. Total ({1})
|
||||
Repair.Pretty.Name=Repair
|
||||
Salvage.Pretty.Name=Salvage
|
||||
|
||||
#Arcane Forging
|
||||
Repair.Arcane.Chance.Downgrade=[[GRAY]]AF Downgrade Chance: [[YELLOW]]{0}%
|
||||
@@ -268,6 +261,29 @@ Repair.Arcane.Lost=[[RED]]You were not skilled enough to keep any enchantments.
|
||||
Repair.Arcane.Perfect=[[GREEN]]You have sustained the arcane energies in this item.
|
||||
Repair.Arcane.Rank=[[RED]]Arcane Forging: [[YELLOW]]Rank {0}/{1}
|
||||
|
||||
#SALVAGE
|
||||
Salvage.Pretty.Name=Salvage
|
||||
Salvage.Effect.0=Advanced Salvage
|
||||
Salvage.Effect.1=Salvage damaged items
|
||||
Salvage.Effect.2=Arcane Salvaging
|
||||
Salvage.Effect.3=Extract enchantments from items
|
||||
Salvage.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (ADVANCED SALVAGE)
|
||||
Salvage.Ability.Bonus.0=Advanced Salvage
|
||||
Salvage.Ability.Bonus.1=Max yield {0} item destroyed
|
||||
Salvage.Arcane.Rank=[[RED]]Arcane Salvaging: [[YELLOW]]Rank {0}/{1}
|
||||
Salvage.Arcane.ExtractFull=[[GRAY]]AS Full-Enchant Chance
|
||||
Salvage.Arcane.ExtractPartial=[[GRAY]]AS Partial-Enchant Chance
|
||||
Salvage.Skills.Success=[[GREEN]]Item salvaged!
|
||||
Salvage.Skills.Adept.Damaged=[[DARK_RED]]You aren't skilled enough to salvage damaged items.
|
||||
Salvage.Skills.Adept.Level=[[RED]]You must be level [[YELLOW]]{0}[[RED]] to salvage [[YELLOW]]{1}
|
||||
Salvage.Skills.TooDamaged=[[DARK_RED]]This item is too damaged to be salvaged.
|
||||
Salvage.Skills.ArcaneFailed=[[RED]]You were unable to extract the knowledge contained within this item.
|
||||
Salvage.Skills.ArcanePartial=[[YELLOW]]You were only able to extract some of the knowledge contained within this item.
|
||||
Salvage.Skills.ArcaneSuccess=[[GREEN]]You able to extract all of the knowledge contained within this item!
|
||||
Salvage.Listener.Anvil=[[DARK_RED]]You have placed a Salvage anvil, use this to Salvage tools and armor.
|
||||
Salvage.Listener=Salvage:
|
||||
Salvage.SkillName=SALVAGE
|
||||
|
||||
#SWORDS
|
||||
Swords.Ability.Lower=[[GRAY]]**YOU LOWER YOUR SWORD**
|
||||
Swords.Ability.Ready=[[GREEN]]**YOU READY YOUR SWORD**
|
||||
@@ -758,12 +774,21 @@ Guides.Mining.Section.4=[[DARK_AQUA]]How to use Blast Mining:\n[[YELLOW]]With a
|
||||
Guides.Mining.Section.5=[[DARK_AQUA]]How does Blast Mining work?\n[[YELLOW]]Blast Mining is an ability with a cooldown tied to the Mining\n[[YELLOW]]skill. It gives bonuses when mining with TNT and allows you\n[[YELLOW]]to remote detonate TNT. There are three parts to Blast Mining.\n[[YELLOW]]The first part is Bigger Bombs, which increases blast radius.\n[[YELLOW]]The second is Demolitions Expert, which decreases damage\n[[YELLOW]]from TNT explosions. The third part simply increases the\n[[YELLOW]]amount of ores dropped from TNT and decreases the\n[[YELLOW]]debris dropped.
|
||||
|
||||
##Repair
|
||||
Guides.Repair.Section.0=[[DARK_AQUA]]About Repair:\n[[YELLOW]]Repair allows you to use an iron block to repair armor and\n[[YELLOW]]tools, or a gold block to salvage armor and tools.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]Repair tools or armor using the mcMMO Anvil. This is an\n[[YELLOW]]iron block by default and should not be confused with\n[[YELLOW]]the Vanilla Minecraft Anvil.
|
||||
Guides.Repair.Section.0=[[DARK_AQUA]]About Repair:\n[[YELLOW]]Repair allows you to use an iron block to repair armor and\n[[YELLOW]]tools.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]Repair tools or armor using the mcMMO Anvil. This is an\n[[YELLOW]]iron block by default and should not be confused with\n[[YELLOW]]the Vanilla Minecraft Anvil.
|
||||
Guides.Repair.Section.1=[[DARK_AQUA]]How can I use Repair?\n[[YELLOW]]Place down a mcMMO Anvil and right-click to repair the item \n[[YELLOW]]you're currently holding. This consumes 1 item on every use.
|
||||
Guides.Repair.Section.2=[[DARK_AQUA]]How does Repair Mastery work?\n[[YELLOW]]Repair Mastery increases the repair amount. The extra amount\n[[YELLOW]]repaired is influenced by your Repair skill level.
|
||||
Guides.Repair.Section.3=[[DARK_AQUA]]How does Super Repair work?\n[[YELLOW]]Super Repair is a passive ability. When repairing an item,\n[[YELLOW]]it grants players a chance to repair an item with\n[[YELLOW]]double effectiveness.
|
||||
Guides.Repair.Section.4=[[DARK_AQUA]]How does Arcane Forging work?\n[[YELLOW]]This passive ability allows you to repair items with a certain\n[[YELLOW]]chance of maintaining its enchantments. The enchants may be\n[[YELLOW]]kept at their existing levels, downgraded to a lower level,\n[[YELLOW]]or lost entirely.
|
||||
Guides.Repair.Section.5=[[DARK_AQUA]]How does Salvage work?\n[[YELLOW]]Place down a mcMMO Salvage Anvil and right-click to salvage\n[[YELLOW]]the item you're currently holding.\n[[YELLOW]]This will break the item apart en give back the used ingots.\n[[YELLOW]]Note: You can only salvage fully repaired tools or armor.
|
||||
|
||||
##Salvage
|
||||
Guides.Salvage.Section.0=[[DARK_AQUA]]About Salvage:\n[[YELLOW]]Salvage allows you to use an gold block to salvage armor and\n[[YELLOW]]tools.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]Salvage is a child skill of Repair and Fishing, your Salvage\n[[YELLOW]]skill level is based on your Fishing and Repair skill levels.
|
||||
Guides.Salvage.Section.1=[[DARK_AQUA]]How can I use Salvage?\n[[YELLOW]]Place down a mcMMO Salvage Anvil and right-click to salvage\n[[YELLOW]]the item you're currently holding. This will break apart the item,\n[[YELLOW]]and give back materials used to craft the item.\n\n[[YELLOW]]For example, salvaging an iron pickaxe will give you iron bars.
|
||||
Guides.Salvage.Section.2=[[DARK_AQUA]]How does Advanced Salvage work?\n[[YELLOW]]When unlocked, this ability allows you to salvage damaged items.\n[[YELLOW]]The yield percentage increases as you level up. A higher yield\n[[YELLOW]]means that you can get more materials back.\n[[YELLOW]]With advanced salvage you will always get 1 material back,\n[[YELLOW]]unless the item is too damaged. So you don't have to worry\n[[YELLOW]]about destroying items without getting anything in return.
|
||||
Guides.Salvage.Section.3=[[DARK_AQUA]]To illustrate how this works, here's an example:\n[[YELLOW]]Let's say we salvage a gold pickaxe which is damaged for 20%,\n[[YELLOW]]this means that the maximum amount you could get is only 2\n[[YELLOW]](because the pick is crafted with 3 ingots - each worth\n[[YELLOW]]33,33% durability) which is equal to 66%. If your yield\n[[YELLOW]]percentage is below 66% you are not able to get 2 ingots.\n[[YELLOW]]If it is above this value you are able to gain the "full amount",\n[[YELLOW]]which means that you will get 2 ingots.
|
||||
Guides.Salvage.Section.4=[[DARK_AQUA]]How does Arcane Salvage work?\n[[YELLOW]]This ability allows you to get enchanted books when salvaging\n[[YELLOW]]enchanted items. Depending on your level the chance of\n[[YELLOW]]successfully extracting a full or partial enchantment varies.\n\n[[YELLOW]]When an enchantment is partially extracted, the enchantment\n[[YELLOW]]book will have a lower level enchantment compared to what\n[[YELLOW]]it was on the item.
|
||||
|
||||
##Smelting
|
||||
Guides.Smelting.Section.0=Coming soon...
|
||||
|
||||
##Swords
|
||||
Guides.Swords.Section.0=[[DARK_AQUA]]About Swords:\n[[YELLOW]]This skill awards combat bonuses to anyone fighting with a\n[[YELLOW]]sword.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]XP is gained based on the amount of damage dealt to mobs or \n[[YELLOW]]other players when wielding a sword.
|
||||
@@ -771,9 +796,6 @@ Guides.Swords.Section.1=[[DARK_AQUA]]How does Serrated Strikes work?\n[[YELLOW]]
|
||||
Guides.Swords.Section.2=[[DARK_AQUA]]How does Counter Attack work?\n[[YELLOW]]Counter Attack is an active ability. When blocking and taking\n[[YELLOW]]hits from mobs, you will have a chance to reflect 50% of \n[[YELLOW]]the damage that was taken.
|
||||
Guides.Swords.Section.3=[[DARK_AQUA]]How does Bleed work?\n[[YELLOW]]Bleed causes enemies to take damage every two seconds. The \n[[YELLOW]]target will bleed until the effect wears off, or death, \n[[YELLOW]]whichever comes first.\n[[YELLOW]]The duration of the bleed is increased by your sword skill.
|
||||
|
||||
##Smelting
|
||||
Guides.Smelting.Section.0=Coming soon...
|
||||
|
||||
##Taming
|
||||
Guides.Taming.Section.0=[[DARK_AQUA]]About Taming:\n[[YELLOW]]Taming will give players various combat bonuses when using\n[[YELLOW]]tamed wolves.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]To gain XP in this skill, you need to tame wolves/ocelots or\n[[YELLOW]]get into combat with your wolves.
|
||||
Guides.Taming.Section.1=[[DARK_AQUA]]How does Call of the Wild work?\n[[YELLOW]]Call of the Wild is an active ability that will allow you to summon\n[[YELLOW]]a wolf or an ocelot by your side. You can do this by\n[[YELLOW]]left-clicking while holding bones or fish.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user