mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b700a99c52 | ||
|
|
7294175d9c | ||
|
|
1b17b90f32 | ||
|
|
d27f668a2e | ||
|
|
69dd5769e4 | ||
|
|
7c9d09a878 | ||
|
|
17c64251db | ||
|
|
d728eba5c4 | ||
|
|
429055bae2 | ||
|
|
3f22a8f479 | ||
|
|
aeae60f968 | ||
|
|
a97b889af5 | ||
|
|
0e9953c25b | ||
|
|
869b30fcaa | ||
|
|
44188396b4 | ||
|
|
a7f146a835 | ||
|
|
3a7d88db4f | ||
|
|
9eba2c683b | ||
|
|
8059636b62 | ||
|
|
d78a1efbf6 | ||
|
|
c0b4a33346 | ||
|
|
2cef6700c7 | ||
|
|
df67bd6720 | ||
|
|
655dcb1c9b | ||
|
|
ce32792668 | ||
|
|
4b384abc51 | ||
|
|
82bccd357b | ||
|
|
12709bcd7f | ||
|
|
0b53f8266a | ||
|
|
a07f14e326 | ||
|
|
3349e9cb05 | ||
|
|
0e2746622d | ||
|
|
d9bd0ace9a | ||
|
|
e31b7d5c48 | ||
|
|
4bddbbf56e | ||
|
|
0654f27599 | ||
|
|
3f71dab0b1 | ||
|
|
bd45fff1b4 | ||
|
|
9618e45a11 | ||
|
|
3839373f5a | ||
|
|
1633617006 | ||
|
|
57e33bbf39 | ||
|
|
cddcf36016 | ||
|
|
dff03109a3 | ||
|
|
c0986a1f89 | ||
|
|
cd4c328320 | ||
|
|
03d0ecd450 | ||
|
|
3a809dab32 | ||
|
|
ade9e20cdd | ||
|
|
29520dc95c | ||
|
|
d40d89f29a | ||
|
|
9377de930f | ||
|
|
3219674678 | ||
|
|
a9438ed52b | ||
|
|
09169bd019 | ||
|
|
c30fdef615 | ||
|
|
109e9725a9 | ||
|
|
44ede5c3f8 | ||
|
|
c1161da6de | ||
|
|
80927417f2 | ||
|
|
91d8cd5da8 | ||
|
|
869d731b81 | ||
|
|
f6a18ef777 | ||
|
|
3e084b3b5d | ||
|
|
2c7f931c4d | ||
|
|
6b18cec7fb | ||
|
|
08960a2dbc | ||
|
|
5f4e269efa | ||
|
|
e5f6da01ec | ||
|
|
ae741a1b99 | ||
|
|
78a3ea4765 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,4 +1,4 @@
|
||||
* text
|
||||
* text=auto
|
||||
|
||||
*.png binary
|
||||
*.wav binary
|
||||
|
||||
82
.gitignore
vendored
82
.gitignore
vendored
@@ -1,42 +1,42 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/mcMMO
|
||||
|
||||
# Other Libraries
|
||||
*.jar
|
||||
|
||||
# Atlassian Stuff
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/mcMMO
|
||||
|
||||
# Other Libraries
|
||||
*.jar
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
||||
|
||||
@@ -7,6 +7,33 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.03-dev
|
||||
+ Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker
|
||||
+ Improved stats display for child skills
|
||||
+ Added cooldown between using Chimaera Wings
|
||||
= Fixed bug with Repair not decreasing enchanting levels properly
|
||||
= Fixed bug with Smelting not properly tracking furnaces
|
||||
= Fixed bug with Blast Mining not dropping blocks correctly
|
||||
= Fixed bug with custom blocks not working
|
||||
= Fixed bug with Blast Mining increasing TNT damage.
|
||||
= Fixed bug where Blast Mining was awarding too much XP
|
||||
= Fixed bug where triple drops would award twice the amount of experience in Herbalism and Mining
|
||||
= Fixed bug where Green Thumb would consume wheat instead of seeds
|
||||
= Fixed bug where Green Terra would consume twice the amount of seed when used on crops
|
||||
= Fixed bug where experience would be awarded in Herbalism for some player-placed blocks
|
||||
= Fixed bug where players were unable to salvage leather armor
|
||||
= Fixed bug with repairing using materials with byte metadata
|
||||
= Fixed bug where Fishing was becoming less successful at higher levels
|
||||
= Fixed bug with using Salvage on stacked items.
|
||||
= Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice
|
||||
= Fixed bug where Beast Lore wouldn't work on friendly pets
|
||||
= Fixed bug where Deflect was calculated based on the attacker, not the defender. (We really did this time!)
|
||||
! Moved the Salvage unlock level from config.yml to advanced.yml
|
||||
! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe)
|
||||
! Queue mctop and mcrank commands when using mySQL
|
||||
- Removed option to disable Salvage via the config file. This should be handled via permissions instead.
|
||||
- Removed the option to use Woodcutting without an axe from the config file.
|
||||
|
||||
Version 1.4.02
|
||||
+ Added API to get the skill and power level caps.
|
||||
= Fixed bug where Deflect was calculated based on the attacker, not the defender
|
||||
|
||||
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.02</version>
|
||||
<version>1.4.03-dev1</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>bin</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/${artifactId}.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<destName>mcMMO.jar</destName>
|
||||
</file>
|
||||
</files>
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>bin</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/${artifactId}.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<destName>mcMMO.jar</destName>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
@@ -104,7 +104,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
// Party leader commands
|
||||
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) {
|
||||
if (!mcMMOPlayer.getParty().getLeader().equalsIgnoreCase(player.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
StringBuilder memberList = new StringBuilder();
|
||||
|
||||
for (OfflinePlayer member : playerParty.getMembers()) {
|
||||
if (playerParty.getLeader().equals(member.getName())) {
|
||||
if (playerParty.getLeader().equalsIgnoreCase(member.getName())) {
|
||||
memberList.append(ChatColor.GOLD).append(member.getName()).append(" ");
|
||||
}
|
||||
else if (member.isOnline()) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!member.getName().equals(leaderName)) {
|
||||
if (!member.getName().equalsIgnoreCase(leaderName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -9,11 +9,11 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.database.queuemanager.McRankAsync;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -99,6 +99,10 @@ public class McrankCommand implements CommandExecutor {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
}
|
||||
@@ -119,6 +123,16 @@ public class McrankCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender));
|
||||
//TODO: Localize messages
|
||||
if (mcMMO.queueManager.contains(sender.getName())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please wait for your previous command to process");
|
||||
}
|
||||
|
||||
if (!mcMMO.queueManager.queue(new McRankAsync(playerName, sender))) {
|
||||
// This will only run if for some reason it is unable to add to the queue
|
||||
sender.sendMessage(ChatColor.RED + "Unable to add to queue.");
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW + "Calculating mcMMO rankings...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -9,9 +8,9 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.database.queuemanager.McTopAsync;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -73,12 +72,17 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sql) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender);
|
||||
}
|
||||
else {
|
||||
sqlDisplay(page, skill, sender, command);
|
||||
sqlDisplay(page, skill, sender);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -87,11 +91,6 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information
|
||||
|
||||
String[] info = LeaderboardManager.retrieveInfo(skill, page);
|
||||
@@ -123,7 +122,18 @@ public class MctopCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command));
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
//TODO: Localize messages
|
||||
if (mcMMO.queueManager.contains(sender.getName())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please wait for your previous command to process");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mcMMO.queueManager.queue(new McTopAsync(page, query, sender))) {
|
||||
// This will only run if for some reason it is unable to add to the queue
|
||||
sender.sendMessage(ChatColor.RED + "Unable to add to queue.");
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW + "Calculating mcMMO rankings...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class RepairCommand extends SkillCommand {
|
||||
private int arcaneForgingRank;
|
||||
@@ -41,10 +41,10 @@ public class RepairCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
Repairable diamondRepairable = mcMMO.repairableManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairableManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairableManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairableManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
|
||||
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
@@ -66,7 +66,7 @@ public class RepairCommand extends SkillCommand {
|
||||
superRepairChanceLucky = superRepairStrings[1];
|
||||
|
||||
// ARCANE FORGING
|
||||
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
||||
arcaneForgingRank = UserManager.getPlayer(player).getRepairManager().getArcaneForgingRank();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,8 +122,8 @@ public class RepairCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||
}
|
||||
|
||||
if (canSalvage && Salvage.salvageUnlockLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||
if (canSalvage && Repair.salvageUnlockLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
@@ -155,11 +155,11 @@ public class RepairCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank));
|
||||
|
||||
if (Repair.arcaneForgingEnchantLoss) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank))));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : UserManager.getPlayer(player).getRepairManager().getKeepEnchantChance())));
|
||||
}
|
||||
|
||||
if (Repair.arcaneForgingDowngrades) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank))));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : UserManager.getPlayer(player).getRepairManager().getDowngradeEnchantChance())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -11,6 +12,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
@@ -57,12 +59,23 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName")));
|
||||
|
||||
if (!skill.isChildSkill()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + skillString)));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", SkillUtils.getSkillName(skill) + " " + LocaleLoader.getString("Skills.Child")));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Child", profile.getSkillLevel(skill)));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents")));
|
||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
}
|
||||
}
|
||||
|
||||
if (effectsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
||||
|
||||
@@ -20,6 +20,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/* GENERAL */
|
||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); }
|
||||
|
||||
/* ACROBATICS */
|
||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||
@@ -178,6 +179,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||
public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); }
|
||||
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
|
||||
|
||||
@@ -101,9 +101,12 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
|
||||
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
|
||||
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
|
||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
|
||||
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
|
||||
|
||||
/* Particles */
|
||||
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
||||
@@ -183,9 +186,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
|
||||
@@ -199,8 +200,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
||||
|
||||
/* Woodcutting */
|
||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
||||
|
||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.gmail.nossr50.database.queuemanager;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class AsyncQueueManager implements Runnable {
|
||||
private LinkedBlockingQueue<Queueable> queue;
|
||||
private boolean running;
|
||||
|
||||
public AsyncQueueManager() {
|
||||
this.queue = new LinkedBlockingQueue<Queueable>();
|
||||
this.running = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(running) {
|
||||
try {
|
||||
queue.take().run();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean queue(Queueable task) {
|
||||
return queue.offer(task);
|
||||
}
|
||||
|
||||
public boolean contains(String player) {
|
||||
return queue.contains(new EqualString(player));
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
running = false;
|
||||
// Throw one more Queueable into queue to unblock take()
|
||||
queue.add(new EndThread());
|
||||
}
|
||||
|
||||
private class EqualString {
|
||||
private String player;
|
||||
|
||||
public EqualString(String player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Queueable) {
|
||||
return ((Queueable)obj).getPlayer().equalsIgnoreCase(player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class EndThread implements Queueable {
|
||||
@Override
|
||||
public void run() { }
|
||||
|
||||
@Override
|
||||
public String getPlayer() { return null; }
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,31 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
package com.gmail.nossr50.database.queuemanager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public class McrankCommandAsyncTask implements Runnable {
|
||||
public class McRankAsync implements Queueable {
|
||||
private final String playerName;
|
||||
private final CommandSender sender;
|
||||
private String player;
|
||||
|
||||
public McrankCommandAsyncTask(String playerName, CommandSender sender) {
|
||||
public McRankAsync(String playerName, CommandSender sender) {
|
||||
this.playerName = playerName;
|
||||
this.sender = sender;
|
||||
this.player = sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
@@ -53,4 +54,9 @@ public class McrankCommandAsyncTask implements Runnable {
|
||||
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,39 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
package com.gmail.nossr50.database.queuemanager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommandAsyncTask implements Runnable {
|
||||
public class McTopAsync implements Queueable {
|
||||
|
||||
private CommandSender sender;
|
||||
private String query;
|
||||
private int page;
|
||||
private Command command;
|
||||
private String player;
|
||||
|
||||
public MctopCommandAsyncTask(int page, String query, CommandSender sender, Command command) {
|
||||
public McTopAsync(int page, String query, CommandSender sender) {
|
||||
this.page = page;
|
||||
this.query = query;
|
||||
this.sender = sender;
|
||||
this.command = command;
|
||||
this.player = sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
final HashMap<Integer, ArrayList<String>> userslist = DatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10");
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
@@ -66,4 +56,9 @@ public class MctopCommandAsyncTask implements Runnable {
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.gmail.nossr50.database.queuemanager;
|
||||
|
||||
public interface Queueable {
|
||||
public void run();
|
||||
public String getPlayer();
|
||||
}
|
||||
@@ -28,10 +28,13 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -65,7 +68,7 @@ public class McMMOPlayer {
|
||||
private boolean displaySkillNotifications = true;
|
||||
|
||||
private boolean abilityUse = true;
|
||||
private boolean placedAnvil;
|
||||
private boolean placedRepairAnvil;
|
||||
private boolean placedSalvageAnvil;
|
||||
private boolean godMode;
|
||||
|
||||
@@ -76,6 +79,7 @@ public class McMMOPlayer {
|
||||
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private int recentlyHurt;
|
||||
private int chimaeraWing;
|
||||
private int respawnATS;
|
||||
|
||||
public McMMOPlayer(Player player) {
|
||||
@@ -92,12 +96,7 @@ public class McMMOPlayer {
|
||||
*/
|
||||
try {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
Class<? extends SkillManager> skillManagerClass = skillType.getManagerClass();
|
||||
|
||||
// TODO: The null check is needed only because currently some SkillType doesn't have a valid skillManagerClass
|
||||
if (skillManagerClass != null) {
|
||||
skillManagers.put(skillType, skillManagerClass.getConstructor(McMMOPlayer.class).newInstance(this));
|
||||
}
|
||||
skillManagers.put(skillType, skillType.getManagerClass().getConstructor(McMMOPlayer.class).newInstance(this));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -144,6 +143,10 @@ public class McMMOPlayer {
|
||||
return (MiningManager) skillManagers.get(SkillType.MINING);
|
||||
}
|
||||
|
||||
public RepairManager getRepairManager() {
|
||||
return (RepairManager) skillManagers.get(SkillType.REPAIR);
|
||||
}
|
||||
|
||||
public SmeltingManager getSmeltingManager() {
|
||||
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
||||
}
|
||||
@@ -160,6 +163,10 @@ public class McMMOPlayer {
|
||||
return (UnarmedManager) skillManagers.get(SkillType.UNARMED);
|
||||
}
|
||||
|
||||
public WoodcuttingManager getWoodcuttingManager() {
|
||||
return (WoodcuttingManager) skillManagers.get(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/*
|
||||
* Abilities
|
||||
*/
|
||||
@@ -292,6 +299,23 @@ public class McMMOPlayer {
|
||||
recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Chimaera Wing
|
||||
*/
|
||||
|
||||
public int getLastChimaeraTeleport() {
|
||||
return chimaeraWing;
|
||||
}
|
||||
|
||||
public void setLastChimaeraTeleport(int value) {
|
||||
chimaeraWing = value;
|
||||
}
|
||||
|
||||
public void actualizeLastChimaeraTeleport() {
|
||||
chimaeraWing = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Exploit Prevention
|
||||
*/
|
||||
@@ -308,24 +332,26 @@ public class McMMOPlayer {
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
|
||||
public void togglePlacedAnvil() {
|
||||
placedAnvil = !placedAnvil;
|
||||
public boolean getPlacedAnvil(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
return placedRepairAnvil;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
return placedSalvageAnvil;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean getPlacedAnvil() {
|
||||
return placedAnvil;
|
||||
}
|
||||
public void togglePlacedAnvil(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
placedRepairAnvil = !placedRepairAnvil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Salvage Anvil Placement
|
||||
*/
|
||||
|
||||
public void togglePlacedSalvageAnvil() {
|
||||
placedSalvageAnvil = !placedSalvageAnvil;
|
||||
}
|
||||
|
||||
public Boolean getPlacedSalvageAnvil() {
|
||||
return placedSalvageAnvil;
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
placedSalvageAnvil = !placedSalvageAnvil;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -92,7 +92,7 @@ public class PlayerProfile {
|
||||
}
|
||||
else {
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equals(huds.get(1).get(0))) {
|
||||
if (type.toString().equalsIgnoreCase(huds.get(1).get(0))) {
|
||||
hudType = type;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class PlayerProfile {
|
||||
// Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
|
||||
if (!character[0].equals(playerName)) {
|
||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ public class PlayerProfile {
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Read the line in and copy it to the output it's not the player we want to edit
|
||||
if (!line.split(":")[0].equals(playerName)) {
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -11,10 +11,12 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public enum SkillType {
|
||||
@@ -25,12 +27,12 @@ public enum SkillType {
|
||||
FISHING(FishingManager.class),
|
||||
HERBALISM(HerbalismManager.class, AbilityType.GREEN_TERRA, ToolType.HOE),
|
||||
MINING(MiningManager.class, AbilityType.SUPER_BREAKER, ToolType.PICKAXE),
|
||||
REPAIR(null), // TODO: Create a proper RepairManager class
|
||||
REPAIR(RepairManager.class),
|
||||
SMELTING(SmeltingManager.class),
|
||||
SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD),
|
||||
TAMING(TamingManager.class),
|
||||
UNARMED(UnarmedManager.class, AbilityType.BERSERK, ToolType.FISTS),
|
||||
WOODCUTTING(null, AbilityType.TREE_FELLER, ToolType.AXE); // TODO: Create a proper WoodcuttingManager class
|
||||
WOODCUTTING(WoodcuttingManager.class, AbilityType.TREE_FELLER, ToolType.AXE);
|
||||
|
||||
private Class<? extends SkillManager> managerClass;
|
||||
private AbilityType ability;
|
||||
|
||||
@@ -20,8 +20,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
@@ -35,10 +33,9 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -109,21 +106,15 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
int blockId = blockState.getTypeId();
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockUtils.shouldBeWatched(blockState)) {
|
||||
mcMMO.placeStore.setTrue(blockState);
|
||||
}
|
||||
|
||||
if (Repair.anvilMessagesEnabled) {
|
||||
int blockID = blockState.getTypeId();
|
||||
|
||||
if (blockID == Repair.anvilID) {
|
||||
Repair.placedAnvilCheck(player, blockID);
|
||||
}
|
||||
else if (blockID == Salvage.anvilID) {
|
||||
Salvage.placedAnvilCheck(player, blockID);
|
||||
}
|
||||
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
|
||||
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,12 +137,11 @@ public class BlockListener implements Listener {
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
|
||||
/* Green Terra */
|
||||
if (herbalismManager.canActivateAbility()) {
|
||||
@@ -163,47 +153,31 @@ public class BlockListener implements Listener {
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
||||
|
||||
// Double drops
|
||||
herbalismManager.herbalismBlockCheck(blockState);
|
||||
|
||||
// Triple drops
|
||||
if (herbalismManager.canGreenTerraPlant()) {
|
||||
herbalismManager.herbalismBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
|
||||
if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemUtils.isAxe(heldItem)) {
|
||||
Woodcutting.beginTreeFeller(blockState, player);
|
||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||
|
||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||
woodcuttingManager.processTreeFeller(blockState);
|
||||
}
|
||||
else {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemUtils.isAxe(heldItem)) {
|
||||
Woodcutting.beginWoodcutting(player, blockState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Woodcutting.beginWoodcutting(player, blockState);
|
||||
}
|
||||
woodcuttingManager.woodcuttingBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
|
||||
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
||||
excavationManager.excavationBlockCheck(blockState);
|
||||
|
||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
@@ -368,24 +342,18 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
// Another perm check for the cracked blocks activation
|
||||
else if (BlockUtils.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) {
|
||||
if (Unarmed.blockCracker(player, blockState)) {
|
||||
else if (BlockUtils.affectedByBlockCracker(blockState)) {
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
|
||||
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
|
||||
blockState.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((mcMMOPlayer.getProfile().getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) {
|
||||
if (SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemUtils.isAxe(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
Woodcutting.beginLeafBlower(player, blockState);
|
||||
}
|
||||
}
|
||||
else if (!(heldItem.getType() == Material.SHEARS)) {
|
||||
event.setInstaBreak(true);
|
||||
Woodcutting.beginLeafBlower(player, blockState);
|
||||
}
|
||||
else if (BlockUtils.isLeaves(blockState)) {
|
||||
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) {
|
||||
event.setInstaBreak(true);
|
||||
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@@ -16,6 +17,7 @@ import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
@@ -49,11 +51,12 @@ public class InventoryListener implements Listener {
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
if (furnace.getBurnTime() == 0) {
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
|
||||
BlockState furnaceBlock = furnace.getBlock().getState();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName());
|
||||
if (!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, new FixedMetadataValue(plugin, player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,23 +78,27 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState furnaceBlock = furnace.getBlock().getState();
|
||||
if (furnace.getBurnTime() == 0) {
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.removeFromFurnaceTracker(furnaceBlock);
|
||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||
BlockState furnaceBlock = event.getBlock().getState();
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState furnaceState = furnaceBlock.getState();
|
||||
|
||||
if (furnaceBlock instanceof Furnace) {
|
||||
ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting();
|
||||
if (furnaceState instanceof Furnace) {
|
||||
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString());
|
||||
|
||||
if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) {
|
||||
return;
|
||||
@@ -104,13 +111,15 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||
BlockState furnaceBlock = event.getBlock().getState();
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState furnaceState = furnaceBlock.getState();
|
||||
|
||||
if (furnaceBlock instanceof Furnace) {
|
||||
ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting();
|
||||
if (furnaceState instanceof Furnace) {
|
||||
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString());
|
||||
|
||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||
return;
|
||||
@@ -123,13 +132,15 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||
BlockState furnaceBlock = event.getBlock().getState();
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState furnaceState = furnaceBlock.getState();
|
||||
|
||||
if (furnaceBlock instanceof Furnace) {
|
||||
ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult();
|
||||
if (furnaceState instanceof Furnace) {
|
||||
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemUtils.isSmelted(result)) {
|
||||
Player player = event.getPlayer();
|
||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) {
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString());
|
||||
|
||||
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
@@ -285,14 +284,14 @@ public class PlayerListener implements Listener {
|
||||
int blockID = block.getTypeId();
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||
mcMMO.repairManager.handleRepair(mcMMOPlayer, heldItem);
|
||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairableManager.isRepairable(heldItem)) {
|
||||
UserManager.getPlayer(player).getRepairManager().handleRepair(heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) {
|
||||
Salvage.handleSalvage(player, block.getLocation(), heldItem);
|
||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||
UserManager.getPlayer(player).getRepairManager().handleSalvage(block.getLocation(), heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ import java.util.List;
|
||||
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
@@ -29,6 +27,7 @@ import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.database.queuemanager.AsyncQueueManager;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
@@ -45,10 +44,11 @@ import com.gmail.nossr50.runnables.party.PartyLoaderTask;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.runnables.skills.SkillMonitorTask;
|
||||
import com.gmail.nossr50.skills.child.ChildConfig;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairableManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.UpdateChecker;
|
||||
@@ -66,12 +66,12 @@ public class mcMMO extends JavaPlugin {
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
private HashMap<BlockState, String> furnaceTracker = new HashMap<BlockState, String>();
|
||||
|
||||
public static mcMMO p;
|
||||
|
||||
public static ChunkManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
public static RepairableManager repairableManager;
|
||||
public static AsyncQueueManager queueManager;
|
||||
|
||||
// Jar Stuff
|
||||
public static File mcmmo;
|
||||
@@ -95,6 +95,7 @@ public class mcMMO extends JavaPlugin {
|
||||
public static FixedMetadataValue metadataValue;
|
||||
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
@@ -115,6 +116,7 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
registerEvents();
|
||||
registerCustomRecipes();
|
||||
|
||||
// Setup the leader boards
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
@@ -155,7 +157,7 @@ public class mcMMO extends JavaPlugin {
|
||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +175,12 @@ public class mcMMO extends JavaPlugin {
|
||||
catch (NullPointerException e) {}
|
||||
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
queueManager.disable(); // Disable and stop queue thread
|
||||
queueManager = null; // null static variable
|
||||
}
|
||||
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
|
||||
if (Config.getInstance().getBackupsEnabled()) {
|
||||
@@ -273,22 +281,6 @@ public class mcMMO extends JavaPlugin {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public void addToOpenFurnaceTracker(BlockState furnace, String playerName) {
|
||||
furnaceTracker.put(furnace, playerName);
|
||||
}
|
||||
|
||||
public boolean furnaceIsTracked(BlockState furnace) {
|
||||
return furnaceTracker.containsKey(furnace);
|
||||
}
|
||||
|
||||
public void removeFromFurnaceTracker(BlockState furnace) {
|
||||
furnaceTracker.remove(furnace);
|
||||
}
|
||||
|
||||
public Player getFurnacePlayer(BlockState furnace) {
|
||||
return getServer().getPlayer(furnaceTracker.get(furnace));
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
@@ -377,8 +369,8 @@ public class mcMMO extends JavaPlugin {
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||
repairManager.registerRepairables(repairables);
|
||||
repairableManager = RepairableManagerFactory.getRepairManager(repairables.size());
|
||||
repairableManager.registerRepairables(repairables);
|
||||
|
||||
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
||||
@@ -450,6 +442,12 @@ public class mcMMO extends JavaPlugin {
|
||||
CommandRegistrationManager.registerMchudCommand();
|
||||
}
|
||||
|
||||
private void registerCustomRecipes() {
|
||||
if (Config.getInstance().getChimaeraEnabled()) {
|
||||
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
|
||||
@@ -465,6 +463,11 @@ public class mcMMO extends JavaPlugin {
|
||||
// Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40);
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
queueManager = new AsyncQueueManager();
|
||||
scheduler.runTaskAsynchronously(this, queueManager);
|
||||
}
|
||||
|
||||
// Old & Powerless User remover
|
||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public final class PartyManager {
|
||||
List<Player> nearMembers = new ArrayList<Player>();
|
||||
if (party != null) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (!player.getName().equals(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
if (!player.getName().equalsIgnoreCase(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
nearMembers.add(member);
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public final class PartyManager {
|
||||
public static Party getPlayerParty(String playerName) {
|
||||
for (Party party : parties) {
|
||||
for (OfflinePlayer member : party.getMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
if (member.getName().equalsIgnoreCase(playerName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public final class PartyManager {
|
||||
}
|
||||
else {
|
||||
// If the leaving player was the party leader, appoint a new leader from the party members
|
||||
if (party.getLeader().equals(player.getName())) {
|
||||
if (party.getLeader().equalsIgnoreCase(player.getName())) {
|
||||
String newLeader = members.get(0).getName();
|
||||
party.setLeader(newLeader);
|
||||
}
|
||||
@@ -374,10 +374,10 @@ public final class PartyManager {
|
||||
String leaderName = party.getLeader();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
if (member.getName().equalsIgnoreCase(playerName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
|
||||
}
|
||||
else if (member.getName().equals(leaderName)) {
|
||||
else if (member.getName().equalsIgnoreCase(leaderName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
|
||||
}
|
||||
else {
|
||||
@@ -396,7 +396,7 @@ public final class PartyManager {
|
||||
* @return true if the player can invite
|
||||
*/
|
||||
public static boolean canInvite(Player player, Party party) {
|
||||
if (party.isLocked() && !party.getLeader().equals(player.getName())) {
|
||||
if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -488,13 +488,13 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
partiesFile.set(partyName + ".Members", memberNames);
|
||||
}
|
||||
|
||||
try {
|
||||
partiesFile.save(new File(partiesFilePath));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
partiesFile.save(new File(partiesFilePath));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SQLConversionTask implements Runnable {
|
||||
playerName = character[0];
|
||||
|
||||
// Check for things we don't want put in the DB
|
||||
if (playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information")) {
|
||||
if (playerName == null || playerName.equalsIgnoreCase("null") || playerName.equalsIgnoreCase("#Storage place for user information")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
public class HerbalismBlockUpdaterTask implements Runnable {
|
||||
private BlockState blockState;
|
||||
|
||||
public HerbalismBlockUpdaterTask(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
@@ -15,13 +11,7 @@ public class SkillMonitorTask implements Runnable {
|
||||
public void run() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) {
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
*/
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.skills.herbalism;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
|
||||
public class GreenTerraTimerTask implements Runnable {
|
||||
private BlockState blockState;
|
||||
|
||||
/**
|
||||
* Convert plants affected by the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public GreenTerraTimerTask(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
switch (blockState.getType()) {
|
||||
case CROPS:
|
||||
case CARROT:
|
||||
case POTATO:
|
||||
blockState.setRawData(CropState.MEDIUM.getData());
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case NETHER_WARTS:
|
||||
blockState.setRawData((byte) 0x2);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
blockState.setData(plant);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.skills.herbalism;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
|
||||
public class GreenThumbTimerTask implements Runnable {
|
||||
private BlockState blockState;
|
||||
private int skillLevel;
|
||||
|
||||
/**
|
||||
* Convert plants affected by the Green Thumb ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @param skillLevel The player's Herbalism skill level
|
||||
*/
|
||||
public GreenThumbTimerTask(BlockState blockState, int skillLevel) {
|
||||
this.blockState = blockState;
|
||||
this.skillLevel = skillLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case CROPS:
|
||||
case CARROT:
|
||||
case POTATO:
|
||||
blockState.setRawData((byte) greenThumbStage);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (greenThumbStage > 2) {
|
||||
blockState.setRawData((byte) 0x2);
|
||||
}
|
||||
else if (greenThumbStage == 2) {
|
||||
blockState.setRawData((byte) 0x1);
|
||||
}
|
||||
else {
|
||||
blockState.setRawData((byte) 0x0);
|
||||
}
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
|
||||
if (greenThumbStage > 1) {
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
}
|
||||
else {
|
||||
plant.setSize(CocoaPlantSize.SMALL);
|
||||
}
|
||||
blockState.setData(plant);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class ArcheryManager extends SkillManager {
|
||||
Location shooterLocation = player.getLocation();
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
|
||||
if (shooterLocation.getWorld() != targetLocation.getWorld()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public class FishingManager extends SkillManager {
|
||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
|
||||
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,24 +63,20 @@ public class Herbalism {
|
||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
Material blockType = blockState.getType();
|
||||
int dropAmount = 0;
|
||||
|
||||
// Handle the original block
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
dropAmount++;
|
||||
}
|
||||
int dropAmount = mcMMO.placeStore.isTrue(block) ? 0 : 1;
|
||||
|
||||
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
||||
for (int y = 1; y < 3; y++) {
|
||||
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
||||
Material relativeBlockType = relativeBlock.getType();
|
||||
|
||||
// If the first one is air, so is the next one
|
||||
if (relativeBlockType == Material.AIR) {
|
||||
if (relativeBlock.getType() != blockType) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
|
||||
if (mcMMO.placeStore.isTrue(relativeBlock)) {
|
||||
mcMMO.placeStore.setFalse(relativeBlock);
|
||||
}
|
||||
else {
|
||||
dropAmount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package com.gmail.nossr50.skills.herbalism;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@@ -20,8 +22,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask;
|
||||
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -76,7 +77,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
||||
return SkillUtils.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange);
|
||||
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,65 +108,63 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process double drops & XP gain for Herbalism.
|
||||
*
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
Material blockType = blockState.getType();
|
||||
Material material = blockState.getType();
|
||||
boolean oneBlockPlant = (material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK) ? false : true;
|
||||
|
||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType);
|
||||
CustomBlock customBlock = null;
|
||||
if (oneBlockPlant && mcMMO.placeStore.isTrue(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material);
|
||||
ItemStack drop = null;
|
||||
int amount = 1;
|
||||
int xp = 0;
|
||||
int dropAmount = 1;
|
||||
ItemStack dropItem = null;
|
||||
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||
|
||||
if (herbalismBlock != null) {
|
||||
if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
||||
xp = herbalismBlock.getXpGain() * dropAmount;
|
||||
if (herbalismBlock.hasGreenThumbPermission(getPlayer())) {
|
||||
processGreenThumbPlants(blockState, greenTerra);
|
||||
}
|
||||
else if (herbalismBlock.hasGreenThumbPermission(player)) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
xp = herbalismBlock.getXpGain();
|
||||
processGreenThumbPlants(blockState);
|
||||
|
||||
xp = herbalismBlock.getXpGain();
|
||||
|
||||
if (herbalismBlock.canDoubleDrop() && Permissions.doubleDrops(getPlayer(), skill)) {
|
||||
drop = herbalismBlock.getDropItem();
|
||||
}
|
||||
else {
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
xp = herbalismBlock.getXpGain();
|
||||
}
|
||||
|
||||
if (!oneBlockPlant) {
|
||||
amount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
||||
xp *= amount;
|
||||
}
|
||||
}
|
||||
else {
|
||||
customBlock = ModUtils.getCustomBlock(blockState);
|
||||
dropItem = customBlock.getItemDrop();
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
}
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
|
||||
Misc.dropItems(location, dropItem, dropAmount);
|
||||
}
|
||||
else if (customBlock != null) {
|
||||
if (Permissions.doubleDrops(getPlayer(), skill)) {
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
|
||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||
drop = customBlock.getItemDrop();
|
||||
amount = Misc.getRandom().nextInt(maximumDropAmount - minimumDropAmount + 1) + minimumDropAmount;
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
|
||||
if (drop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
|
||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||
Misc.dropItems(blockState.getLocation(), drop, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,29 +268,82 @@ public class HerbalismManager extends SkillManager {
|
||||
* Process the Green Thumb ability for plants.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @param greenTerra
|
||||
*/
|
||||
private void processGreenThumbPlants(BlockState blockState) {
|
||||
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
||||
Player player = getPlayer();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
|
||||
ItemStack seed = (blockState.getType() == Material.CROPS) ? new ItemStack(Material.SEEDS) : HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
|
||||
|
||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0);
|
||||
if (!greenTerra && !SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||
return;
|
||||
}
|
||||
else if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimerTask(blockState, getSkillLevel()), 0);
|
||||
if (!handleBlockState(blockState, greenTerra)) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new HerbalismBlockUpdaterTask(blockState), 0);
|
||||
}
|
||||
|
||||
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
|
||||
switch (blockState.getType()) {
|
||||
case CROPS:
|
||||
case CARROT:
|
||||
case POTATO:
|
||||
if (greenTerra) {
|
||||
blockState.setRawData(CropState.MEDIUM.getData()); // 2
|
||||
}
|
||||
else {
|
||||
blockState.setRawData(getGreenThumbStage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (greenTerra) {
|
||||
blockState.setRawData((byte) 2);
|
||||
}
|
||||
else {
|
||||
int greenThumbStage = getGreenThumbStage();
|
||||
|
||||
if (greenThumbStage > 2) {
|
||||
blockState.setRawData((byte) 2);
|
||||
}
|
||||
else if (greenThumbStage == 2) {
|
||||
blockState.setRawData((byte) 1);
|
||||
}
|
||||
else {
|
||||
blockState.setRawData((byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
|
||||
if (greenTerra || getGreenThumbStage() > 1) {
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
}
|
||||
else {
|
||||
plant.setSize(CocoaPlantSize.SMALL);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private byte getGreenThumbStage() {
|
||||
return (byte) Math.min(Math.min(getProfile().getSkillLevel(skill), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ public class Mining {
|
||||
protected static void handleSilkTouchDrops(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
|
||||
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (blockType) {
|
||||
case ENDER_STONE:
|
||||
case GOLD_ORE:
|
||||
@@ -76,7 +72,7 @@ public class Mining {
|
||||
|
||||
default:
|
||||
if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -89,13 +85,7 @@ public class Mining {
|
||||
*/
|
||||
protected static void handleMiningDrops(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
|
||||
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = blockState.getLocation();
|
||||
ItemStack dropItem;
|
||||
|
||||
switch (blockType) {
|
||||
case COAL_ORE:
|
||||
@@ -130,7 +120,7 @@ public class Mining {
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
dropItem = customBlock.getItemDrop();
|
||||
ItemStack dropItem = customBlock.getItemDrop();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
@@ -54,18 +55,31 @@ public class MiningManager extends SkillManager{
|
||||
*/
|
||||
public void miningBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
int xp = Mining.getBlockXp(blockState);
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
Mining.handleSilkTouchDrops(blockState);
|
||||
}
|
||||
else {
|
||||
Mining.handleMiningDrops(blockState);
|
||||
}
|
||||
applyXpGain(Mining.getBlockXp(blockState));
|
||||
|
||||
if (Permissions.doubleDrops(player, skill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
Material material = blockState.getType();
|
||||
|
||||
if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean silkTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH);
|
||||
|
||||
for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) {
|
||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
||||
if (silkTouch) {
|
||||
Mining.handleSilkTouchDrops(blockState);
|
||||
}
|
||||
else {
|
||||
Mining.handleMiningDrops(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,11 +142,10 @@ public class MiningManager extends SkillManager{
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
}
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
||||
}
|
||||
}
|
||||
@@ -142,7 +155,7 @@ public class MiningManager extends SkillManager{
|
||||
if (debrisYield > 0) {
|
||||
for (BlockState blockState : debris) {
|
||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +173,7 @@ public class MiningManager extends SkillManager{
|
||||
}
|
||||
|
||||
public int processDemolitionsExpertise(int damage) {
|
||||
return (int) (damage * (100.0 - getBlastDamageModifier()));
|
||||
return (int) (damage * ((100.0D - getBlastDamageModifier()) / 100.0D));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,29 +1,49 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
|
||||
public class Repair {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); }
|
||||
@Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); }
|
||||
@Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); }
|
||||
@Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); }
|
||||
@Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); }
|
||||
@Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); }
|
||||
@Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); }
|
||||
@Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); }
|
||||
@Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }};
|
||||
|
||||
int numerical;
|
||||
|
||||
private Tier(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
public int toNumerical() {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected int getKeepEnchantChance();
|
||||
abstract protected int getDowngradeEnchantChance();
|
||||
}
|
||||
|
||||
public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel();
|
||||
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
||||
|
||||
@@ -33,248 +53,164 @@ public class Repair {
|
||||
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
||||
public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled();
|
||||
|
||||
public static int anvilID = Config.getInstance().getRepairAnvilId();
|
||||
public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel();
|
||||
|
||||
public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId();
|
||||
public static int repairAnvilId = Config.getInstance().getRepairAnvilId();
|
||||
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
|
||||
|
||||
/**
|
||||
* Get current Arcane Forging rank.
|
||||
* Checks if the item is salvageable.
|
||||
*
|
||||
* @param profile The PlayerProfile of the player to get the rank for
|
||||
* @return The player's current Arcane Forging rank
|
||||
* @param item Item to check
|
||||
* @return true if the item is salvageable, false otherwise
|
||||
*/
|
||||
public static int getArcaneForgingRank(PlayerProfile profile) {
|
||||
int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) {
|
||||
return 4;
|
||||
public static boolean isSalvageable(ItemStack item) {
|
||||
if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(item) || ItemUtils.isStringTool(item) || item.getType() == Material.BUCKET)) {
|
||||
return true;
|
||||
}
|
||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels3()) {
|
||||
|
||||
if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(item)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the inventory for an item and return the index.
|
||||
*
|
||||
* @param inventory PlayerInventory to scan
|
||||
* @param itemId Item id to look for
|
||||
* @return index location where the item was found, or -1 if not found
|
||||
*/
|
||||
protected static int findInInventory(PlayerInventory inventory, int itemId) {
|
||||
int location = inventory.first(itemId);
|
||||
|
||||
// VALIDATE
|
||||
if (inventory.getItem(location).getTypeId() == itemId) {
|
||||
return location;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the inventory for an item and return the index.
|
||||
*
|
||||
* @param inventory PlayerInventory to scan
|
||||
* @param itemId Item id to look for
|
||||
* @param metadata Metadata to look for
|
||||
* @return index location where the item was found, or -1 if not found
|
||||
*/
|
||||
protected static int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
|
||||
int location = -1;
|
||||
|
||||
ItemStack[] contents = inventory.getContents();
|
||||
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack item = contents[i];
|
||||
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getTypeId() == itemId && item.getData().getData() == metadata) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the amount of items in this slot by one
|
||||
*
|
||||
* @param inventory PlayerInventory to work in
|
||||
* @param index Item index to decrement
|
||||
*/
|
||||
protected static void removeOneFrom(PlayerInventory inventory, int index) {
|
||||
ItemStack item = inventory.getItem(index).clone();
|
||||
item.setAmount(1);
|
||||
|
||||
inventory.removeItem(item);
|
||||
}
|
||||
|
||||
protected static String[] getSpoutAnvilMessages(int blockId) {
|
||||
if (blockId == repairAnvilId) {
|
||||
return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")};
|
||||
}
|
||||
|
||||
if (blockId == salvageAnvilId) {
|
||||
return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"};
|
||||
}
|
||||
|
||||
return new String[] {"", ""};
|
||||
}
|
||||
|
||||
protected static String getAnvilMessage(int blockId) {
|
||||
if (blockId == repairAnvilId) {
|
||||
return LocaleLoader.getString("Repair.Listener.Anvil");
|
||||
}
|
||||
|
||||
if (blockId == salvageAnvilId) {
|
||||
return LocaleLoader.getString("Repair.Listener.Anvil2");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
protected static Material getSalvagedItem(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;
|
||||
}
|
||||
}
|
||||
|
||||
protected static int getSalvagedAmount(ItemStack inHand) {
|
||||
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
|
||||
return 3;
|
||||
}
|
||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels2()) {
|
||||
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
|
||||
return 1;
|
||||
}
|
||||
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
|
||||
return 2;
|
||||
}
|
||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) {
|
||||
return 1;
|
||||
else if (ItemUtils.isHelmet(inHand)) {
|
||||
return 5;
|
||||
}
|
||||
else if (ItemUtils.isChestplate(inHand)) {
|
||||
return 8;
|
||||
}
|
||||
else if (ItemUtils.isLeggings(inHand)) {
|
||||
return 7;
|
||||
}
|
||||
else if (ItemUtils.isBoots(inHand)) {
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles removing & downgrading enchants.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param is Item being repaired
|
||||
*/
|
||||
protected static void addEnchants(Player player, ItemStack is) {
|
||||
if (Permissions.arcaneBypass(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
|
||||
return;
|
||||
}
|
||||
Map<Enchantment, Integer> enchants = is.getEnchantments();
|
||||
|
||||
if (enchants.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int rank = getArcaneForgingRank(UserManager.getPlayer(player).getProfile());
|
||||
|
||||
if (rank == 0 || !Permissions.arcaneForging(player)) {
|
||||
for (Enchantment x : enchants.keySet()) {
|
||||
is.removeEnchantment(x);
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean downgraded = false;
|
||||
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR);
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (arcaneForgingDowngrades && enchantLevel > 1) {
|
||||
if (Misc.getRandom().nextInt(activationChance) < getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, --enchantLevel);
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
is.removeEnchantment(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> newEnchants = is.getEnchantments();
|
||||
|
||||
if (newEnchants.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail"));
|
||||
}
|
||||
else if (downgraded || newEnchants.size() < enchants.size()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets chance of keeping enchantment during repair.
|
||||
*
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of keeping the enchantment
|
||||
*/
|
||||
public static int getEnchantChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4();
|
||||
|
||||
case 3:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3();
|
||||
|
||||
case 2:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2();
|
||||
|
||||
case 1:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets chance of enchantment being downgraded during repair.
|
||||
*
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of the enchantment being downgraded
|
||||
*/
|
||||
public static int getDowngradeChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4();
|
||||
|
||||
case 3:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3();
|
||||
|
||||
case 2:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2();
|
||||
|
||||
case 1:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1();
|
||||
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Super Repair bonus.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @return true if bonus granted, false otherwise
|
||||
*/
|
||||
public static boolean checkPlayerProcRepair(Player player) {
|
||||
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
int chance = (int) ((superRepairMaxChance / superRepairMaxBonusLevel) * skillLevel);
|
||||
if (skillLevel >= superRepairMaxBonusLevel) {
|
||||
chance = (int) superRepairMaxChance;
|
||||
}
|
||||
|
||||
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR);
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.superRepair(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
* @param player The player placing the anvil
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.getPlacedAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2"), Material.getMaterial(anvilID));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
mcMMOPlayer.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Xp gain for repair events.
|
||||
*
|
||||
* @param mcMMOPlayer Player repairing the item
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
*/
|
||||
protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) {
|
||||
short dif = (short) ((durabilityBefore - durabilityAfter) * modify);
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @param skillLevel the skillLevel of the player in Repair
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
|
||||
float bonus;
|
||||
if (skillLevel >= repairMasteryMaxBonusLevel) {
|
||||
bonus = (float) (repairMasteryMaxBonus / 100F);
|
||||
}
|
||||
else {
|
||||
bonus = (((float) skillLevel) / ((float) repairMasteryMaxBonusLevel)) * (float) ((repairMasteryMaxBonus) / 100F);
|
||||
}
|
||||
|
||||
if (Permissions.repairMastery(player)) {
|
||||
bonus = repairAmount * bonus;
|
||||
repairAmount += (int) bonus;
|
||||
}
|
||||
|
||||
if (checkPlayerProcRepair(player)) {
|
||||
repairAmount = (int) (repairAmount * 2D);
|
||||
}
|
||||
|
||||
if (repairAmount <= 0 || repairAmount > 32767) {
|
||||
repairAmount = 32767;
|
||||
}
|
||||
|
||||
durability -= repairAmount;
|
||||
|
||||
if (durability < 0) {
|
||||
durability = 0;
|
||||
}
|
||||
|
||||
return durability;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,350 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
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.PlayerInventory;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair.Tier;
|
||||
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 interface RepairManager {
|
||||
/**
|
||||
* Register a repairable with the RepairManager
|
||||
*
|
||||
* @param repairable Repairable to register
|
||||
*/
|
||||
public void registerRepairable(Repairable repairable);
|
||||
public class RepairManager extends SkillManager {
|
||||
public RepairManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.REPAIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a list of repairables with the RepairManager
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
* @param repairables List<Repairable> to register
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public void registerRepairables(List<Repairable> repairables);
|
||||
public void placedAnvilCheck(int anvilId) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (mcMMOPlayer.getPlacedAnvil(anvilId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||
String[] spoutMessages = Repair.getSpoutAnvilMessages(anvilId);
|
||||
spoutPlayer.sendNotification(spoutMessages[0], spoutMessages[1], Material.getMaterial(anvilId));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(Repair.getAnvilMessage(anvilId));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(Repair.getAnvilMessage(anvilId));
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
mcMMOPlayer.togglePlacedAnvil(anvilId);
|
||||
}
|
||||
|
||||
public void handleRepair(ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
int itemId = item.getTypeId();
|
||||
|
||||
Repairable repairable = mcMMO.repairableManager.getRepairable(itemId);
|
||||
|
||||
// Permissions checks on material and item types
|
||||
if (!repairable.getRepairItemType().getPermissions(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!repairable.getRepairMaterialType().getPermissions(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = getSkillLevel();
|
||||
int minimumRepairableLevel = repairable.getMinimumLevel();
|
||||
|
||||
// Level check
|
||||
if (skillLevel < minimumRepairableLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(itemId)));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
int repairMaterialId = repairable.getRepairMaterialId();
|
||||
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
|
||||
|
||||
// Check if they have the proper material to repair with
|
||||
if (!inventory.contains(repairMaterialId)) {
|
||||
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterialId));
|
||||
|
||||
if (repairMaterialMetadata != (byte) -1) {
|
||||
// TODO: Do something nicer than append the metadata as a :# ?
|
||||
if (Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata) == -1) {
|
||||
message += ":" + repairMaterialMetadata;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
short startDurability = item.getDurability();
|
||||
|
||||
// Do not repair if at full durability
|
||||
if (startDurability <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not repair stacked items
|
||||
if (item.getAmount() != 1) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear ability buffs before trying to repair.
|
||||
SkillUtils.removeAbilityBuff(item);
|
||||
|
||||
// Lets get down to business,
|
||||
// To defeat, the huns.
|
||||
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
|
||||
short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons?
|
||||
|
||||
// We're going to hold onto our repair item location
|
||||
int repairItemLocation;
|
||||
if (repairable.getRepairMaterialMetadata() == (byte) -1) {
|
||||
repairItemLocation = Repair.findInInventory(inventory, repairMaterialId);
|
||||
}
|
||||
else {
|
||||
// Special case for when the repairable has metadata that must be addressed
|
||||
repairItemLocation = Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata);
|
||||
}
|
||||
|
||||
// This should never happen, but if it does we need to complain loudly about it.
|
||||
if (repairItemLocation == -1) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Error"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Call event
|
||||
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle the enchants
|
||||
if (Repair.arcaneForgingEnchantLoss) {
|
||||
addEnchants(item);
|
||||
}
|
||||
|
||||
// Remove the item
|
||||
Repair.removeOneFrom(inventory, repairItemLocation);
|
||||
|
||||
// Give out XP like candy
|
||||
applyXpGain((int) ((startDurability - newDurability) * repairable.getXpMultiplier()) * 10);
|
||||
|
||||
// BWONG BWONG BWONG
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
|
||||
// Repair the item!
|
||||
item.setDurability(newDurability);
|
||||
}
|
||||
|
||||
public void handleSalvage(Location location, ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
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.getSalvagedItem(item)), Repair.getSalvagedAmount(item) * item.getAmount());
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an item is repairable
|
||||
* Gets the Arcane Forging rank
|
||||
*
|
||||
* @param itemId id to check if repairable
|
||||
* @return true if repairable, false if not
|
||||
* @return the current Arcane Forging rank
|
||||
*/
|
||||
public boolean isRepairable(int itemId);
|
||||
public int getArcaneForgingRank() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an item is repairable
|
||||
* Gets chance of keeping enchantment during repair.
|
||||
*
|
||||
* @param itemStack Item to check if repairable
|
||||
* @return true if repairable, false if not
|
||||
* @return The chance of keeping the enchantment
|
||||
*/
|
||||
public boolean isRepairable(ItemStack itemStack);
|
||||
public int getKeepEnchantChance() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getKeepEnchantChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repairable with this id
|
||||
* Gets chance of enchantment being downgraded during repair.
|
||||
*
|
||||
* @param id Id of the repairable to look for
|
||||
* @return the repairable, can be null
|
||||
* @return The chance of the enchantment being downgraded
|
||||
*/
|
||||
public Repairable getRepairable(int id);
|
||||
public int getDowngradeEnchantChance() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getDowngradeEnchantChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the repairing of this object
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param mcMMOPlayer Player that is repairing an item
|
||||
* @param item ItemStack that is being repaired
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
public void handleRepair(McMMOPlayer mcMMOPlayer, ItemStack item);
|
||||
private short repairCalculate(short durability, int repairAmount) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (Permissions.repairMastery(player)) {
|
||||
double bonus = repairAmount * Math.min((((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * getSkillLevel()) / 100.0D), Repair.repairMasteryMaxBonus / 100.0D);
|
||||
repairAmount += bonus;
|
||||
}
|
||||
|
||||
if (Permissions.superRepair(player) && checkPlayerProcRepair()) {
|
||||
repairAmount *= 2.0D;
|
||||
}
|
||||
|
||||
if (repairAmount <= 0 || repairAmount > Short.MAX_VALUE) {
|
||||
repairAmount = Short.MAX_VALUE;
|
||||
}
|
||||
|
||||
return (short) Math.max(durability - repairAmount, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Super Repair bonus.
|
||||
*
|
||||
* @return true if bonus granted, false otherwise
|
||||
*/
|
||||
private boolean checkPlayerProcRepair() {
|
||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Repair.superRepairMaxChance, Repair.superRepairMaxBonusLevel)) {
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles removing & downgrading enchants.
|
||||
*
|
||||
* @param item Item being repaired
|
||||
*/
|
||||
private void addEnchants(ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
|
||||
Map<Enchantment, Integer> enchants = item.getEnchantments();
|
||||
|
||||
if (enchants.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.arcaneBypass(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (getArcaneForgingRank() == 0 || !Permissions.arcaneForging(player)) {
|
||||
for (Enchantment enchant : enchants.keySet()) {
|
||||
item.removeEnchantment(enchant);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean downgraded = false;
|
||||
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
||||
item.addEnchantment(enchantment, enchantLevel - 1);
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
item.removeEnchantment(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> newEnchants = item.getEnchantments();
|
||||
|
||||
if (newEnchants.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail"));
|
||||
}
|
||||
else if (downgraded || newEnchants.size() < enchants.size()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public class RepairManagerFactory {
|
||||
public static RepairManager getRepairManager() {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairManager();
|
||||
}
|
||||
|
||||
public static RepairManager getRepairManager(int repairablesSize) {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairManager(repairablesSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface RepairableManager {
|
||||
/**
|
||||
* Register a repairable with the RepairManager
|
||||
*
|
||||
* @param repairable Repairable to register
|
||||
*/
|
||||
public void registerRepairable(Repairable repairable);
|
||||
|
||||
/**
|
||||
* Register a list of repairables with the RepairManager
|
||||
*
|
||||
* @param repairables List<Repairable> to register
|
||||
*/
|
||||
public void registerRepairables(List<Repairable> repairables);
|
||||
|
||||
/**
|
||||
* Checks if an item is repairable
|
||||
*
|
||||
* @param itemId id to check if repairable
|
||||
* @return true if repairable, false if not
|
||||
*/
|
||||
public boolean isRepairable(int itemId);
|
||||
|
||||
/**
|
||||
* Checks if an item is repairable
|
||||
*
|
||||
* @param itemStack Item to check if repairable
|
||||
* @return true if repairable, false if not
|
||||
*/
|
||||
public boolean isRepairable(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Gets the repairable with this id
|
||||
*
|
||||
* @param id Id of the repairable to look for
|
||||
* @return the repairable, can be null
|
||||
*/
|
||||
public Repairable getRepairable(int id);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public class RepairableManagerFactory {
|
||||
public static RepairableManager getRepairManager() {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairableManager();
|
||||
}
|
||||
|
||||
public static RepairableManager getRepairManager(int repairablesSize) {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairableManager(repairablesSize);
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
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.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class Salvage {
|
||||
public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel();
|
||||
public static int anvilID = Config.getInstance().getSalvageAnvilId();
|
||||
|
||||
public static void handleSalvage(final Player player, final Location location, final ItemStack item) {
|
||||
if (!Config.getInstance().getSalvageEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGameMode() == GameMode.SURVIVAL) {
|
||||
final int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel < salvageUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
|
||||
return;
|
||||
}
|
||||
|
||||
final float currentDurability = item.getDurability();
|
||||
|
||||
if (currentDurability == 0) {
|
||||
player.setItemInHand(new ItemStack(Material.AIR));
|
||||
location.setY(location.getY() + 1);
|
||||
|
||||
Misc.dropItems(location, new ItemStack(getSalvagedItem(item)), getSalvagedAmount(item));
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
* @param player The player placing the anvil
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(final Player player, final int anvilID) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.getPlacedSalvageAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||
spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2"));
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
mcMMOPlayer.togglePlacedSalvageAnvil();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is salvageable.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is salvageable, false otherwise
|
||||
*/
|
||||
public static boolean isSalvageable(final ItemStack is) {
|
||||
if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(is) || ItemUtils.isStringTool(is) || is.getType() == Material.BUCKET)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(is)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Material getSalvagedItem(final 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;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSalvagedAmount(final ItemStack inHand) {
|
||||
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
|
||||
return 3;
|
||||
}
|
||||
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
|
||||
return 1;
|
||||
}
|
||||
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
|
||||
return 2;
|
||||
}
|
||||
else if (ItemUtils.isHelmet(inHand)) {
|
||||
return 5;
|
||||
}
|
||||
else if (ItemUtils.isChestplate(inHand)) {
|
||||
return 8;
|
||||
}
|
||||
else if (ItemUtils.isLeggings(inHand)) {
|
||||
return 7;
|
||||
}
|
||||
else if (ItemUtils.isBoots(inHand)) {
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SimpleRepairManager implements RepairManager {
|
||||
private HashMap<Integer, Repairable> repairables;
|
||||
|
||||
protected SimpleRepairManager() {
|
||||
this(55);
|
||||
}
|
||||
|
||||
protected SimpleRepairManager(int repairablesSize) {
|
||||
this.repairables = new HashMap<Integer, Repairable>(repairablesSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRepairable(Repairable repairable) {
|
||||
Integer itemId = repairable.getItemId();
|
||||
repairables.put(itemId, repairable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRepairables(List<Repairable> repairables) {
|
||||
for (Repairable repairable : repairables) {
|
||||
registerRepairable(repairable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(int itemId) {
|
||||
return repairables.containsKey(itemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(ItemStack itemStack) {
|
||||
return isRepairable(itemStack.getTypeId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repairable getRepairable(int id) {
|
||||
return repairables.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRepair(McMMOPlayer mcMMOPlayer, ItemStack item) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Repairable repairable = repairables.get(item.getTypeId());
|
||||
|
||||
// Permissions checks on material and item types
|
||||
if (!repairable.getRepairItemType().getPermissions(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!repairable.getRepairMaterialType().getPermissions(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
// Level check
|
||||
if (skillLevel < repairable.getMinimumLevel()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", repairable.getMinimumLevel(), StringUtils.getPrettyItemString(item.getTypeId())));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
// Check if they have the proper material to repair with
|
||||
if (!inventory.contains(repairable.getRepairMaterialId())) {
|
||||
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairable.getRepairMaterialId()));
|
||||
if (repairable.getRepairMaterialMetadata() != (byte) -1) {
|
||||
// TODO: Do something nicer than append the metadata as a :# ?
|
||||
if (findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) {
|
||||
message += ":" + repairable.getRepairMaterialMetadata();
|
||||
}
|
||||
}
|
||||
player.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
short startDurability = item.getDurability();
|
||||
|
||||
// Do not repair if at full durability
|
||||
if (startDurability <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not repair stacked items
|
||||
if (item.getAmount() != 1) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear ability buffs before trying to repair.
|
||||
SkillUtils.removeAbilityBuff(item);
|
||||
|
||||
// Lets get down to business,
|
||||
// To defeat, the huns.
|
||||
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
|
||||
short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount); // When I asked for sons?
|
||||
|
||||
// We're going to hold onto our repair item location
|
||||
int repairItemLocation;
|
||||
if (repairable.getRepairMaterialMetadata() == (byte) -1) {
|
||||
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId());
|
||||
}
|
||||
else {
|
||||
// Special case for when the repairable has metadata that must be addressed
|
||||
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata());
|
||||
}
|
||||
|
||||
// This should never happen, but if it does we need to complain loudly about it.
|
||||
if (repairItemLocation == -1) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Error"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Call event
|
||||
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle the enchants
|
||||
if (AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.arcaneBypass(player)) {
|
||||
// Generalize away enchantment work
|
||||
Repair.addEnchants(player, item);
|
||||
}
|
||||
|
||||
// Remove the item
|
||||
removeOneFrom(inventory, repairItemLocation);
|
||||
|
||||
// Give out XP like candy
|
||||
Repair.xpHandler(mcMMOPlayer, startDurability, newDurability, repairable.getXpMultiplier());
|
||||
|
||||
// Repair the item!
|
||||
item.setDurability(newDurability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the amount of items in this slot by one
|
||||
*
|
||||
* @param inventory PlayerInventory to work in
|
||||
* @param index Item index to decrement
|
||||
*/
|
||||
private void removeOneFrom(PlayerInventory inventory, int index) {
|
||||
ItemStack item = inventory.getItem(index).clone();
|
||||
item.setAmount(1);
|
||||
|
||||
inventory.removeItem(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the inventory for an item and return the index.
|
||||
*
|
||||
* @param inventory PlayerInventory to scan
|
||||
* @param itemId Item id to look for
|
||||
* @return index location where the item was found, or -1 if not found
|
||||
*/
|
||||
private int findInInventory(PlayerInventory inventory, int itemId) {
|
||||
int location = inventory.first(itemId);
|
||||
|
||||
// VALIDATE
|
||||
if (inventory.getItem(location).getTypeId() == itemId) {
|
||||
return location;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the inventory for an item and return the index.
|
||||
*
|
||||
* @param inventory PlayerInventory to scan
|
||||
* @param itemId Item id to look for
|
||||
* @param metadata Metadata to look for
|
||||
* @return index location where the item was found, or -1 if not found
|
||||
*/
|
||||
private int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
|
||||
int location = -1;
|
||||
|
||||
for (ItemStack item : inventory.getContents()) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getTypeId() == itemId && item.getData().getData() == metadata) {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SimpleRepairableManager implements RepairableManager {
|
||||
private HashMap<Integer, Repairable> repairables;
|
||||
|
||||
protected SimpleRepairableManager() {
|
||||
this(55);
|
||||
}
|
||||
|
||||
protected SimpleRepairableManager(int repairablesSize) {
|
||||
this.repairables = new HashMap<Integer, Repairable>(repairablesSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRepairable(Repairable repairable) {
|
||||
Integer itemId = repairable.getItemId();
|
||||
repairables.put(itemId, repairable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRepairables(List<Repairable> repairables) {
|
||||
for (Repairable repairable : repairables) {
|
||||
registerRepairable(repairable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(int itemId) {
|
||||
return repairables.containsKey(itemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(ItemStack itemStack) {
|
||||
return isRepairable(itemStack.getTypeId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repairable getRepairable(int id) {
|
||||
return repairables.get(id);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class Unarmed {
|
||||
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
|
||||
@@ -24,23 +19,4 @@ public class Unarmed {
|
||||
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
|
||||
|
||||
public static double berserkDamageModifier = 1.5;
|
||||
|
||||
public static boolean blockCracker(Player player, BlockState blockState) {
|
||||
if (SkillUtils.blockBreakSimulate(blockState.getBlock(), player, false)) {
|
||||
Material type = blockState.getType();
|
||||
|
||||
switch (type) {
|
||||
case SMOOTH_BRICK:
|
||||
if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) {
|
||||
blockState.setRawData((byte) 0x2);
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -44,6 +45,25 @@ public class UnarmedManager extends SkillManager {
|
||||
return player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player);
|
||||
}
|
||||
|
||||
public boolean canUseBlockCracker() {
|
||||
return Permissions.blockCracker(getPlayer());
|
||||
}
|
||||
|
||||
public boolean blockCrackerCheck(BlockState blockState) {
|
||||
Material type = blockState.getType();
|
||||
|
||||
switch (type) {
|
||||
case SMOOTH_BRICK:
|
||||
if (Unarmed.blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) {
|
||||
blockState.setRawData((byte) 0x2);
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for disarm.
|
||||
*
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
package com.gmail.nossr50.skills.woodcutting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Tree;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public final class TreeFeller {
|
||||
private static boolean treeFellerReachedThreshold = false;
|
||||
|
||||
private TreeFeller() {}
|
||||
|
||||
/**
|
||||
* Begins Tree Feller
|
||||
*
|
||||
* @param mcMMOPlayer Player using Tree Feller
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
protected static void processTreeFeller(BlockState blockState, Player player) {
|
||||
List<BlockState> treeFellerBlocks = new ArrayList<BlockState>();
|
||||
|
||||
if (blockState.getTypeId() == 17 || blockState.getTypeId() == 99) {
|
||||
processRegularTrees(blockState, treeFellerBlocks);
|
||||
}
|
||||
else {
|
||||
processRedMushroomTrees(blockState, treeFellerBlocks);
|
||||
}
|
||||
|
||||
// If the player is trying to break too many blocks
|
||||
if (treeFellerReachedThreshold) {
|
||||
treeFellerReachedThreshold = false;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the tool can't sustain the durability loss
|
||||
if (!handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
|
||||
|
||||
int health = player.getHealth();
|
||||
|
||||
if (health > 1) {
|
||||
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(health - 1));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
dropBlocks(treeFellerBlocks, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes Tree Feller for generic Trees
|
||||
*
|
||||
* @param blockState Block being checked
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
private static void processRegularTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
|
||||
if (!BlockUtils.isLog(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
|
||||
World world = blockState.getWorld();
|
||||
|
||||
// Handle the blocks around 'block'
|
||||
for (int y = 0; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState();
|
||||
|
||||
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
|
||||
|
||||
if (treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursive call for each log found
|
||||
for (BlockState futureCenterBlock : futureCenterBlocks) {
|
||||
if (treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
processRegularTrees(futureCenterBlock, treeFellerBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes Tree Feller for Red Mushrooms (Dome Shaped)
|
||||
*
|
||||
* @param blockState Block being checked
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
private static void processRedMushroomTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
|
||||
if (!BlockUtils.isLog(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
|
||||
World world = blockState.getWorld();
|
||||
|
||||
// Handle the blocks around 'block'
|
||||
for (int y = 0; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState();
|
||||
BlockState otherNextBlock = world.getBlockAt(blockState.getLocation().add(x, y - (y * 2), z)).getState();
|
||||
|
||||
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
|
||||
handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks);
|
||||
|
||||
if (treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursive call for each log found
|
||||
for (BlockState futureCenterBlock : futureCenterBlocks) {
|
||||
if (treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
processRedMushroomTrees(futureCenterBlock, treeFellerBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a block addition to the list of blocks to be removed and to the list of blocks used for future recursive calls of 'processRecursively()'
|
||||
*
|
||||
* @param blockState Block to be added
|
||||
* @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()'
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
private static void handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, List<BlockState> treeFellerBlocks) {
|
||||
if (!BlockUtils.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
treeFellerBlocks.add(blockState);
|
||||
|
||||
if (treeFellerBlocks.size() > Config.getInstance().getTreeFellerThreshold()) {
|
||||
treeFellerReachedThreshold = true;
|
||||
return;
|
||||
}
|
||||
|
||||
futureCenterBlocks.add(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the durability loss
|
||||
*
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
* @param inHand tool being used
|
||||
* @return True if the tool can sustain the durability loss
|
||||
*/
|
||||
private static boolean handleDurabilityLoss(List<BlockState> treeFellerBlocks, ItemStack inHand) {
|
||||
Material inHandMaterial = inHand.getType();
|
||||
|
||||
if (inHandMaterial != Material.AIR) {
|
||||
short durabilityLoss = 0;
|
||||
int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
if (BlockUtils.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) {
|
||||
durabilityLoss += Config.getInstance().getAbilityToolDamage();
|
||||
}
|
||||
}
|
||||
|
||||
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
|
||||
short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability();
|
||||
|
||||
if (finalDurability >= maxDurability) {
|
||||
inHand.setDurability(maxDurability);
|
||||
return false;
|
||||
}
|
||||
|
||||
inHand.setDurability(finalDurability);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the dropping of blocks
|
||||
*
|
||||
* @param treeFellerBlocks List of blocks to be dropped
|
||||
* @param player Player using the ability
|
||||
*/
|
||||
private static void dropBlocks(List<BlockState> treeFellerBlocks, Player player) {
|
||||
int xp = 0;
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
if (!SkillUtils.blockBreakSimulate(blockState.getBlock(), player, true)) {
|
||||
break; // TODO: Shouldn't we use continue instead?
|
||||
}
|
||||
|
||||
Material material = blockState.getType();
|
||||
|
||||
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
|
||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
||||
Misc.dropItem(blockState.getLocation(), drop);
|
||||
}
|
||||
}
|
||||
else if (ModUtils.isCustomLogBlock(blockState)) {
|
||||
Woodcutting.checkForDoubleDrop(player, blockState);
|
||||
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
Location location = blockState.getLocation();
|
||||
ItemStack item = customBlock.getItemDrop();;
|
||||
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
|
||||
if (minimumDropAmount < maximumDropAmount) {
|
||||
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
}
|
||||
else if (ModUtils.isCustomLeafBlock(blockState)) {
|
||||
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
|
||||
}
|
||||
else {
|
||||
Tree tree = (Tree) blockState.getData();
|
||||
switch (material) {
|
||||
case LOG:
|
||||
Woodcutting.checkForDoubleDrop(player, blockState);
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData()));
|
||||
break;
|
||||
|
||||
case LEAVES:
|
||||
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
blockState.setRawData((byte) 0x0);
|
||||
blockState.setType(Material.AIR);
|
||||
blockState.update(true);
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.gmail.nossr50.skills.woodcutting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Tree;
|
||||
|
||||
@@ -12,18 +14,17 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public final class Woodcutting {
|
||||
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
|
||||
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance();
|
||||
|
||||
public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||
public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
|
||||
|
||||
protected enum ExperienceGainMethod {
|
||||
DEFAULT,
|
||||
TREE_FELLER,
|
||||
@@ -31,47 +32,6 @@ public final class Woodcutting {
|
||||
|
||||
private Woodcutting() {}
|
||||
|
||||
/**
|
||||
* Begins the Tree Feller ability
|
||||
*
|
||||
* @param mcMMOPlayer Player using the ability
|
||||
* @param block Block being broken
|
||||
*/
|
||||
public static void beginTreeFeller(BlockState blockState, Player player) {
|
||||
TreeFeller.processTreeFeller(blockState, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the Leaf Blower ability
|
||||
*
|
||||
* @param player Player using the ability
|
||||
* @param block Block being broken
|
||||
*/
|
||||
public static void beginLeafBlower(Player player, BlockState blockState) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
|
||||
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins Woodcutting
|
||||
*
|
||||
* @param mcMMOPlayer Player breaking the block
|
||||
* @param block Block being broken
|
||||
*/
|
||||
public static void beginWoodcutting(Player player, BlockState blockState) {
|
||||
int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
|
||||
|
||||
if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) {
|
||||
Material blockType = blockState.getType();
|
||||
|
||||
if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) {
|
||||
checkForDoubleDrop(player, blockState);
|
||||
}
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the experience reward from a log
|
||||
*
|
||||
@@ -126,11 +86,7 @@ public final class Woodcutting {
|
||||
* @param mcMMOPlayer Player breaking the block
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
protected static void checkForDoubleDrop(Player player, BlockState blockState) {
|
||||
if (!SkillUtils.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected static void checkForDoubleDrop(BlockState blockState) {
|
||||
if (ModUtils.isCustomLogBlock(blockState)) {
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
@@ -179,4 +135,129 @@ public final class Woodcutting {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes Tree Feller for generic Trees
|
||||
*
|
||||
* @param blockState Block being checked
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
protected static void processRegularTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
|
||||
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
|
||||
|
||||
// Handle the blocks around 'block'
|
||||
for (int y = 0; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
BlockState nextBlock = blockState.getBlock().getRelative(x, y, z).getState();
|
||||
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
|
||||
|
||||
if (WoodcuttingManager.treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursive call for each log found
|
||||
for (BlockState futureCenterBlock : futureCenterBlocks) {
|
||||
if (WoodcuttingManager.treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
processRegularTrees(futureCenterBlock, treeFellerBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes Tree Feller for Red Mushrooms (Dome Shaped)
|
||||
*
|
||||
* @param blockState Block being checked
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
protected static void processRedMushroomTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
|
||||
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
|
||||
|
||||
// Handle the blocks around 'block'
|
||||
for (int y = 0; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
BlockState nextBlock = blockState.getBlock().getRelative(x, y, z).getState();
|
||||
BlockState otherNextBlock = blockState.getBlock().getRelative(x, y - (y * 2), z).getState();
|
||||
|
||||
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
|
||||
handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks);
|
||||
|
||||
if (WoodcuttingManager.treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursive call for each log found
|
||||
for (BlockState futureCenterBlock : futureCenterBlocks) {
|
||||
if (WoodcuttingManager.treeFellerReachedThreshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
processRedMushroomTrees(futureCenterBlock, treeFellerBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the durability loss
|
||||
*
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
* @param inHand tool being used
|
||||
* @return True if the tool can sustain the durability loss
|
||||
*/
|
||||
protected static boolean handleDurabilityLoss(List<BlockState> treeFellerBlocks, ItemStack inHand) {
|
||||
Material inHandMaterial = inHand.getType();
|
||||
|
||||
if (inHandMaterial == Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
short durabilityLoss = 0;
|
||||
int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
if (BlockUtils.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) {
|
||||
durabilityLoss += Config.getInstance().getAbilityToolDamage();
|
||||
}
|
||||
}
|
||||
|
||||
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
|
||||
short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability();
|
||||
|
||||
if (finalDurability >= maxDurability) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inHand.setDurability(finalDurability);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a block addition to the list of blocks to be removed and to the list of blocks used for future recursive calls of 'processRecursively()'
|
||||
*
|
||||
* @param blockState Block to be added
|
||||
* @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()'
|
||||
* @param treeFellerBlocks List of blocks to be removed
|
||||
*/
|
||||
private static void handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, List<BlockState> treeFellerBlocks) {
|
||||
if (!BlockUtils.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
treeFellerBlocks.add(blockState);
|
||||
|
||||
if (treeFellerBlocks.size() > treeFellerThreshold) {
|
||||
WoodcuttingManager.treeFellerReachedThreshold = true;
|
||||
return;
|
||||
}
|
||||
|
||||
futureCenterBlocks.add(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.gmail.nossr50.skills.woodcutting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Tree;
|
||||
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class WoodcuttingManager extends SkillManager {
|
||||
protected static boolean treeFellerReachedThreshold = false;
|
||||
|
||||
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
public boolean canUseLeafBlower(ItemStack heldItem) {
|
||||
return getSkillLevel() >= Woodcutting.leafBlowerUnlockLevel && ItemUtils.isAxe(heldItem);
|
||||
}
|
||||
|
||||
public boolean canUseTreeFeller(ItemStack heldItem) {
|
||||
return mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(getPlayer()) && ItemUtils.isAxe(heldItem);
|
||||
}
|
||||
|
||||
protected boolean canGetDoubleDrops() {
|
||||
return Permissions.doubleDrops(getPlayer(), skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Woodcutting.doubleDropsMaxChance, Woodcutting.doubleDropsMaxLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins Woodcutting
|
||||
*
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
public void woodcuttingBlockCheck(BlockState blockState) {
|
||||
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case HUGE_MUSHROOM_1:
|
||||
case HUGE_MUSHROOM_2:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (canGetDoubleDrops()) {
|
||||
Woodcutting.checkForDoubleDrop(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins Tree Feller
|
||||
*
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
public void processTreeFeller(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
List<BlockState> treeFellerBlocks = new ArrayList<BlockState>();
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case LOG:
|
||||
case HUGE_MUSHROOM_1:
|
||||
Woodcutting.processRegularTrees(blockState, treeFellerBlocks);
|
||||
break;
|
||||
|
||||
case HUGE_MUSHROOM_2:
|
||||
Woodcutting.processRedMushroomTrees(blockState, treeFellerBlocks);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModUtils.isCustomLogBlock(blockState)) {
|
||||
Woodcutting.processRegularTrees(blockState, treeFellerBlocks);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// If the player is trying to break too many blocks
|
||||
if (treeFellerReachedThreshold) {
|
||||
treeFellerReachedThreshold = false;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the tool can't sustain the durability loss
|
||||
if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
|
||||
|
||||
int health = player.getHealth();
|
||||
|
||||
if (health > 1) {
|
||||
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(health - 1));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
dropBlocks(treeFellerBlocks);
|
||||
treeFellerReachedThreshold = false; // Reset the value after we're done with Tree Feller each time.
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the dropping of blocks
|
||||
*
|
||||
* @param treeFellerBlocks List of blocks to be dropped
|
||||
* @param player Player using the ability
|
||||
*/
|
||||
private void dropBlocks(List<BlockState> treeFellerBlocks) {
|
||||
Player player = getPlayer();
|
||||
int xp = 0;
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
if (!SkillUtils.blockBreakSimulate(blockState.getBlock(), player, true)) {
|
||||
break; // TODO: Shouldn't we use continue instead?
|
||||
}
|
||||
|
||||
Material material = blockState.getType();
|
||||
|
||||
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
|
||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
||||
Misc.dropItem(blockState.getLocation(), drop);
|
||||
}
|
||||
}
|
||||
else if (ModUtils.isCustomLogBlock(blockState)) {
|
||||
if (canGetDoubleDrops()) {
|
||||
Woodcutting.checkForDoubleDrop(blockState);
|
||||
}
|
||||
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
Location location = blockState.getLocation();
|
||||
ItemStack item = customBlock.getItemDrop();;
|
||||
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
|
||||
if (minimumDropAmount < maximumDropAmount) {
|
||||
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
}
|
||||
else if (ModUtils.isCustomLeafBlock(blockState)) {
|
||||
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
|
||||
}
|
||||
else {
|
||||
Tree tree = (Tree) blockState.getData();
|
||||
switch (material) {
|
||||
case LOG:
|
||||
if (canGetDoubleDrops()) {
|
||||
Woodcutting.checkForDoubleDrop(blockState);
|
||||
}
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData()));
|
||||
break;
|
||||
|
||||
case LEAVES:
|
||||
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
blockState.setRawData((byte) 0x0);
|
||||
blockState.setType(Material.AIR);
|
||||
blockState.update(true);
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -22,23 +28,31 @@ public final class ChimaeraWing {
|
||||
public static void activationCheck(Player player) {
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (!Config.getInstance().getChimaeraEnabled() || inHand.getTypeId() != Config.getInstance().getChimaeraItemId()) {
|
||||
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = player.getLocation().getBlock();
|
||||
int amount = inHand.getAmount();
|
||||
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR;
|
||||
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt();
|
||||
long lastChimaeraWing = (UserManager.getPlayer(player).getLastChimaeraTeleport());
|
||||
|
||||
if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||
if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
|
||||
if (Permissions.chimaeraWing(player) && ItemUtils.isChimaeraWing(inHand)) {
|
||||
if (!SkillUtils.cooldownOver(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) {
|
||||
player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player) + ")"); //TODO Locale!
|
||||
return;
|
||||
}
|
||||
|
||||
for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
||||
if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
||||
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
|
||||
return;
|
||||
if (SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player) && amount >= Config.getInstance().getChimaeraUseCost()) {
|
||||
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
|
||||
|
||||
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
|
||||
for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
||||
if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
||||
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,15 +63,40 @@ public final class ChimaeraWing {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).actualizeLastChimaeraTeleport();
|
||||
MetricsManager.chimeraWingUsed();
|
||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
||||
}
|
||||
else if (!SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||
else if (!SkillUtils.cooldownOver(recentlyHurt, 60 * Misc.TIME_CONVERSION_FACTOR, player) && amount >= Config.getInstance().getChimaeraUseCost()) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt, 60, player)));
|
||||
}
|
||||
else if (amount <= Config.getInstance().getChimaeraCost()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Config.getInstance().getChimaeraItemId())));
|
||||
else if (amount <= Config.getInstance().getChimaeraUseCost()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getChimaeraWing(int amount) {
|
||||
ItemStack itemStack = new ItemStack(Material.FEATHER, amount);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.GOLD + "Chimaera Wing"); //TODO Locale!
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
itemLore.add("mcMMO Item");
|
||||
itemLore.add(ChatColor.GRAY + "Teleports you to your bed."); //TODO Locale!
|
||||
itemMeta.setLore(itemLore);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static ShapelessRecipe getChimaeraWingRecipe() {
|
||||
Material ingredient = Material.getMaterial(Config.getInstance().getChimaeraItemId());
|
||||
int amount = Config.getInstance().getChimaeraRecipeCost();
|
||||
if (amount > 9) {
|
||||
amount = 9;
|
||||
}
|
||||
|
||||
ShapelessRecipe ChimaeraWing = new ShapelessRecipe(getChimaeraWing(1));
|
||||
ChimaeraWing.addIngredient(amount, ingredient);
|
||||
return ChimaeraWing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
@@ -98,7 +97,7 @@ public final class HolidayManager {
|
||||
final int firework_amount = 10;
|
||||
for (int i = 0; i < firework_amount; i++) {
|
||||
int delay = (int) (Math.random() * 3) + 4;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
spawnFireworks((Player) sender);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.api.SpoutToolsAPI;
|
||||
@@ -264,7 +268,7 @@ public class ItemUtils {
|
||||
* @return true if the item is armor, false otherwise
|
||||
*/
|
||||
public static boolean isMinecraftArmor(ItemStack is) {
|
||||
return isDiamondArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
||||
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -644,4 +648,32 @@ public class ItemUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMcMMOItem(ItemStack is) {
|
||||
if (!is.hasItemMeta()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = is.getItemMeta();
|
||||
if (itemMeta.hasLore()) {
|
||||
List<String> itemLore = itemMeta.getLore();
|
||||
if (itemLore.contains("mcMMO Item")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isChimaeraWing(ItemStack is) {
|
||||
if (!isMcMMOItem(is)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = is.getItemMeta();
|
||||
if (itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + "Chimaera Wing")) { //TODO Get localized name
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class Misc {
|
||||
* @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise
|
||||
*/
|
||||
public static boolean isNear(Location first, Location second, double maxDistance) {
|
||||
if (!first.getWorld().equals(second.getWorld())) {
|
||||
if (first.getWorld() != second.getWorld()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static CustomBlock getCustomBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -88,7 +88,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -110,7 +110,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -132,7 +132,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomMiningBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -154,7 +154,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -176,7 +176,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -198,7 +198,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomLeafBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -220,7 +220,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomLogBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
@@ -242,7 +242,7 @@ public final class ModUtils {
|
||||
*/
|
||||
public static boolean isCustomOreBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
ItemStack item = blockState.getData().toItemStack(1);
|
||||
|
||||
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
|
||||
@@ -231,8 +231,6 @@ public final class Permissions {
|
||||
for (World world : server.getWorlds()) {
|
||||
addDynamicPermission("mcmmo.commands.ptp.world." + world.getName(), PermissionDefault.OP, pluginManager);
|
||||
}
|
||||
|
||||
addDynamicPermission("mcmmo.commands.ptp.world.all", PermissionDefault.OP, pluginManager);
|
||||
}
|
||||
|
||||
private static void addDynamicPermission(String permissionName, PermissionDefault permissionDefault, PluginManager pluginManager) {
|
||||
|
||||
@@ -43,12 +43,18 @@ public class UpdateChecker {
|
||||
jo = (JSONObject) jo.get("versions");
|
||||
newVersion = (String) jo.get("version");
|
||||
|
||||
String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]");
|
||||
String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]");
|
||||
String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
|
||||
String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Integer newVer = Integer.parseInt(newTokens[i]);
|
||||
Integer oldVer = Integer.parseInt(oldTokens[i]);
|
||||
Integer oldVer;
|
||||
try {
|
||||
oldVer = Integer.parseInt(oldTokens[i]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
oldVer = 0;
|
||||
}
|
||||
if (oldVer < newVer) {
|
||||
isr.close();
|
||||
return true;
|
||||
|
||||
@@ -11,10 +11,11 @@ import java.io.StreamCorruptedException;
|
||||
import java.io.UTFDataFormatException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class HashChunkletManager implements ChunkletManager {
|
||||
public HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
|
||||
|
||||
@@ -168,7 +169,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
@@ -176,7 +177,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
@Override
|
||||
public void unloadAll() {
|
||||
saveAll();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||
unloadWorld(world);
|
||||
}
|
||||
}
|
||||
@@ -276,7 +277,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
for (String key : store.keySet()) {
|
||||
if (store.get(key).isEmpty()) {
|
||||
String[] info = key.split(",");
|
||||
File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data");
|
||||
File dataDir = new File(mcMMO.p.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data");
|
||||
|
||||
File cxDir = new File(dataDir, "" + info[1]);
|
||||
if (!cxDir.exists()) {
|
||||
|
||||
@@ -11,12 +11,12 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
|
||||
|
||||
public class HashChunkManager implements ChunkManager {
|
||||
@@ -283,7 +283,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void saveAll() {
|
||||
closeAll();
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
@@ -292,7 +292,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void unloadAll() {
|
||||
closeAll();
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||
unloadWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +64,6 @@ public final class CombatUtils {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (target instanceof Tameable) {
|
||||
if (isFriendlyPet(player, (Tameable) target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (heldItem.getType() == Material.BONE) {
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
@@ -77,6 +73,10 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFriendlyPet(player, (Tameable) target)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ItemUtils.isSword(heldItem)) {
|
||||
@@ -232,7 +232,7 @@ public final class CombatUtils {
|
||||
UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager();
|
||||
|
||||
if (unarmedManager.canDeflect()) {
|
||||
event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck());
|
||||
event.setCancelled(unarmedManager.deflectCheck());
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
|
||||
@@ -40,6 +40,8 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||
|
||||
public class SkillUtils {
|
||||
private static int enchantBuff = AdvancedConfig.getInstance().getEnchantBuff();
|
||||
|
||||
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
|
||||
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
|
||||
@@ -92,10 +94,6 @@ public class SkillUtils {
|
||||
* @param ability The ability to watch cooldowns for
|
||||
*/
|
||||
public static void watchCooldown(McMMOPlayer mcMMOPlayer, AbilityType ability) {
|
||||
if (mcMMOPlayer == null || ability == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!mcMMOPlayer.getAbilityInformed(ability) && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
@@ -215,9 +213,10 @@ public class SkillUtils {
|
||||
int xpRemoved = 0;
|
||||
|
||||
if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
while (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= UserManager.getPlayer(player).getPowerLevel() + 1)) {
|
||||
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= mcMMOPlayer.getPowerLevel() + 1)) {
|
||||
int xp = profile.getXpToLevel(skillType);
|
||||
xpRemoved += xp;
|
||||
|
||||
@@ -460,22 +459,6 @@ public class SkillUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a skill level is higher than the max bonus level of the ability.
|
||||
*
|
||||
* @param skillLevel Skill level to check
|
||||
* @param maxLevel Max level of the ability
|
||||
* @return whichever value is lower
|
||||
*/
|
||||
public static int skillCheck(int skillLevel, int maxLevel) {
|
||||
// TODO: Could we just use Math.min(skillLevel, maxLevel) here?
|
||||
if (skillLevel > maxLevel) {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
public static void handleAbilitySpeedIncrease(Player player) {
|
||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
@@ -493,7 +476,7 @@ public class SkillUtils {
|
||||
}
|
||||
|
||||
itemLore.add("mcMMO Ability Tool");
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true);
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + enchantBuff, true);
|
||||
|
||||
itemMeta.setLore(itemLore);
|
||||
heldItem.setItemMeta(itemMeta);
|
||||
@@ -559,11 +542,11 @@ public class SkillUtils {
|
||||
if (itemLore.remove("mcMMO Ability Tool")) {
|
||||
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||
|
||||
if (efficiencyLevel <= 5) {
|
||||
if (efficiencyLevel <= enchantBuff) {
|
||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||
}
|
||||
else {
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true);
|
||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - enchantBuff, true);
|
||||
}
|
||||
|
||||
itemMeta.setLore(itemLore);
|
||||
|
||||
@@ -16,6 +16,8 @@ Skills:
|
||||
General:
|
||||
# This setting will determine when the length of every ability gets longer with 1 second
|
||||
Ability_IncreaseLevel: 50
|
||||
# This setting determines how many enchant levels to use when buffing Super Breaker & Giga Drill Breaker
|
||||
Ability_EnchantBuff: 5
|
||||
#
|
||||
# Settings for Acrobatics
|
||||
###
|
||||
@@ -247,6 +249,9 @@ Skills:
|
||||
SuperRepair_ChanceMax: 100.0
|
||||
SuperRepair_MaxBonusLevel: 1000
|
||||
|
||||
# Salvage_UnlockLevel: Level when Salvage become available
|
||||
Salvage_UnlockLevel: 600
|
||||
|
||||
Arcane_Forging:
|
||||
May_Lose_Enchants: true
|
||||
Rank_Levels:
|
||||
|
||||
@@ -72,7 +72,10 @@ Mods:
|
||||
Items:
|
||||
Chimaera_Wing:
|
||||
Enabled: true
|
||||
Feather_Cost: 10
|
||||
Cooldown: 240
|
||||
Prevent_Use_Underground: true
|
||||
Use_Cost: 1
|
||||
Recipe_Cost: 5
|
||||
Item_ID: 288
|
||||
|
||||
#
|
||||
@@ -160,9 +163,7 @@ Skills:
|
||||
Level_Cap: 0
|
||||
Anvil_Messages: true
|
||||
Anvil_ID: 42
|
||||
Salvage_enabled: true
|
||||
Salvage_Anvil_ID: 41
|
||||
Salvage_UnlockLevel: 600
|
||||
Salvage_tools: true
|
||||
Salvage_armor: true
|
||||
Smelting:
|
||||
@@ -186,7 +187,6 @@ Skills:
|
||||
SmoothBrick_To_CrackedBrick: true
|
||||
Woodcutting:
|
||||
Level_Cap: 0
|
||||
Requires_Axe: true
|
||||
|
||||
#
|
||||
# Settings for Double Drops
|
||||
@@ -360,8 +360,11 @@ Commands:
|
||||
# Settings for particles
|
||||
###
|
||||
Particles:
|
||||
# These settings determine if fireworks should get launched when a player activates/deactivates an ability
|
||||
Ability_Activation: true
|
||||
Ability_Deactivation: true
|
||||
|
||||
# Use particle effect when these abilities trigger
|
||||
Dodge: true
|
||||
Bleed: true
|
||||
Greater_Impact: true
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
#
|
||||
# Item Weights configuration
|
||||
#
|
||||
# This file is used to determine the value of an item. This will only
|
||||
# happen when users are sharing items in a party using the EQUAL item share mode.
|
||||
#
|
||||
# Rare items should have a higher value than common items. If an item is not listed
|
||||
# here, the value from "Default" will be used instead.
|
||||
#
|
||||
#####
|
||||
Item_Weights:
|
||||
Default: 5
|
||||
Emerald: 150
|
||||
|
||||
@@ -566,6 +566,7 @@ Party.ItemShare.Disabled=[[RED]]Party item sharing is disabled.
|
||||
Commands.XPGain.Acrobatics=Falling
|
||||
Commands.XPGain.Archery=Attacking Monsters
|
||||
Commands.XPGain.Axes=Attacking Monsters
|
||||
Commands.XPGain.Child=Gains levels from Parent Skills
|
||||
Commands.XPGain.Excavation=Digging and finding treasures
|
||||
Commands.XPGain.Fishing=Fishing (Go figure!)
|
||||
Commands.XPGain.Herbalism=Harvesting Herbs
|
||||
@@ -590,7 +591,9 @@ XPRate.Event= [[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x!
|
||||
#EFFECTS
|
||||
##generic
|
||||
Effects.Effects=EFFECTS
|
||||
Effects.Child=[[DARK_GRAY]]LVL: [[GREEN]]{0}
|
||||
Effects.Level=[[DARK_GRAY]]LVL: [[GREEN]]{0} [[DARK_AQUA]]XP[[YELLOW]]([[GOLD]]{1}[[YELLOW]]/[[GOLD]]{2}[[YELLOW]])
|
||||
Effects.Parent = [[GOLD]]{0} -
|
||||
Effects.Template=[[DARK_AQUA]]{0}: [[GREEN]]{1}
|
||||
|
||||
#GUIDES
|
||||
@@ -625,9 +628,11 @@ Item.ChimaeraWing.Pass=**CHIMAERA WING**
|
||||
Item.Injured.Wait=You were injured recently and must wait to use this. [[YELLOW]]({0}s)
|
||||
|
||||
#SKILLS
|
||||
Skills.Child=[[GOLD]](CHILD SKILL)
|
||||
Skills.Disarmed=[[DARK_RED]]You have been disarmed!
|
||||
Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]-----
|
||||
Skills.NeedMore=[[DARK_RED]]You need more [[GRAY]]{0}
|
||||
Skills.Parents = PARENTS
|
||||
Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]])
|
||||
Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
|
||||
|
||||
|
||||
@@ -1190,11 +1190,11 @@ permissions:
|
||||
default: false
|
||||
description: Implies all mcmmo.item permissions
|
||||
children:
|
||||
mcmmo.item.all: true
|
||||
mcmmo.item.all: true
|
||||
mcmmo.item.all:
|
||||
description: Implies all mcmmo.item permissions
|
||||
children:
|
||||
mcmmo.item.chimaerawing: true
|
||||
mcmmo.item.chimaerawing: true
|
||||
mcmmo.item.chimaerawing:
|
||||
description: Allows use of Chimaera Wing item
|
||||
mcmmo.motd:
|
||||
|
||||
Reference in New Issue
Block a user