mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
80 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 | ||
|
|
1a66ff7659 | ||
|
|
df53e2fd4f | ||
|
|
4210920c5f | ||
|
|
3440833af8 | ||
|
|
1e738263bc | ||
|
|
9cf322ca0b | ||
|
|
0c027ca697 | ||
|
|
27ed5f7c38 | ||
|
|
2f83e559a4 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,4 +1,4 @@
|
|||||||
* text
|
* text=auto
|
||||||
|
|
||||||
*.png binary
|
*.png binary
|
||||||
*.wav binary
|
*.wav binary
|
||||||
|
|||||||
82
.gitignore
vendored
82
.gitignore
vendored
@@ -1,42 +1,42 @@
|
|||||||
# Eclipse stuff
|
# Eclipse stuff
|
||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.settings
|
/.settings
|
||||||
|
|
||||||
# netbeans
|
# netbeans
|
||||||
/nbproject
|
/nbproject
|
||||||
|
|
||||||
# we use maven!
|
# we use maven!
|
||||||
/build.xml
|
/build.xml
|
||||||
|
|
||||||
# maven
|
# maven
|
||||||
/target
|
/target
|
||||||
|
|
||||||
# vim
|
# vim
|
||||||
.*.sw[a-p]
|
.*.sw[a-p]
|
||||||
|
|
||||||
# various other potential build files
|
# various other potential build files
|
||||||
/build
|
/build
|
||||||
/bin
|
/bin
|
||||||
/dist
|
/dist
|
||||||
/manifest.mf
|
/manifest.mf
|
||||||
|
|
||||||
/world
|
/world
|
||||||
|
|
||||||
# Mac filesystem dust
|
# Mac filesystem dust
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
|
|
||||||
# intellij
|
# intellij
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
# Project Stuff
|
# Project Stuff
|
||||||
/src/main/resources/mcMMO
|
/src/main/resources/mcMMO
|
||||||
|
|
||||||
# Other Libraries
|
# Other Libraries
|
||||||
*.jar
|
*.jar
|
||||||
|
|
||||||
# Atlassian Stuff
|
# Atlassian Stuff
|
||||||
/atlassian-ide-plugin.xml
|
/atlassian-ide-plugin.xml
|
||||||
|
|||||||
@@ -7,6 +7,42 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- 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
|
||||||
|
= Fixed bug where some skills weren't registering as unlocked until one level later
|
||||||
|
= Fixed bug where the PTP cooldown was being read improperly
|
||||||
|
= Fixed bug where /ptp <accept|toggle|acceptall> where broken
|
||||||
|
= Fixed ClassCastException relating to counter-attack with Swords
|
||||||
|
= Fixed issue with some skill activations not activating enough or activating too much
|
||||||
|
|
||||||
Version 1.4.01
|
Version 1.4.01
|
||||||
= Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs
|
= Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs
|
||||||
= Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile
|
= Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>1.4.01</version>
|
<version>1.4.03-dev1</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<issueManagement>
|
<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">
|
<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>
|
<id>bin</id>
|
||||||
<includeBaseDirectory>false</includeBaseDirectory>
|
<includeBaseDirectory>false</includeBaseDirectory>
|
||||||
<formats>
|
<formats>
|
||||||
<format>zip</format>
|
<format>zip</format>
|
||||||
</formats>
|
</formats>
|
||||||
<files>
|
<files>
|
||||||
<file>
|
<file>
|
||||||
<source>${project.build.directory}/${artifactId}.jar</source>
|
<source>${project.build.directory}/${artifactId}.jar</source>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
<destName>mcMMO.jar</destName>
|
<destName>mcMMO.jar</destName>
|
||||||
</file>
|
</file>
|
||||||
</files>
|
</files>
|
||||||
</assembly>
|
</assembly>
|
||||||
@@ -237,6 +237,29 @@ public final class ExperienceAPI {
|
|||||||
return UserManager.getPlayer(player).getPowerLevel();
|
return UserManager.getPlayer(player).getPowerLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the level cap of a specific skill.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param skillType The skill to get the level cap for
|
||||||
|
* @return the level cap of a given skill
|
||||||
|
*/
|
||||||
|
public static int getLevelCap(String skillType) {
|
||||||
|
return Config.getInstance().getLevelCap(SkillType.getSkill(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the power level cap.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return the power level cap of a given skill
|
||||||
|
*/
|
||||||
|
public static int getPowerLevelCap() {
|
||||||
|
return Config.getInstance().getPowerLevelCap();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the level of a player in a specific skill type.
|
* Sets the level of a player in a specific skill type.
|
||||||
* </br>
|
* </br>
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Party leader commands
|
// Party leader commands
|
||||||
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) {
|
if (!mcMMOPlayer.getParty().getLeader().equalsIgnoreCase(player.getName())) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
StringBuilder memberList = new StringBuilder();
|
StringBuilder memberList = new StringBuilder();
|
||||||
|
|
||||||
for (OfflinePlayer member : playerParty.getMembers()) {
|
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(" ");
|
memberList.append(ChatColor.GOLD).append(member.getName()).append(" ");
|
||||||
}
|
}
|
||||||
else if (member.isOnline()) {
|
else if (member.isOnline()) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class PartyRenameCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!member.getName().equals(leaderName)) {
|
if (!member.getName().equalsIgnoreCase(leaderName)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
|
player = (Player) sender;
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("toggle")) {
|
if (args[0].equalsIgnoreCase("toggle")) {
|
||||||
if (!Permissions.partyTeleportToggle(sender)) {
|
if (!Permissions.partyTeleportToggle(sender)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
@@ -50,11 +53,10 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
return acceptAnyTeleportRequest();
|
return acceptAnyTeleportRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
player = (Player) sender;
|
|
||||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||||
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt() * Misc.TIME_CONVERSION_FACTOR;
|
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt();
|
||||||
|
|
||||||
if (System.currentTimeMillis() - recentlyHurt >= (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) {
|
if ((recentlyHurt * Misc.TIME_CONVERSION_FACTOR + ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -110,9 +112,9 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target = mcMMOPlayer.getPtpRequest();
|
target = mcMMOPlayer.getPtpRequest();
|
||||||
|
mcMMOPlayer.removePtpRequest();
|
||||||
|
|
||||||
if (!canTeleport(target.getName())) {
|
if (!canTeleport(target.getName())) {
|
||||||
mcMMOPlayer.removePtpRequest();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -9,11 +9,11 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.LeaderboardManager;
|
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.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -99,6 +99,10 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
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
|
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) {
|
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;
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -9,9 +8,9 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.LeaderboardManager;
|
import com.gmail.nossr50.database.LeaderboardManager;
|
||||||
|
import com.gmail.nossr50.database.queuemanager.McTopAsync;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
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) {
|
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 (sql) {
|
||||||
if (skill.equalsIgnoreCase("all")) {
|
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 {
|
else {
|
||||||
sqlDisplay(page, skill, sender, command);
|
sqlDisplay(page, skill, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -87,11 +91,6 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
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
|
LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information
|
||||||
|
|
||||||
String[] info = LeaderboardManager.retrieveInfo(skill, page);
|
String[] info = LeaderboardManager.retrieveInfo(skill, page);
|
||||||
@@ -123,7 +122,18 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command));
|
//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.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
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.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class RepairCommand extends SkillCommand {
|
public class RepairCommand extends SkillCommand {
|
||||||
private int arcaneForgingRank;
|
private int arcaneForgingRank;
|
||||||
@@ -41,10 +41,10 @@ public class RepairCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
// We're using pickaxes here, not the best but it works
|
// We're using pickaxes here, not the best but it works
|
||||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
Repairable diamondRepairable = mcMMO.repairableManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
Repairable goldRepairable = mcMMO.repairableManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
|
Repairable ironRepairable = mcMMO.repairableManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_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
|
// 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();
|
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||||
@@ -66,7 +66,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
superRepairChanceLucky = superRepairStrings[1];
|
superRepairChanceLucky = superRepairStrings[1];
|
||||||
|
|
||||||
// ARCANE FORGING
|
// ARCANE FORGING
|
||||||
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
arcaneForgingRank = UserManager.getPlayer(player).getRepairManager().getArcaneForgingRank();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSalvage && Salvage.salvageUnlockLevel > 0) {
|
if (canSalvage && Repair.salvageUnlockLevel > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canArcaneForge) {
|
if (canArcaneForge) {
|
||||||
@@ -155,11 +155,11 @@ public class RepairCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank));
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank));
|
||||||
|
|
||||||
if (Repair.arcaneForgingEnchantLoss) {
|
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) {
|
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;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
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.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
@@ -57,12 +59,23 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
dataCalculations();
|
dataCalculations();
|
||||||
permissionsCheck();
|
permissionsCheck();
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName")));
|
|
||||||
|
|
||||||
if (!skill.isChildSkill()) {
|
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("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + skillString)));
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
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()) {
|
if (effectsHeaderPermissions()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||||
|
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); }
|
||||||
|
|
||||||
/* ACROBATICS */
|
/* ACROBATICS */
|
||||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
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 int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||||
public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); }
|
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 getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
||||||
|
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||||
|
|
||||||
/* Arcane Forging */
|
/* Arcane Forging */
|
||||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
|
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); }
|
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||||
|
|
||||||
/* Items */
|
/* 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 int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
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 */
|
/* Particles */
|
||||||
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
||||||
@@ -183,9 +186,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* Repair */
|
/* Repair */
|
||||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
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 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 getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", 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); }
|
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
|
||||||
|
|
||||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
||||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
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 java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
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 String playerName;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
private String player;
|
||||||
|
|
||||||
public McrankCommandAsyncTask(String playerName, CommandSender sender) {
|
public McRankAsync(String playerName, CommandSender sender) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
|
this.player = sender.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
|
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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||||
@@ -53,4 +54,9 @@ public class McrankCommandAsyncTask implements Runnable {
|
|||||||
|
|
||||||
}, 1L);
|
}, 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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class MctopCommandAsyncTask implements Runnable {
|
public class McTopAsync implements Queueable {
|
||||||
|
|
||||||
private CommandSender sender;
|
private CommandSender sender;
|
||||||
private String query;
|
private String query;
|
||||||
private int page;
|
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.page = page;
|
||||||
this.query = query;
|
this.query = query;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.command = command;
|
this.player = sender.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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();
|
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");
|
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
|
@Override
|
||||||
public void run() {
|
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"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -66,4 +56,9 @@ public class MctopCommandAsyncTask implements Runnable {
|
|||||||
}, 1L);
|
}, 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.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -65,16 +68,18 @@ public class McMMOPlayer {
|
|||||||
private boolean displaySkillNotifications = true;
|
private boolean displaySkillNotifications = true;
|
||||||
|
|
||||||
private boolean abilityUse = true;
|
private boolean abilityUse = true;
|
||||||
private boolean placedAnvil;
|
private boolean placedRepairAnvil;
|
||||||
private boolean placedSalvageAnvil;
|
private boolean placedSalvageAnvil;
|
||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
|
|
||||||
private Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
private Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||||
private Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
private Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||||
private Map<ToolType, Boolean> toolPreparationMode = new HashMap<ToolType, Boolean>();
|
|
||||||
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
private Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||||
|
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||||
|
|
||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
|
private int chimaeraWing;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
|
|
||||||
public McMMOPlayer(Player player) {
|
public McMMOPlayer(Player player) {
|
||||||
@@ -91,12 +96,7 @@ public class McMMOPlayer {
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
Class<? extends SkillManager> skillManagerClass = skillType.getManagerClass();
|
skillManagers.put(skillType, skillType.getManagerClass().getConstructor(McMMOPlayer.class).newInstance(this));
|
||||||
|
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@@ -110,7 +110,7 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ToolType toolType : ToolType.values()) {
|
for (ToolType toolType : ToolType.values()) {
|
||||||
toolPreparationMode.put(toolType, false);
|
toolMode.put(toolType, false);
|
||||||
toolATS.put(toolType, 0);
|
toolATS.put(toolType, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,6 +143,10 @@ public class McMMOPlayer {
|
|||||||
return (MiningManager) skillManagers.get(SkillType.MINING);
|
return (MiningManager) skillManagers.get(SkillType.MINING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RepairManager getRepairManager() {
|
||||||
|
return (RepairManager) skillManagers.get(SkillType.REPAIR);
|
||||||
|
}
|
||||||
|
|
||||||
public SmeltingManager getSmeltingManager() {
|
public SmeltingManager getSmeltingManager() {
|
||||||
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
||||||
}
|
}
|
||||||
@@ -159,6 +163,10 @@ public class McMMOPlayer {
|
|||||||
return (UnarmedManager) skillManagers.get(SkillType.UNARMED);
|
return (UnarmedManager) skillManagers.get(SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WoodcuttingManager getWoodcuttingManager() {
|
||||||
|
return (WoodcuttingManager) skillManagers.get(SkillType.WOODCUTTING);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Abilities
|
* Abilities
|
||||||
*/
|
*/
|
||||||
@@ -219,7 +227,7 @@ public class McMMOPlayer {
|
|||||||
* @return true if the tool is prepped, false otherwise
|
* @return true if the tool is prepped, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getToolPreparationMode(ToolType tool) {
|
public boolean getToolPreparationMode(ToolType tool) {
|
||||||
return toolPreparationMode.get(tool);
|
return toolMode.get(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAbilityUse() {
|
public boolean getAbilityUse() {
|
||||||
@@ -250,7 +258,7 @@ public class McMMOPlayer {
|
|||||||
* @param bool true if the tool should be prepped, false otherwise
|
* @param bool true if the tool should be prepped, false otherwise
|
||||||
*/
|
*/
|
||||||
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
||||||
toolPreparationMode.put(tool, bool);
|
toolMode.put(tool, bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -291,6 +299,23 @@ public class McMMOPlayer {
|
|||||||
recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
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
|
* Exploit Prevention
|
||||||
*/
|
*/
|
||||||
@@ -307,24 +332,26 @@ public class McMMOPlayer {
|
|||||||
* Repair Anvil Placement
|
* Repair Anvil Placement
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void togglePlacedAnvil() {
|
public boolean getPlacedAnvil(int anvilId) {
|
||||||
placedAnvil = !placedAnvil;
|
if (anvilId == Repair.repairAnvilId) {
|
||||||
|
return placedRepairAnvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anvilId == Repair.salvageAnvilId) {
|
||||||
|
return placedSalvageAnvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getPlacedAnvil() {
|
public void togglePlacedAnvil(int anvilId) {
|
||||||
return placedAnvil;
|
if (anvilId == Repair.repairAnvilId) {
|
||||||
}
|
placedRepairAnvil = !placedRepairAnvil;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
if (anvilId == Repair.salvageAnvilId) {
|
||||||
* Salvage Anvil Placement
|
placedSalvageAnvil = !placedSalvageAnvil;
|
||||||
*/
|
}
|
||||||
|
|
||||||
public void togglePlacedSalvageAnvil() {
|
|
||||||
placedSalvageAnvil = !placedSalvageAnvil;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getPlacedSalvageAnvil() {
|
|
||||||
return placedSalvageAnvil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (HudType type : HudType.values()) {
|
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;
|
hudType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ public class PlayerProfile {
|
|||||||
// Find if the line contains the player we want.
|
// Find if the line contains the player we want.
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
if (!character[0].equals(playerName)) {
|
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ public class PlayerProfile {
|
|||||||
// While not at the end of the file
|
// While not at the end of the file
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
// Read the line in and copy it to the output it's not the player we want to edit
|
// 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");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
|||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public enum SkillType {
|
public enum SkillType {
|
||||||
@@ -25,12 +27,12 @@ public enum SkillType {
|
|||||||
FISHING(FishingManager.class),
|
FISHING(FishingManager.class),
|
||||||
HERBALISM(HerbalismManager.class, AbilityType.GREEN_TERRA, ToolType.HOE),
|
HERBALISM(HerbalismManager.class, AbilityType.GREEN_TERRA, ToolType.HOE),
|
||||||
MINING(MiningManager.class, AbilityType.SUPER_BREAKER, ToolType.PICKAXE),
|
MINING(MiningManager.class, AbilityType.SUPER_BREAKER, ToolType.PICKAXE),
|
||||||
REPAIR(null), // TODO: Create a proper RepairManager class
|
REPAIR(RepairManager.class),
|
||||||
SMELTING(SmeltingManager.class),
|
SMELTING(SmeltingManager.class),
|
||||||
SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD),
|
SWORDS(SwordsManager.class, AbilityType.SERRATED_STRIKES, ToolType.SWORD),
|
||||||
TAMING(TamingManager.class),
|
TAMING(TamingManager.class),
|
||||||
UNARMED(UnarmedManager.class, AbilityType.BERSERK, ToolType.FISTS),
|
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 Class<? extends SkillManager> managerClass;
|
||||||
private AbilityType ability;
|
private AbilityType ability;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -19,8 +20,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
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.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@@ -34,10 +33,9 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
|||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
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.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@@ -108,21 +106,15 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
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 */
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||||
if (BlockUtils.shouldBeWatched(blockState)) {
|
if (BlockUtils.shouldBeWatched(blockState)) {
|
||||||
mcMMO.placeStore.setTrue(blockState);
|
mcMMO.placeStore.setTrue(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Repair.anvilMessagesEnabled) {
|
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
|
||||||
int blockID = blockState.getTypeId();
|
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId);
|
||||||
|
|
||||||
if (blockID == Repair.anvilID) {
|
|
||||||
Repair.placedAnvilCheck(player, blockID);
|
|
||||||
}
|
|
||||||
else if (blockID == Salvage.anvilID) {
|
|
||||||
Salvage.placedAnvilCheck(player, blockID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,12 +137,11 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
|
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
/* HERBALISM */
|
/* HERBALISM */
|
||||||
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
||||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||||
|
|
||||||
/* Green Terra */
|
/* Green Terra */
|
||||||
if (herbalismManager.canActivateAbility()) {
|
if (herbalismManager.canActivateAbility()) {
|
||||||
@@ -162,47 +153,31 @@ public class BlockListener implements Listener {
|
|||||||
* Instead, we check it inside the drops handler.
|
* Instead, we check it inside the drops handler.
|
||||||
*/
|
*/
|
||||||
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
||||||
|
|
||||||
// Double drops
|
|
||||||
herbalismManager.herbalismBlockCheck(blockState);
|
herbalismManager.herbalismBlockCheck(blockState);
|
||||||
|
|
||||||
// Triple drops
|
|
||||||
if (herbalismManager.canGreenTerraPlant()) {
|
|
||||||
herbalismManager.herbalismBlockCheck(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
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);
|
miningManager.miningBlockCheck(blockState);
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
|
||||||
miningManager.miningBlockCheck(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WOOD CUTTING */
|
/* WOOD CUTTING */
|
||||||
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) {
|
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)) {
|
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||||
Woodcutting.beginTreeFeller(blockState, player);
|
|
||||||
|
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||||
|
woodcuttingManager.processTreeFeller(blockState);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
woodcuttingManager.woodcuttingBlockCheck(blockState);
|
||||||
if (ItemUtils.isAxe(heldItem)) {
|
|
||||||
Woodcutting.beginWoodcutting(player, blockState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Woodcutting.beginWoodcutting(player, blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EXCAVATION */
|
/* EXCAVATION */
|
||||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
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);
|
excavationManager.excavationBlockCheck(blockState);
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
@@ -234,20 +209,26 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
ItemStack heldItem = player.getItemInHand();
|
||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
|
||||||
SmeltingManager smeltingManager = mcMMOPlayer.getSmeltingManager();
|
|
||||||
|
|
||||||
if (herbalismManager.canUseHylianLuck()) {
|
if (ItemUtils.isSword(heldItem)) {
|
||||||
if (herbalismManager.processHylianLuck(blockState)) {
|
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||||
blockState.update(true);
|
|
||||||
event.setCancelled(true);
|
if (herbalismManager.canUseHylianLuck()) {
|
||||||
|
if (herbalismManager.processHylianLuck(blockState)) {
|
||||||
|
blockState.update(true);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (smeltingManager.canUseFluxMining(blockState)) {
|
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
if (smeltingManager.processFluxMining(blockState)) {
|
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
|
||||||
blockState.update(true);
|
|
||||||
event.setCancelled(true);
|
if (smeltingManager.canUseFluxMining(blockState)) {
|
||||||
|
if (smeltingManager.processFluxMining(blockState)) {
|
||||||
|
blockState.update(true);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,24 +342,18 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Another perm check for the cracked blocks activation
|
// Another perm check for the cracked blocks activation
|
||||||
else if (BlockUtils.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) {
|
else if (BlockUtils.affectedByBlockCracker(blockState)) {
|
||||||
if (Unarmed.blockCracker(player, blockState)) {
|
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||||
|
|
||||||
|
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
|
||||||
blockState.update();
|
blockState.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((mcMMOPlayer.getProfile().getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockUtils.isLeaves(blockState)) {
|
else if (BlockUtils.isLeaves(blockState)) {
|
||||||
if (SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) {
|
||||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
event.setInstaBreak(true);
|
||||||
if (ItemUtils.isAxe(heldItem)) {
|
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||||
event.setInstaBreak(true);
|
|
||||||
Woodcutting.beginLeafBlower(player, blockState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!(heldItem.getType() == Material.SHEARS)) {
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
Woodcutting.beginLeafBlower(player, blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ public class EntityListener implements Listener {
|
|||||||
Player defendingPlayer = (Player) defender;
|
Player defendingPlayer = (Player) defender;
|
||||||
Player attackingPlayer = (Player) attacker;
|
Player attackingPlayer = (Player) attacker;
|
||||||
|
|
||||||
// TODO: Why?
|
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
|
||||||
if (defendingPlayer == attackingPlayer) {
|
if (defendingPlayer.equals(attackingPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@@ -16,6 +17,7 @@ import org.bukkit.event.inventory.InventoryOpenEvent;
|
|||||||
import org.bukkit.inventory.FurnaceInventory;
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
@@ -49,11 +51,12 @@ public class InventoryListener implements Listener {
|
|||||||
if (furnace == null) {
|
if (furnace == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (furnace.getBurnTime() == 0) {
|
||||||
|
Block furnaceBlock = furnace.getBlock();
|
||||||
|
|
||||||
BlockState furnaceBlock = furnace.getBlock().getState();
|
if (!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||||
|
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, new FixedMetadataValue(plugin, player.getName()));
|
||||||
if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) {
|
}
|
||||||
plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,23 +78,27 @@ public class InventoryListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState furnaceBlock = furnace.getBlock().getState();
|
if (furnace.getBurnTime() == 0) {
|
||||||
|
Block furnaceBlock = furnace.getBlock();
|
||||||
|
|
||||||
if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) {
|
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||||
plugin.removeFromFurnaceTracker(furnaceBlock);
|
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||||
BlockState furnaceBlock = event.getBlock().getState();
|
Block furnaceBlock = event.getBlock();
|
||||||
|
BlockState furnaceState = furnaceBlock.getState();
|
||||||
|
|
||||||
if (furnaceBlock instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting();
|
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||||
|
|
||||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
// 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)) {
|
if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) {
|
||||||
return;
|
return;
|
||||||
@@ -104,13 +111,15 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||||
BlockState furnaceBlock = event.getBlock().getState();
|
Block furnaceBlock = event.getBlock();
|
||||||
|
BlockState furnaceState = furnaceBlock.getState();
|
||||||
|
|
||||||
if (furnaceBlock instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting();
|
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||||
|
|
||||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
// 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)) {
|
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||||
return;
|
return;
|
||||||
@@ -123,13 +132,15 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||||
BlockState furnaceBlock = event.getBlock().getState();
|
Block furnaceBlock = event.getBlock();
|
||||||
|
BlockState furnaceState = furnaceBlock.getState();
|
||||||
|
|
||||||
if (furnaceBlock instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult();
|
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
|
||||||
|
|
||||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemUtils.isSmelted(result)) {
|
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) {
|
||||||
Player player = event.getPlayer();
|
// 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();
|
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.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
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.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ChimaeraWing;
|
import com.gmail.nossr50.util.ChimaeraWing;
|
||||||
@@ -285,14 +284,14 @@ public class PlayerListener implements Listener {
|
|||||||
int blockID = block.getTypeId();
|
int blockID = block.getTypeId();
|
||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) {
|
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairableManager.isRepairable(heldItem)) {
|
||||||
mcMMO.repairManager.handleRepair(mcMMOPlayer, heldItem);
|
UserManager.getPlayer(player).getRepairManager().handleRepair(heldItem);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) {
|
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||||
Salvage.handleSalvage(player, block.getLocation(), heldItem);
|
UserManager.getPlayer(player).getRepairManager().handleSalvage(block.getLocation(), heldItem);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
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.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.database.LeaderboardManager;
|
import com.gmail.nossr50.database.LeaderboardManager;
|
||||||
|
import com.gmail.nossr50.database.queuemanager.AsyncQueueManager;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.listeners.BlockListener;
|
import com.gmail.nossr50.listeners.BlockListener;
|
||||||
import com.gmail.nossr50.listeners.EntityListener;
|
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.BleedTimerTask;
|
||||||
import com.gmail.nossr50.runnables.skills.SkillMonitorTask;
|
import com.gmail.nossr50.runnables.skills.SkillMonitorTask;
|
||||||
import com.gmail.nossr50.skills.child.ChildConfig;
|
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.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.skills.repair.config.RepairConfigManager;
|
||||||
|
import com.gmail.nossr50.util.ChimaeraWing;
|
||||||
import com.gmail.nossr50.util.LogFilter;
|
import com.gmail.nossr50.util.LogFilter;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.UpdateChecker;
|
import com.gmail.nossr50.util.UpdateChecker;
|
||||||
@@ -66,12 +66,12 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private final WorldListener worldListener = new WorldListener();
|
private final WorldListener worldListener = new WorldListener();
|
||||||
|
|
||||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||||
private HashMap<BlockState, String> furnaceTracker = new HashMap<BlockState, String>();
|
|
||||||
|
|
||||||
public static mcMMO p;
|
public static mcMMO p;
|
||||||
|
|
||||||
public static ChunkManager placeStore;
|
public static ChunkManager placeStore;
|
||||||
public static RepairManager repairManager;
|
public static RepairableManager repairableManager;
|
||||||
|
public static AsyncQueueManager queueManager;
|
||||||
|
|
||||||
// Jar Stuff
|
// Jar Stuff
|
||||||
public static File mcmmo;
|
public static File mcmmo;
|
||||||
@@ -95,6 +95,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
||||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
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.
|
* Things to be run when the plugin is enabled.
|
||||||
@@ -115,6 +116,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
registerCustomRecipes();
|
||||||
|
|
||||||
// Setup the leader boards
|
// Setup the leader boards
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
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.");
|
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) {}
|
catch (NullPointerException e) {}
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
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
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||||
|
|
||||||
if (Config.getInstance().getBackupsEnabled()) {
|
if (Config.getInstance().getBackupsEnabled()) {
|
||||||
@@ -273,22 +281,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
tntTracker.remove(tntID);
|
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() {
|
public static String getMainDirectory() {
|
||||||
return mainDirectory;
|
return mainDirectory;
|
||||||
}
|
}
|
||||||
@@ -377,8 +369,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
// Load repair configs, make manager, and register them at this time
|
// Load repair configs, make manager, and register them at this time
|
||||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||||
repairables.addAll(rManager.getLoadedRepairables());
|
repairables.addAll(rManager.getLoadedRepairables());
|
||||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
repairableManager = RepairableManagerFactory.getRepairManager(repairables.size());
|
||||||
repairManager.registerRepairables(repairables);
|
repairableManager.registerRepairables(repairables);
|
||||||
|
|
||||||
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||||
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
||||||
@@ -450,6 +442,12 @@ public class mcMMO extends JavaPlugin {
|
|||||||
CommandRegistrationManager.registerMchudCommand();
|
CommandRegistrationManager.registerMchudCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCustomRecipes() {
|
||||||
|
if (Config.getInstance().getChimaeraEnabled()) {
|
||||||
|
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void scheduleTasks() {
|
private void scheduleTasks() {
|
||||||
BukkitScheduler scheduler = getServer().getScheduler();
|
BukkitScheduler scheduler = getServer().getScheduler();
|
||||||
|
|
||||||
@@ -465,6 +463,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
// Bleed timer (Runs every two seconds)
|
// Bleed timer (Runs every two seconds)
|
||||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40);
|
scheduler.scheduleSyncRepeatingTask(this, new BleedTimerTask(), 40, 40);
|
||||||
|
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
queueManager = new AsyncQueueManager();
|
||||||
|
scheduler.runTaskAsynchronously(this, queueManager);
|
||||||
|
}
|
||||||
|
|
||||||
// Old & Powerless User remover
|
// Old & Powerless User remover
|
||||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public final class PartyManager {
|
|||||||
List<Player> nearMembers = new ArrayList<Player>();
|
List<Player> nearMembers = new ArrayList<Player>();
|
||||||
if (party != null) {
|
if (party != null) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
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);
|
nearMembers.add(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ public final class PartyManager {
|
|||||||
public static Party getPlayerParty(String playerName) {
|
public static Party getPlayerParty(String playerName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
for (OfflinePlayer member : party.getMembers()) {
|
for (OfflinePlayer member : party.getMembers()) {
|
||||||
if (member.getName().equals(playerName)) {
|
if (member.getName().equalsIgnoreCase(playerName)) {
|
||||||
return party;
|
return party;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If the leaving player was the party leader, appoint a new leader from the party members
|
// 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();
|
String newLeader = members.get(0).getName();
|
||||||
party.setLeader(newLeader);
|
party.setLeader(newLeader);
|
||||||
}
|
}
|
||||||
@@ -374,10 +374,10 @@ public final class PartyManager {
|
|||||||
String leaderName = party.getLeader();
|
String leaderName = party.getLeader();
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (member.getName().equals(playerName)) {
|
if (member.getName().equalsIgnoreCase(playerName)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
|
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"));
|
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -396,7 +396,7 @@ public final class PartyManager {
|
|||||||
* @return true if the player can invite
|
* @return true if the player can invite
|
||||||
*/
|
*/
|
||||||
public static boolean canInvite(Player player, Party party) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,13 +488,13 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
partiesFile.set(partyName + ".Members", memberNames);
|
partiesFile.set(partyName + ".Members", memberNames);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
partiesFile.save(new File(partiesFilePath));
|
partiesFile.save(new File(partiesFilePath));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class SQLConversionTask implements Runnable {
|
|||||||
playerName = character[0];
|
playerName = character[0];
|
||||||
|
|
||||||
// Check for things we don't want put in the DB
|
// 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;
|
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;
|
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.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
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.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
@@ -15,13 +11,7 @@ public class SkillMonitorTask implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) {
|
||||||
if (Misc.isNPCEntity(player)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MONITOR SKILLS
|
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
@@ -27,12 +28,11 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
|
|
||||||
public boolean canDodge(Entity damager) {
|
public boolean canDodge(Entity damager) {
|
||||||
if (Permissions.dodge(getPlayer())) {
|
if (Permissions.dodge(getPlayer())) {
|
||||||
if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) {
|
if (damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) {
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CombatUtils.shouldProcessSkill(damager, skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -48,7 +48,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
|
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
|
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
|
||||||
ParticleEffectUtils.playDodgeEffect(player);
|
ParticleEffectUtils.playDodgeEffect(player);
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSkillShot() {
|
public boolean canSkillShot() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(getPlayer(), skill);
|
||||||
|
|
||||||
return SkillUtils.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTrackArrows() {
|
public boolean canTrackArrows() {
|
||||||
@@ -47,7 +45,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
Location shooterLocation = player.getLocation();
|
Location shooterLocation = player.getLocation();
|
||||||
Location targetLocation = target.getLocation();
|
Location targetLocation = target.getLocation();
|
||||||
|
|
||||||
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
|
if (shooterLocation.getWorld() != targetLocation.getWorld()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +62,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param target The {@link LivingEntity} damaged by the arrow
|
* @param target The {@link LivingEntity} damaged by the arrow
|
||||||
*/
|
*/
|
||||||
public void trackArrows(LivingEntity target) {
|
public void trackArrows(LivingEntity target) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
|
||||||
Archery.incrementTrackerValue(target);
|
Archery.incrementTrackerValue(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,14 +70,12 @@ public class ArcheryManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Handle the effects of the Daze ability
|
* Handle the effects of the Daze ability
|
||||||
*
|
*
|
||||||
* @param defender The player being affected by the ability
|
* @param defender The {@link Player} being affected by the ability
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public int dazeCheck(Player defender, int damage) {
|
public int dazeCheck(Player defender, int damage) {
|
||||||
Player attacker = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
|
||||||
Location dazedLocation = defender.getLocation();
|
Location dazedLocation = defender.getLocation();
|
||||||
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
||||||
|
|
||||||
@@ -91,7 +87,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage + Archery.dazeModifier;
|
return damage + Archery.dazeModifier;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.skills.ToolType;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -68,10 +69,8 @@ public class AxesManager extends SkillManager {
|
|||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public int criticalHitCheck(LivingEntity target, int damage) {
|
public int criticalHitCheck(LivingEntity target, int damage) {
|
||||||
Player player = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||||
@@ -94,10 +93,11 @@ public class AxesManager extends SkillManager {
|
|||||||
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
||||||
|
|
||||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||||
if (ItemUtils.isArmor(armor) && SkillUtils.activationSuccessful(getPlayer(), skill, Axes.impactChance)) {
|
if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
||||||
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
||||||
double maxDurabilityDamage = (ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityModifier;
|
short maxDurability = ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability();
|
||||||
|
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
|
||||||
|
|
||||||
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
||||||
}
|
}
|
||||||
@@ -112,9 +112,9 @@ public class AxesManager extends SkillManager {
|
|||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public int greaterImpactCheck(LivingEntity target, int damage) {
|
public int greaterImpactCheck(LivingEntity target, int damage) {
|
||||||
Player player = getPlayer();
|
if (Axes.greaterImpactChance > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Axes.greaterImpactChance)) {
|
|
||||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||||
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canShake(Entity target) {
|
public boolean canShake(Entity target) {
|
||||||
Player player = getPlayer();
|
return target instanceof LivingEntity && getSkillLevel() >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(getPlayer());
|
||||||
|
|
||||||
return target instanceof LivingEntity && SkillUtils.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,7 +134,7 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param mob The {@link LivingEntity} affected by the ability
|
* @param mob The {@link LivingEntity} affected by the ability
|
||||||
*/
|
*/
|
||||||
public void shakeCheck(LivingEntity target) {
|
public void shakeCheck(LivingEntity target) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
|
if (getShakeProbability() > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
||||||
|
|
||||||
Fishing.findPossibleDrops(target, possibleDrops);
|
Fishing.findPossibleDrops(target, possibleDrops);
|
||||||
@@ -219,7 +217,7 @@ public class FishingManager extends SkillManager {
|
|||||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||||
ItemStack treasureDrop = treasure.getDrop();
|
ItemStack treasureDrop = treasure.getDrop();
|
||||||
|
|
||||||
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
|
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,24 +63,20 @@ public class Herbalism {
|
|||||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
Material blockType = blockState.getType();
|
Material blockType = blockState.getType();
|
||||||
int dropAmount = 0;
|
int dropAmount = mcMMO.placeStore.isTrue(block) ? 0 : 1;
|
||||||
|
|
||||||
// Handle the original block
|
|
||||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
|
||||||
dropAmount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
||||||
for (int y = 1; y < 3; y++) {
|
for (int y = 1; y < 3; y++) {
|
||||||
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
||||||
Material relativeBlockType = relativeBlock.getType();
|
|
||||||
|
|
||||||
// If the first one is air, so is the next one
|
if (relativeBlock.getType() != blockType) {
|
||||||
if (relativeBlockType == Material.AIR) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
|
if (mcMMO.placeStore.isTrue(relativeBlock)) {
|
||||||
|
mcMMO.placeStore.setFalse(relativeBlock);
|
||||||
|
}
|
||||||
|
else {
|
||||||
dropAmount++;
|
dropAmount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package com.gmail.nossr50.skills.herbalism;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.CropState;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
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.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@@ -20,11 +22,9 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
||||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -54,9 +54,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseHylianLuck() {
|
public boolean canUseHylianLuck() {
|
||||||
Player player = getPlayer();
|
return Permissions.hylianLuck(getPlayer());
|
||||||
|
|
||||||
return ItemUtils.isSword(player.getItemInHand()) && Permissions.hylianLuck(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGreenTerraBlock(BlockState blockState) {
|
public boolean canGreenTerraBlock(BlockState blockState) {
|
||||||
@@ -79,7 +77,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return the modified change in hunger for the event
|
* @return the modified change in hunger for the event
|
||||||
*/
|
*/
|
||||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,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
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
* @return true if the ability was successful, false otherwise
|
|
||||||
*/
|
*/
|
||||||
public void herbalismBlockCheck(BlockState blockState) {
|
public void herbalismBlockCheck(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Material material = blockState.getType();
|
||||||
Material blockType = blockState.getType();
|
boolean oneBlockPlant = (material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK) ? false : true;
|
||||||
|
|
||||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType);
|
if (oneBlockPlant && mcMMO.placeStore.isTrue(blockState)) {
|
||||||
CustomBlock customBlock = null;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material);
|
||||||
|
ItemStack drop = null;
|
||||||
|
int amount = 1;
|
||||||
int xp = 0;
|
int xp = 0;
|
||||||
int dropAmount = 1;
|
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||||
ItemStack dropItem = null;
|
|
||||||
|
|
||||||
if (herbalismBlock != null) {
|
if (herbalismBlock != null) {
|
||||||
if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) {
|
if (herbalismBlock.hasGreenThumbPermission(getPlayer())) {
|
||||||
dropItem = herbalismBlock.getDropItem();
|
processGreenThumbPlants(blockState, greenTerra);
|
||||||
dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
|
||||||
xp = herbalismBlock.getXpGain() * dropAmount;
|
|
||||||
}
|
}
|
||||||
else if (herbalismBlock.hasGreenThumbPermission(player)) {
|
|
||||||
dropItem = herbalismBlock.getDropItem();
|
xp = herbalismBlock.getXpGain();
|
||||||
xp = herbalismBlock.getXpGain();
|
|
||||||
processGreenThumbPlants(blockState);
|
if (herbalismBlock.canDoubleDrop() && Permissions.doubleDrops(getPlayer(), skill)) {
|
||||||
|
drop = herbalismBlock.getDropItem();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
if (!oneBlockPlant) {
|
||||||
dropItem = herbalismBlock.getDropItem();
|
amount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
||||||
xp = herbalismBlock.getXpGain();
|
xp *= amount;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
customBlock = ModUtils.getCustomBlock(blockState);
|
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||||
dropItem = customBlock.getItemDrop();
|
|
||||||
xp = customBlock.getXpGain();
|
xp = customBlock.getXpGain();
|
||||||
}
|
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
if (Permissions.doubleDrops(getPlayer(), skill)) {
|
||||||
Location location = blockState.getLocation();
|
|
||||||
|
|
||||||
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
|
|
||||||
Misc.dropItems(location, dropItem, dropAmount);
|
|
||||||
}
|
|
||||||
else if (customBlock != null) {
|
|
||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||||
|
drop = customBlock.getItemDrop();
|
||||||
if (minimumDropAmount != maximumDropAmount) {
|
amount = Misc.getRandom().nextInt(maximumDropAmount - minimumDropAmount + 1) + minimumDropAmount;
|
||||||
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyXpGain(xp);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,10 +174,8 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
||||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,9 +189,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean processHylianLuck(BlockState blockState) {
|
public boolean processHylianLuck(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
|
||||||
|
|
||||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +228,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
|
|
||||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
getPlayer().sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +256,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
|
||||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -276,29 +268,82 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* Process the Green Thumb ability for plants.
|
* Process the Green Thumb ability for plants.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @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();
|
Player player = getPlayer();
|
||||||
PlayerInventory playerInventory = player.getInventory();
|
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)) {
|
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
if (!greenTerra && !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 GreenTerraTimerTask(blockState), 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (SkillUtils.activationSuccessful(player, skill, 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;
|
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) {
|
protected static void handleSilkTouchDrops(BlockState blockState) {
|
||||||
Material blockType = blockState.getType();
|
Material blockType = blockState.getType();
|
||||||
|
|
||||||
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case ENDER_STONE:
|
case ENDER_STONE:
|
||||||
case GOLD_ORE:
|
case GOLD_ORE:
|
||||||
@@ -76,7 +72,7 @@ public class Mining {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (ModUtils.isCustomMiningBlock(blockState)) {
|
if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
|
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -89,13 +85,7 @@ public class Mining {
|
|||||||
*/
|
*/
|
||||||
protected static void handleMiningDrops(BlockState blockState) {
|
protected static void handleMiningDrops(BlockState blockState) {
|
||||||
Material blockType = blockState.getType();
|
Material blockType = blockState.getType();
|
||||||
|
|
||||||
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location location = blockState.getLocation();
|
Location location = blockState.getLocation();
|
||||||
ItemStack dropItem;
|
|
||||||
|
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
@@ -130,7 +120,7 @@ public class Mining {
|
|||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||||
|
|
||||||
dropItem = customBlock.getItemDrop();
|
ItemStack dropItem = customBlock.getItemDrop();
|
||||||
|
|
||||||
if (minimumDropAmount != maximumDropAmount) {
|
if (minimumDropAmount != maximumDropAmount) {
|
||||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@@ -30,47 +31,55 @@ public class MiningManager extends SkillManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseDemolitionsExpertise() {
|
public boolean canUseDemolitionsExpertise() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= BlastMining.Tier.FOUR.getLevel() && Permissions.demolitionsExpertise(getPlayer());
|
||||||
|
|
||||||
return SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDetonate() {
|
public boolean canDetonate() {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel());
|
return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBlastMining() {
|
public boolean canUseBlastMining() {
|
||||||
return SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel());
|
return getSkillLevel() >= BlastMining.Tier.ONE.getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBiggerBombs() {
|
public boolean canUseBiggerBombs() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= BlastMining.Tier.TWO.getLevel() && Permissions.biggerBombs(getPlayer());
|
||||||
|
|
||||||
return Permissions.biggerBombs(player) && SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process double drops & XP gain for Mining.
|
* Process double drops & XP gain for Mining.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
* @param player The {@link Player} using this ability
|
|
||||||
*/
|
*/
|
||||||
public void miningBlockCheck(BlockState blockState) {
|
public void miningBlockCheck(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
int xp = Mining.getBlockXp(blockState);
|
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
applyXpGain(Mining.getBlockXp(blockState));
|
||||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
|
||||||
Mining.handleSilkTouchDrops(blockState);
|
if (Permissions.doubleDrops(player, skill)) {
|
||||||
}
|
return;
|
||||||
else {
|
|
||||||
Mining.handleMiningDrops(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,11 +142,10 @@ public class MiningManager extends SkillManager{
|
|||||||
xp += Mining.getBlockXp(blockState);
|
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)) {
|
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||||
for (int i = 1; i < dropMultiplier; i++) {
|
for (int i = 1; i < dropMultiplier; i++) {
|
||||||
xp += Mining.getBlockXp(blockState);
|
|
||||||
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +155,7 @@ public class MiningManager extends SkillManager{
|
|||||||
if (debrisYield > 0) {
|
if (debrisYield > 0) {
|
||||||
for (BlockState blockState : debris) {
|
for (BlockState blockState : debris) {
|
||||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
|
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,7 +173,7 @@ public class MiningManager extends SkillManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int processDemolitionsExpertise(int damage) {
|
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;
|
package com.gmail.nossr50.skills.repair;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
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.ItemStack;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
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.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
|
||||||
|
|
||||||
public class Repair {
|
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 int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel();
|
||||||
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
||||||
|
|
||||||
@@ -33,248 +53,164 @@ public class Repair {
|
|||||||
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
||||||
public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled();
|
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();
|
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
|
* @param item Item to check
|
||||||
* @return The player's current Arcane Forging rank
|
* @return true if the item is salvageable, false otherwise
|
||||||
*/
|
*/
|
||||||
public static int getArcaneForgingRank(PlayerProfile profile) {
|
public static boolean isSalvageable(ItemStack item) {
|
||||||
int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(item) || ItemUtils.isStringTool(item) || item.getType() == Material.BUCKET)) {
|
||||||
|
return true;
|
||||||
if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) {
|
|
||||||
return 4;
|
|
||||||
}
|
}
|
||||||
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;
|
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;
|
return 2;
|
||||||
}
|
}
|
||||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) {
|
else if (ItemUtils.isHelmet(inHand)) {
|
||||||
return 1;
|
return 5;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isChestplate(inHand)) {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isLeggings(inHand)) {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isBoots(inHand)) {
|
||||||
|
return 4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
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;
|
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.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.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 {
|
public class RepairManager extends SkillManager {
|
||||||
/**
|
public RepairManager(McMMOPlayer mcMMOPlayer) {
|
||||||
* Register a repairable with the RepairManager
|
super(mcMMOPlayer, SkillType.REPAIR);
|
||||||
*
|
}
|
||||||
* @param repairable Repairable to register
|
|
||||||
*/
|
|
||||||
public void registerRepairable(Repairable repairable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 the current Arcane Forging rank
|
||||||
* @return true if repairable, false if not
|
|
||||||
*/
|
*/
|
||||||
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 The chance of keeping the enchantment
|
||||||
* @return true if repairable, false if not
|
|
||||||
*/
|
*/
|
||||||
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 chance of the enchantment being downgraded
|
||||||
* @return the repairable, can be null
|
|
||||||
*/
|
*/
|
||||||
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 durability The durability of the item being repaired
|
||||||
* @param item ItemStack that is 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.smelting;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -16,7 +15,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.skills.mining.Mining;
|
import com.gmail.nossr50.skills.mining.Mining;
|
||||||
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@@ -27,16 +25,11 @@ public class SmeltingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseFluxMining(BlockState blockState) {
|
public boolean canUseFluxMining(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.placeStore.isTrue(blockState);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
|
||||||
|
|
||||||
return BlockUtils.affectedByFluxMining(blockState) && ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseVanillaXpBoost() {
|
public boolean canUseVanillaXpBoost() {
|
||||||
Player player = getPlayer();
|
return getSkillLevel() >= Smelting.Tier.ONE.getLevel() && Permissions.vanillaXpBoost(getPlayer(), skill);
|
||||||
|
|
||||||
return SkillUtils.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +41,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
public boolean processFluxMining(BlockState blockState) {
|
public boolean processFluxMining(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (SkillUtils.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillUtils.activationSuccessful(player, skill, Smelting.fluxMiningChance)) {
|
if (Smelting.fluxMiningChance > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
@@ -72,7 +65,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
|
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +94,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
|
|
||||||
applyXpGain(Smelting.getResourceXp(resourceType));
|
applyXpGain(Smelting.getResourceXp(resourceType));
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
|
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
|
||||||
ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1);
|
ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1);
|
||||||
return newResult;
|
return newResult;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.skills.swords;
|
package com.gmail.nossr50.skills.swords;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -28,6 +29,10 @@ public class SwordsManager extends SkillManager {
|
|||||||
return Permissions.bleed(getPlayer());
|
return Permissions.bleed(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUseCounterAttack(Entity target) {
|
||||||
|
return target instanceof LivingEntity && Permissions.counterAttack(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canUseSerratedStrike() {
|
public boolean canUseSerratedStrike() {
|
||||||
return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer());
|
return mcMMOPlayer.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.serratedStrikes(getPlayer());
|
||||||
}
|
}
|
||||||
@@ -38,9 +43,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
* @param target The defending entity
|
* @param target The defending entity
|
||||||
*/
|
*/
|
||||||
public void bleedCheck(LivingEntity target) {
|
public void bleedCheck(LivingEntity target) {
|
||||||
Player player = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
|
|
||||||
|
|
||||||
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
|
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
|
||||||
BleedTimerTask.add(target, Swords.bleedMaxTicks);
|
BleedTimerTask.add(target, Swords.bleedMaxTicks);
|
||||||
@@ -50,7 +53,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
@@ -64,7 +67,7 @@ public class SwordsManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
|
||||||
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
||||||
|
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||||
|
|||||||
@@ -27,23 +27,35 @@ public class TamingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseThickFur() {
|
public boolean canUseThickFur() {
|
||||||
return getSkillLevel() > Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer());
|
return getSkillLevel() >= Taming.thickFurUnlockLevel && Permissions.thickFur(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseEnvironmentallyAware() {
|
public boolean canUseEnvironmentallyAware() {
|
||||||
return getSkillLevel() > Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer());
|
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.environmentallyAware(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseShockProof() {
|
public boolean canUseShockProof() {
|
||||||
return getSkillLevel() > Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer());
|
return getSkillLevel() >= Taming.shockProofUnlockLevel && Permissions.shockProof(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseHolyHound() {
|
public boolean canUseHolyHound() {
|
||||||
return getSkillLevel() > Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer());
|
return getSkillLevel() >= Taming.holyHoundUnlockLevel && Permissions.holyHound(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBeastLore(LivingEntity target) {
|
public boolean canUseFastFoodService() {
|
||||||
return target instanceof Tameable && Permissions.beastLore(getPlayer());
|
return getSkillLevel() >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseSharpenedClaws() {
|
||||||
|
return getSkillLevel() >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseGore() {
|
||||||
|
return Permissions.gore(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canUseBeastLore() {
|
||||||
|
return Permissions.beastLore(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +85,7 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param damage The damage being absorbed by the wolf
|
* @param damage The damage being absorbed by the wolf
|
||||||
*/
|
*/
|
||||||
public void fastFoodService(Wolf wolf, int damage) {
|
public void fastFoodService(Wolf wolf, int damage) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) {
|
if (Taming.fastFoodServiceActivationChance > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
|
|
||||||
int health = wolf.getHealth();
|
int health = wolf.getHealth();
|
||||||
int maxHealth = wolf.getMaxHealth();
|
int maxHealth = wolf.getMaxHealth();
|
||||||
@@ -91,16 +103,14 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public int gore(LivingEntity target, int damage) {
|
public int gore(LivingEntity target, int damage) {
|
||||||
Player owner = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
||||||
|
|
||||||
if (SkillUtils.activationSuccessful(owner, skill, Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
|
||||||
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.sendMessage(LocaleLoader.getString("Combat.Gore"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||||
return damage * Taming.goreModifier;
|
return damage * Taming.goreModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills.unarmed;
|
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.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class Unarmed {
|
public class Unarmed {
|
||||||
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
|
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
|
||||||
@@ -24,23 +19,4 @@ public class Unarmed {
|
|||||||
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
|
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
|
||||||
|
|
||||||
public static double berserkDamageModifier = 1.5;
|
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;
|
package com.gmail.nossr50.skills.unarmed;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -38,13 +39,38 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer());
|
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.disarm(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canDeflect() {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
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.
|
* Check for disarm.
|
||||||
*
|
*
|
||||||
* @param defender The defending player
|
* @param defender The defending player
|
||||||
*/
|
*/
|
||||||
public void disarmCheck(Player defender) {
|
public void disarmCheck(Player defender) {
|
||||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
|
||||||
McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender);
|
McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent);
|
||||||
|
|
||||||
@@ -61,10 +87,8 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* Check for arrow deflection.
|
* Check for arrow deflection.
|
||||||
*/
|
*/
|
||||||
public boolean deflectCheck() {
|
public boolean deflectCheck() {
|
||||||
Player player = getPlayer();
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
|
||||||
if (SkillUtils.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
package com.gmail.nossr50.skills.woodcutting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.Tree;
|
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.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
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 final class Woodcutting {
|
||||||
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
|
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
|
||||||
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance();
|
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance();
|
||||||
|
|
||||||
|
public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||||
|
public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
|
||||||
|
|
||||||
protected enum ExperienceGainMethod {
|
protected enum ExperienceGainMethod {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
TREE_FELLER,
|
TREE_FELLER,
|
||||||
@@ -31,47 +32,6 @@ public final class Woodcutting {
|
|||||||
|
|
||||||
private 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
|
* Retrieves the experience reward from a log
|
||||||
*
|
*
|
||||||
@@ -126,11 +86,7 @@ public final class Woodcutting {
|
|||||||
* @param mcMMOPlayer Player breaking the block
|
* @param mcMMOPlayer Player breaking the block
|
||||||
* @param blockState Block being broken
|
* @param blockState Block being broken
|
||||||
*/
|
*/
|
||||||
protected static void checkForDoubleDrop(Player player, BlockState blockState) {
|
protected static void checkForDoubleDrop(BlockState blockState) {
|
||||||
if (!SkillUtils.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ModUtils.isCustomLogBlock(blockState)) {
|
if (ModUtils.isCustomLogBlock(blockState)) {
|
||||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
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;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -22,23 +28,31 @@ public final class ChimaeraWing {
|
|||||||
public static void activationCheck(Player player) {
|
public static void activationCheck(Player player) {
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (!Config.getInstance().getChimaeraEnabled() || inHand.getTypeId() != Config.getInstance().getChimaeraItemId()) {
|
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
int amount = inHand.getAmount();
|
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 (Permissions.chimaeraWing(player) && ItemUtils.isChimaeraWing(inHand)) {
|
||||||
if (SkillUtils.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
if (!SkillUtils.cooldownOver(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) {
|
||||||
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
|
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 (SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player) && amount >= Config.getInstance().getChimaeraUseCost()) {
|
||||||
if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) {
|
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
|
||||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
|
||||||
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
|
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,15 +63,40 @@ public final class ChimaeraWing {
|
|||||||
player.teleport(player.getWorld().getSpawnLocation());
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserManager.getPlayer(player).actualizeLastChimaeraTeleport();
|
||||||
MetricsManager.chimeraWingUsed();
|
MetricsManager.chimeraWingUsed();
|
||||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
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)));
|
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt, 60, player)));
|
||||||
}
|
}
|
||||||
else if (amount <= Config.getInstance().getChimaeraCost()) {
|
else if (amount <= Config.getInstance().getChimaeraUseCost()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Config.getInstance().getChimaeraItemId())));
|
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.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
@@ -98,7 +97,7 @@ public final class HolidayManager {
|
|||||||
final int firework_amount = 10;
|
final int firework_amount = 10;
|
||||||
for (int i = 0; i < firework_amount; i++) {
|
for (int i = 0; i < firework_amount; i++) {
|
||||||
int delay = (int) (Math.random() * 3) + 4;
|
int delay = (int) (Math.random() * 3) + 4;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
spawnFireworks((Player) sender);
|
spawnFireworks((Player) sender);
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.api.SpoutToolsAPI;
|
import com.gmail.nossr50.api.SpoutToolsAPI;
|
||||||
@@ -264,7 +268,7 @@ public class ItemUtils {
|
|||||||
* @return true if the item is armor, false otherwise
|
* @return true if the item is armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMinecraftArmor(ItemStack is) {
|
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;
|
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
|
* @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) {
|
public static boolean isNear(Location first, Location second, double maxDistance) {
|
||||||
if (!first.getWorld().equals(second.getWorld())) {
|
if (first.getWorld() != second.getWorld()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static CustomBlock getCustomBlock(BlockState blockState) {
|
public static CustomBlock getCustomBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -88,7 +88,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -110,7 +110,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -132,7 +132,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomMiningBlock(BlockState blockState) {
|
public static boolean isCustomMiningBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -154,7 +154,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -176,7 +176,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -198,7 +198,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomLeafBlock(BlockState blockState) {
|
public static boolean isCustomLeafBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -220,7 +220,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomLogBlock(BlockState blockState) {
|
public static boolean isCustomLogBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
@@ -242,7 +242,7 @@ public final class ModUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isCustomOreBlock(BlockState blockState) {
|
public static boolean isCustomOreBlock(BlockState blockState) {
|
||||||
if (customBlocksEnabled) {
|
if (customBlocksEnabled) {
|
||||||
ItemStack item = blockState.getData().toItemStack();
|
ItemStack item = blockState.getData().toItemStack(1);
|
||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
|
|||||||
@@ -231,8 +231,6 @@ public final class Permissions {
|
|||||||
for (World world : server.getWorlds()) {
|
for (World world : server.getWorlds()) {
|
||||||
addDynamicPermission("mcmmo.commands.ptp.world." + world.getName(), PermissionDefault.OP, pluginManager);
|
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) {
|
private static void addDynamicPermission(String permissionName, PermissionDefault permissionDefault, PluginManager pluginManager) {
|
||||||
|
|||||||
@@ -43,12 +43,18 @@ public class UpdateChecker {
|
|||||||
jo = (JSONObject) jo.get("versions");
|
jo = (JSONObject) jo.get("versions");
|
||||||
newVersion = (String) jo.get("version");
|
newVersion = (String) jo.get("version");
|
||||||
|
|
||||||
String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]");
|
String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
|
||||||
String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]");
|
String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
Integer newVer = Integer.parseInt(newTokens[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) {
|
if (oldVer < newVer) {
|
||||||
isr.close();
|
isr.close();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ import java.io.StreamCorruptedException;
|
|||||||
import java.io.UTFDataFormatException;
|
import java.io.UTFDataFormatException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class HashChunkletManager implements ChunkletManager {
|
public class HashChunkletManager implements ChunkletManager {
|
||||||
public HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
|
public HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAll() {
|
public void saveAll() {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||||
saveWorld(world);
|
saveWorld(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,7 +177,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
@Override
|
@Override
|
||||||
public void unloadAll() {
|
public void unloadAll() {
|
||||||
saveAll();
|
saveAll();
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||||
unloadWorld(world);
|
unloadWorld(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +277,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
for (String key : store.keySet()) {
|
for (String key : store.keySet()) {
|
||||||
if (store.get(key).isEmpty()) {
|
if (store.get(key).isEmpty()) {
|
||||||
String[] info = key.split(",");
|
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]);
|
File cxDir = new File(dataDir, "" + info[1]);
|
||||||
if (!cxDir.exists()) {
|
if (!cxDir.exists()) {
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
|
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
|
||||||
|
|
||||||
public class HashChunkManager implements ChunkManager {
|
public class HashChunkManager implements ChunkManager {
|
||||||
@@ -283,7 +283,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
public synchronized void saveAll() {
|
public synchronized void saveAll() {
|
||||||
closeAll();
|
closeAll();
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||||
saveWorld(world);
|
saveWorld(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
public synchronized void unloadAll() {
|
public synchronized void unloadAll() {
|
||||||
closeAll();
|
closeAll();
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : mcMMO.p.getServer().getWorlds()) {
|
||||||
unloadWorld(world);
|
unloadWorld(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,21 +55,26 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
|
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
|
||||||
Player player = (Player) attacker;
|
Player player = (Player) attacker;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (Misc.isNPCEntity(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if (target instanceof Tameable) {
|
if (target instanceof Tameable) {
|
||||||
if (heldItem.getType() == Material.BONE && Permissions.beastLore(player)) {
|
if (heldItem.getType() == Material.BONE) {
|
||||||
mcMMOPlayer.getTamingManager().beastLore(target);
|
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
if (tamingManager.canUseBeastLore()) {
|
||||||
|
tamingManager.beastLore(target);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (isFriendlyPet(player, (Tameable) target)) {
|
|
||||||
|
if (isFriendlyPet(player, (Tameable) target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +99,7 @@ public final class CombatUtils {
|
|||||||
swordsManager.serratedStrikes(target, event.getDamage());
|
swordsManager.serratedStrikes(target, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(swordsManager.getMcMMOPlayer(), target, SkillType.SWORDS);
|
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isAxe(heldItem)) {
|
else if (ItemUtils.isAxe(heldItem)) {
|
||||||
@@ -128,7 +133,7 @@ public final class CombatUtils {
|
|||||||
axesManager.skullSplitterCheck(target, event.getDamage());
|
axesManager.skullSplitterCheck(target, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(axesManager.getMcMMOPlayer(), target, SkillType.AXES);
|
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (heldItem.getType() == Material.AIR) {
|
else if (heldItem.getType() == Material.AIR) {
|
||||||
@@ -155,14 +160,7 @@ public final class CombatUtils {
|
|||||||
unarmedManager.disarmCheck((Player) target);
|
unarmedManager.disarmCheck((Player) target);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(unarmedManager.getMcMMOPlayer(), target, SkillType.UNARMED);
|
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (heldItem.getType() == Material.BONE) {
|
|
||||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
|
||||||
|
|
||||||
if (tamingManager.canUseBeastLore(target)) {
|
|
||||||
tamingManager.beastLore(target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,17 +183,16 @@ public final class CombatUtils {
|
|||||||
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
||||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||||
int skillLevel = tamingManager.getSkillLevel();
|
|
||||||
|
|
||||||
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) {
|
if (tamingManager.canUseFastFoodService()) {
|
||||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) {
|
if (tamingManager.canUseSharpenedClaws()) {
|
||||||
event.setDamage(Taming.sharpenedClaws(event.getDamage()));
|
event.setDamage(Taming.sharpenedClaws(event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.gore(master)) {
|
if (tamingManager.canUseGore()) {
|
||||||
event.setDamage(tamingManager.gore(target, event.getDamage()));
|
event.setDamage(tamingManager.gore(target, event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,10 +211,47 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldProcessSkill(target, SkillType.ARCHERY)) {
|
if (!shouldProcessSkill(target, SkillType.ARCHERY)) {
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) shooter;
|
||||||
|
|
||||||
|
if (Misc.isNPCEntity(player)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Permissions.skillEnabled(player, SkillType.ARCHERY)) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||||
|
|
||||||
|
if (archeryManager.canSkillShot()) {
|
||||||
|
event.setDamage(archeryManager.skillShotCheck(event.getDamage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled()) {
|
||||||
|
UnarmedManager unarmedManager = UserManager.getPlayer((Player) target).getUnarmedManager();
|
||||||
|
|
||||||
|
if (unarmedManager.canDeflect()) {
|
||||||
|
event.setCancelled(unarmedManager.deflectCheck());
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archeryManager.canDaze(target)) {
|
||||||
|
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archeryManager.canTrackArrows()) {
|
||||||
|
archeryManager.trackArrows(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
archeryManager.distanceXpBonus(target);
|
||||||
|
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
archeryCheck((Player) shooter, target, event);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -238,59 +272,17 @@ public final class CombatUtils {
|
|||||||
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack heldItem = player.getItemInHand();
|
if (ItemUtils.isSword(player.getItemInHand())) {
|
||||||
|
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
|
||||||
if (damager instanceof Player) {
|
|
||||||
if (SkillType.SWORDS.getPVPEnabled() && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) {
|
|
||||||
mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemUtils.isSword(heldItem) && Permissions.counterAttack(player)) {
|
|
||||||
mcMMOPlayer.getSwordsManager().counterAttackChecks((LivingEntity) damager, event.getDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Process archery abilities.
|
|
||||||
*
|
|
||||||
* @param shooter The player shooting
|
|
||||||
* @param target The defending entity
|
|
||||||
* @param event The event to run the archery checks on.
|
|
||||||
*/
|
|
||||||
private static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) {
|
|
||||||
if (Misc.isNPCEntity(shooter)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) {
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(shooter);
|
|
||||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
|
||||||
|
|
||||||
if (archeryManager.canSkillShot()) {
|
|
||||||
event.setDamage(archeryManager.skillShotCheck(event.getDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) {
|
|
||||||
event.setCancelled(mcMMOPlayer.getUnarmedManager().deflectCheck());
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (archeryManager.canDaze(target)) {
|
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||||
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (archeryManager.canTrackArrows()) {
|
if (swordsManager.canUseCounterAttack(damager)) {
|
||||||
archeryManager.trackArrows(target);
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
archeryManager.distanceXpBonus(target);
|
|
||||||
startGainXp(UserManager.getPlayer(shooter), target, SkillType.ARCHERY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,7 +574,7 @@ public final class CombatUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldProcessSkill(LivingEntity target, SkillType skill) {
|
public static boolean shouldProcessSkill(Entity target, SkillType skill) {
|
||||||
boolean process;
|
boolean process;
|
||||||
|
|
||||||
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
|
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import com.gmail.nossr50.util.player.UserManager;
|
|||||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||||
|
|
||||||
public class SkillUtils {
|
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) {
|
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
|
||||||
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||||
|
|
||||||
@@ -92,10 +94,6 @@ public class SkillUtils {
|
|||||||
* @param ability The ability to watch cooldowns for
|
* @param ability The ability to watch cooldowns for
|
||||||
*/
|
*/
|
||||||
public static void watchCooldown(McMMOPlayer mcMMOPlayer, AbilityType ability) {
|
public static void watchCooldown(McMMOPlayer mcMMOPlayer, AbilityType ability) {
|
||||||
if (mcMMOPlayer == null || ability == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityInformed(ability) && cooldownOver(mcMMOPlayer.getProfile().getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
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;
|
int xpRemoved = 0;
|
||||||
|
|
||||||
if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
|
if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
while (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
|
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);
|
int xp = profile.getXpToLevel(skillType);
|
||||||
xpRemoved += xp;
|
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) {
|
public static void handleAbilitySpeedIncrease(Player player) {
|
||||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
@@ -493,7 +476,7 @@ public class SkillUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemLore.add("mcMMO Ability Tool");
|
itemLore.add("mcMMO Ability Tool");
|
||||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true);
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + enchantBuff, true);
|
||||||
|
|
||||||
itemMeta.setLore(itemLore);
|
itemMeta.setLore(itemLore);
|
||||||
heldItem.setItemMeta(itemMeta);
|
heldItem.setItemMeta(itemMeta);
|
||||||
@@ -559,11 +542,11 @@ public class SkillUtils {
|
|||||||
if (itemLore.remove("mcMMO Ability Tool")) {
|
if (itemLore.remove("mcMMO Ability Tool")) {
|
||||||
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||||
|
|
||||||
if (efficiencyLevel <= 5) {
|
if (efficiencyLevel <= enchantBuff) {
|
||||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true);
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - enchantBuff, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemMeta.setLore(itemLore);
|
itemMeta.setLore(itemLore);
|
||||||
@@ -612,12 +595,8 @@ public class SkillUtils {
|
|||||||
return chance > Misc.getRandom().nextInt(activationChance);
|
return chance > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean activationSuccessful(Player player, SkillType skill, double chance) {
|
public static boolean activationSuccessful(int skillLevel, int activationChance, double maxChance, int maxLevel) {
|
||||||
return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill));
|
return ((maxChance / maxLevel) * Math.min(skillLevel, maxLevel)) > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) {
|
|
||||||
return UserManager.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean treasureDropSuccessful(double dropChance, int activationChance) {
|
public static boolean treasureDropSuccessful(double dropChance, int activationChance) {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ Skills:
|
|||||||
General:
|
General:
|
||||||
# This setting will determine when the length of every ability gets longer with 1 second
|
# This setting will determine when the length of every ability gets longer with 1 second
|
||||||
Ability_IncreaseLevel: 50
|
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
|
# Settings for Acrobatics
|
||||||
###
|
###
|
||||||
@@ -247,6 +249,9 @@ Skills:
|
|||||||
SuperRepair_ChanceMax: 100.0
|
SuperRepair_ChanceMax: 100.0
|
||||||
SuperRepair_MaxBonusLevel: 1000
|
SuperRepair_MaxBonusLevel: 1000
|
||||||
|
|
||||||
|
# Salvage_UnlockLevel: Level when Salvage become available
|
||||||
|
Salvage_UnlockLevel: 600
|
||||||
|
|
||||||
Arcane_Forging:
|
Arcane_Forging:
|
||||||
May_Lose_Enchants: true
|
May_Lose_Enchants: true
|
||||||
Rank_Levels:
|
Rank_Levels:
|
||||||
|
|||||||
@@ -72,7 +72,10 @@ Mods:
|
|||||||
Items:
|
Items:
|
||||||
Chimaera_Wing:
|
Chimaera_Wing:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Feather_Cost: 10
|
Cooldown: 240
|
||||||
|
Prevent_Use_Underground: true
|
||||||
|
Use_Cost: 1
|
||||||
|
Recipe_Cost: 5
|
||||||
Item_ID: 288
|
Item_ID: 288
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -160,9 +163,7 @@ Skills:
|
|||||||
Level_Cap: 0
|
Level_Cap: 0
|
||||||
Anvil_Messages: true
|
Anvil_Messages: true
|
||||||
Anvil_ID: 42
|
Anvil_ID: 42
|
||||||
Salvage_enabled: true
|
|
||||||
Salvage_Anvil_ID: 41
|
Salvage_Anvil_ID: 41
|
||||||
Salvage_UnlockLevel: 600
|
|
||||||
Salvage_tools: true
|
Salvage_tools: true
|
||||||
Salvage_armor: true
|
Salvage_armor: true
|
||||||
Smelting:
|
Smelting:
|
||||||
@@ -186,7 +187,6 @@ Skills:
|
|||||||
SmoothBrick_To_CrackedBrick: true
|
SmoothBrick_To_CrackedBrick: true
|
||||||
Woodcutting:
|
Woodcutting:
|
||||||
Level_Cap: 0
|
Level_Cap: 0
|
||||||
Requires_Axe: true
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Double Drops
|
# Settings for Double Drops
|
||||||
@@ -360,8 +360,11 @@ Commands:
|
|||||||
# Settings for particles
|
# Settings for particles
|
||||||
###
|
###
|
||||||
Particles:
|
Particles:
|
||||||
|
# These settings determine if fireworks should get launched when a player activates/deactivates an ability
|
||||||
Ability_Activation: true
|
Ability_Activation: true
|
||||||
Ability_Deactivation: true
|
Ability_Deactivation: true
|
||||||
|
|
||||||
|
# Use particle effect when these abilities trigger
|
||||||
Dodge: true
|
Dodge: true
|
||||||
Bleed: true
|
Bleed: true
|
||||||
Greater_Impact: 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:
|
Item_Weights:
|
||||||
Default: 5
|
Default: 5
|
||||||
Emerald: 150
|
Emerald: 150
|
||||||
|
|||||||
@@ -566,6 +566,7 @@ Party.ItemShare.Disabled=[[RED]]Party item sharing is disabled.
|
|||||||
Commands.XPGain.Acrobatics=Falling
|
Commands.XPGain.Acrobatics=Falling
|
||||||
Commands.XPGain.Archery=Attacking Monsters
|
Commands.XPGain.Archery=Attacking Monsters
|
||||||
Commands.XPGain.Axes=Attacking Monsters
|
Commands.XPGain.Axes=Attacking Monsters
|
||||||
|
Commands.XPGain.Child=Gains levels from Parent Skills
|
||||||
Commands.XPGain.Excavation=Digging and finding treasures
|
Commands.XPGain.Excavation=Digging and finding treasures
|
||||||
Commands.XPGain.Fishing=Fishing (Go figure!)
|
Commands.XPGain.Fishing=Fishing (Go figure!)
|
||||||
Commands.XPGain.Herbalism=Harvesting Herbs
|
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
|
#EFFECTS
|
||||||
##generic
|
##generic
|
||||||
Effects.Effects=EFFECTS
|
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.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}
|
Effects.Template=[[DARK_AQUA]]{0}: [[GREEN]]{1}
|
||||||
|
|
||||||
#GUIDES
|
#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)
|
Item.Injured.Wait=You were injured recently and must wait to use this. [[YELLOW]]({0}s)
|
||||||
|
|
||||||
#SKILLS
|
#SKILLS
|
||||||
|
Skills.Child=[[GOLD]](CHILD SKILL)
|
||||||
Skills.Disarmed=[[DARK_RED]]You have been disarmed!
|
Skills.Disarmed=[[DARK_RED]]You have been disarmed!
|
||||||
Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]-----
|
Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]-----
|
||||||
Skills.NeedMore=[[DARK_RED]]You need more [[GRAY]]{0}
|
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.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)
|
Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
|
||||||
|
|
||||||
|
|||||||
@@ -1190,11 +1190,11 @@ permissions:
|
|||||||
default: false
|
default: false
|
||||||
description: Implies all mcmmo.item permissions
|
description: Implies all mcmmo.item permissions
|
||||||
children:
|
children:
|
||||||
mcmmo.item.all: true
|
mcmmo.item.all: true
|
||||||
mcmmo.item.all:
|
mcmmo.item.all:
|
||||||
description: Implies all mcmmo.item permissions
|
description: Implies all mcmmo.item permissions
|
||||||
children:
|
children:
|
||||||
mcmmo.item.chimaerawing: true
|
mcmmo.item.chimaerawing: true
|
||||||
mcmmo.item.chimaerawing:
|
mcmmo.item.chimaerawing:
|
||||||
description: Allows use of Chimaera Wing item
|
description: Allows use of Chimaera Wing item
|
||||||
mcmmo.motd:
|
mcmmo.motd:
|
||||||
|
|||||||
Reference in New Issue
Block a user