mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
172 Commits
1.4.00-bet
...
1.4.00-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13111a8d1b | ||
|
|
bbbba12e95 | ||
|
|
fbd016f86d | ||
|
|
10e7fe5560 | ||
|
|
d5bcb4346e | ||
|
|
213b4763e7 | ||
|
|
886515400d | ||
|
|
c900edb261 | ||
|
|
8fb8c67148 | ||
|
|
499411f6a2 | ||
|
|
c3eaec513b | ||
|
|
a7f858ab03 | ||
|
|
5ba4dc7b77 | ||
|
|
bbcc8f918e | ||
|
|
356c97cd67 | ||
|
|
0bdd5b219f | ||
|
|
90368d4ece | ||
|
|
ec12303834 | ||
|
|
294393bd1c | ||
|
|
4aaaf01ab5 | ||
|
|
cbbe436a69 | ||
|
|
18510ba851 | ||
|
|
0201ed332f | ||
|
|
e46ed07b94 | ||
|
|
3db6762531 | ||
|
|
f388948f04 | ||
|
|
4392e6b9ab | ||
|
|
38c3891533 | ||
|
|
a28d673eb7 | ||
|
|
55138f1599 | ||
|
|
0cd07cf2fd | ||
|
|
ae1eda915b | ||
|
|
38cd395171 | ||
|
|
3aec0e5ef4 | ||
|
|
56bd782625 | ||
|
|
d8904827ec | ||
|
|
f767edba93 | ||
|
|
07a0f43825 | ||
|
|
ec8581a835 | ||
|
|
f5290c3256 | ||
|
|
070189a7fd | ||
|
|
d409610a55 | ||
|
|
d46b134dbb | ||
|
|
5026bdcbd4 | ||
|
|
3607d0b9a1 | ||
|
|
21b8626366 | ||
|
|
4c10fdf34a | ||
|
|
8001a928ea | ||
|
|
26c2134484 | ||
|
|
2373ca82ba | ||
|
|
3bd9a30055 | ||
|
|
52467075b4 | ||
|
|
9888fe6e09 | ||
|
|
19068dee03 | ||
|
|
ca8204d8f4 | ||
|
|
35139815a6 | ||
|
|
da1e03cbfc | ||
|
|
219667965f | ||
|
|
ec8221610a | ||
|
|
afe28d54c6 | ||
|
|
1eb225cae1 | ||
|
|
e716e38386 | ||
|
|
1fe471b005 | ||
|
|
5cd542002e | ||
|
|
a485308fca | ||
|
|
9659ef65b9 | ||
|
|
214079a3cd | ||
|
|
e9dcb31002 | ||
|
|
3b05bb96e3 | ||
|
|
54ca6e78f5 | ||
|
|
9759224690 | ||
|
|
20970e430c | ||
|
|
38155e3af4 | ||
|
|
3036d4fa90 | ||
|
|
aba662e3d0 | ||
|
|
301914d94b | ||
|
|
8d16c06739 | ||
|
|
7e1eeb66d6 | ||
|
|
920bdde135 | ||
|
|
1db9a554dc | ||
|
|
62aaad8707 | ||
|
|
2fee9df625 | ||
|
|
6c6ab4c96e | ||
|
|
1d316f9420 | ||
|
|
d2035f1816 | ||
|
|
fd821139bd | ||
|
|
7e6550d147 | ||
|
|
e556b707c9 | ||
|
|
9282b7bd15 | ||
|
|
0d473d232e | ||
|
|
f9ad8ffe93 | ||
|
|
e85a0f6cfc | ||
|
|
63974f3968 | ||
|
|
3b07d4055a | ||
|
|
d052d7a3ce | ||
|
|
513a9212e4 | ||
|
|
84dce845a5 | ||
|
|
0a68b82078 | ||
|
|
3dc1afde7e | ||
|
|
e50eb1963f | ||
|
|
fdd6c0a0d8 | ||
|
|
c589c5556b | ||
|
|
17a85c94c6 | ||
|
|
4284fe1029 | ||
|
|
dec3c10ec1 | ||
|
|
c805a48a87 | ||
|
|
918d81198f | ||
|
|
1d87de0a3e | ||
|
|
fdeadde7f0 | ||
|
|
760432fb41 | ||
|
|
240589e9ea | ||
|
|
400c93fb7d | ||
|
|
1bcf43db63 | ||
|
|
79bcd76aa0 | ||
|
|
8833ceb3b5 | ||
|
|
ccc265edf9 | ||
|
|
b18a4da0d9 | ||
|
|
e956988c60 | ||
|
|
1b6d66d4b0 | ||
|
|
fd47d77800 | ||
|
|
5c76ef312f | ||
|
|
f189907ff8 | ||
|
|
6e32843fb4 | ||
|
|
a99d6eb9f8 | ||
|
|
bb37a5982e | ||
|
|
a43a5a0861 | ||
|
|
4ff1e79cc0 | ||
|
|
d28794a587 | ||
|
|
19292c8007 | ||
|
|
a67dd1d9d7 | ||
|
|
9c0f763949 | ||
|
|
6571864b16 | ||
|
|
701822c69f | ||
|
|
2eab93292e | ||
|
|
29fb8b83c2 | ||
|
|
ad68f50b14 | ||
|
|
519485f155 | ||
|
|
45fbb47ccf | ||
|
|
cf0f075acb | ||
|
|
d9aad67ca5 | ||
|
|
083a89c1a3 | ||
|
|
671be42472 | ||
|
|
add4bc24df | ||
|
|
1da1bb7218 | ||
|
|
d0d9527d39 | ||
|
|
c39827ed59 | ||
|
|
5d6a35d4ef | ||
|
|
0d62688343 | ||
|
|
80b7cc717f | ||
|
|
05a9c8b7e5 | ||
|
|
e78cbcfcc8 | ||
|
|
f7b1aea7e0 | ||
|
|
2744fb122c | ||
|
|
77638bf56a | ||
|
|
57e6e5400b | ||
|
|
f2b03896e2 | ||
|
|
8a795e6091 | ||
|
|
946513cb66 | ||
|
|
1fe182babe | ||
|
|
f61aed9f6c | ||
|
|
08882e58b6 | ||
|
|
4c6f2da78a | ||
|
|
3550310e5c | ||
|
|
cedd8da9ba | ||
|
|
3cb269de4b | ||
|
|
91010f2958 | ||
|
|
f3e823997b | ||
|
|
4ae276d1d7 | ||
|
|
f6b38ab32a | ||
|
|
6f96a5026b | ||
|
|
4071f259ad | ||
|
|
a9ed1a1850 |
@@ -9,6 +9,7 @@ Key:
|
||||
|
||||
Version 1.4.00-dev
|
||||
+ Added new Child Skill - Smelting!
|
||||
+ Added a version check, admins will get notified when a new version is available!
|
||||
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
|
||||
+ Added config options for Hylian Luck skill
|
||||
+ Added display values to Unarmed command for Iron Grip
|
||||
@@ -33,6 +34,16 @@ Version 1.4.00-dev
|
||||
+ Added '/hardcore' and '/vampirism' commands for toggling these modes on or off.
|
||||
+ Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick
|
||||
+ Added config option to disable automatic zip backups.
|
||||
+ Added particle effects for many abilities.
|
||||
+ Added '/mcnotify' command to toggle ability notifications on/off
|
||||
+ Added ability for config files to automatically update with new keys, and prune out old ones
|
||||
+ Added config option to make .new config files instead over writing over old ones when updating
|
||||
+ Added "Holy Hound" ability to Taming
|
||||
+ Added "Shroom Thumb" ability to Herbalism
|
||||
+ Added child.yml config file to choose parents for child skills
|
||||
+ Added '/party itemshare <NONE | EQUAL | RANDOM>' command to choose party item share mode
|
||||
+ Added '/party itemshare <loot | mining | herbalism | woodcutting> <true | false>' command to control items that are shared
|
||||
+ Added itemweights.yml file to determine which items are more valuable for party itemshare
|
||||
= Fixed Green Thumb on wheat not working properly at rank 4
|
||||
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
|
||||
= Fixed Green Terra not also checking Green Thumb permissions
|
||||
@@ -67,6 +78,9 @@ Version 1.4.00-dev
|
||||
= Fixed a bug where a new party leader wasn't appointed, after the previous party leader left
|
||||
= Fixed a bug where Disarm and Deflect had wrong values
|
||||
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
||||
! Changed our custom chat events to be async
|
||||
! Changed some config value key names regarding double drops and XP - make sure you copy any custom values to your new config after updating.
|
||||
! Changed Green Terra blocks to be determined via permissions instead of the config file
|
||||
! Config files are now backed up even when running in SQL mode
|
||||
! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported.
|
||||
! We're now using Bukkit sounds instead of Spout sounds.
|
||||
@@ -85,12 +99,13 @@ Version 1.4.00-dev
|
||||
! Changed BeastLore: Now also displays offline player names
|
||||
! Changed backup task to include ALL config files
|
||||
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
|
||||
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak.
|
||||
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak. Option exists in hidden.yml to change this to an potion-based buff.
|
||||
! Changed locales to fall back on English when translated strings cannot be found.
|
||||
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
|
||||
- Removed unused "healthbar" files from the resources
|
||||
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
|
||||
- Removed /mcc command. Replaced with /mcmmo [?|help|commands]
|
||||
- Removed /mcc command. Replaced with /mcmmo [?|help|commands]
|
||||
- Removed options to allow Mining & Excavation without a tool due to the changes to their abilities
|
||||
|
||||
Version 1.3.14
|
||||
+ Added new Hylian Luck skill to Herbalism.
|
||||
|
||||
17
pom.xml
17
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.00-beta3</version>
|
||||
<version>1.4.00-dev5</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -129,29 +129,14 @@
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>Plugin MetricsExtension</id>
|
||||
<url>http://repo.turt2live.com</url>
|
||||
</repository>
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class AbilityAPI {
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLIITER);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER);
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
|
||||
28
src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java
Normal file
28
src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.huds.HudType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SpoutHudAPI {
|
||||
|
||||
/**
|
||||
* Disable the mcMMO XP bar for a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*/
|
||||
public static void disableXpBar(Player player) {
|
||||
Users.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the mcMMO XP bar for the server.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*/
|
||||
public static void disableXpBar() {
|
||||
SpoutConfig.getInstance().setXPBarEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import com.gmail.nossr50.party.Party;
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message);
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
@@ -30,17 +30,20 @@ public final class ChatManager {
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat");
|
||||
mcMMO.p.getLogger().info("[A]<" + ChatColor.stripColor(displayName) + "> " + adminMessage);
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String senderName, String message) {
|
||||
handleAdminChat(plugin, senderName, senderName, message);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
handleAdminChat(plugin, playerName, displayName, message, false);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message);
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
@@ -64,4 +67,8 @@ public final class ChatManager {
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||
handlePartyChat(plugin, party, senderName, senderName, message);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
handlePartyChat(plugin, party, playerName, displayName, message, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,12 @@ public class AdminChatCommand extends ChatCommand {
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
String message = buildChatMessage(args, 0);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message);
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
}
|
||||
else {
|
||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message);
|
||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public final class CommandHelper {
|
||||
private CommandHelper() {}
|
||||
@@ -31,23 +32,23 @@ public final class CommandHelper {
|
||||
if (SkillTools.hasGatheringSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.excavation")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.EXCAVATION)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.fishing")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.FISHING)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.fishing")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.HERBALISM)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.mining")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.MINING)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.woodcutting")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.WOODCUTTING)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
}
|
||||
}
|
||||
@@ -68,23 +69,23 @@ public final class CommandHelper {
|
||||
if (SkillTools.hasCombatSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.axes")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.AXES)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.archery")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.ARCHERY)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.swords")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.SWORDS)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.taming")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.TAMING)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.unarmed")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.UNARMED)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED)));
|
||||
}
|
||||
}
|
||||
@@ -105,11 +106,11 @@ public final class CommandHelper {
|
||||
if (SkillTools.hasMiscSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.acrobatics")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.ACROBATICS)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.repair")) {
|
||||
if (Permissions.skillEnabled(inspect, SkillType.REPAIR)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.player.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.player.McnotifyCommand;
|
||||
import com.gmail.nossr50.commands.player.McrankCommand;
|
||||
import com.gmail.nossr50.commands.player.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.player.MctopCommand;
|
||||
@@ -215,7 +216,7 @@ public final class CommandRegistrationHelper {
|
||||
public static void registerMcmmoCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcmmo");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
|
||||
command.setPermission("mcmmo.commands.mcmmo;mcmmo.commands.mcmmo.help");
|
||||
command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help"));
|
||||
@@ -252,7 +253,6 @@ public final class CommandRegistrationHelper {
|
||||
public static void registerMcpurgeCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcpurge");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff()));
|
||||
command.setPermission("mcmmo.commands.mcpurge");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
||||
command.setExecutor(new McpurgeCommand());
|
||||
@@ -261,7 +261,6 @@ public final class CommandRegistrationHelper {
|
||||
public static void registerMcremoveCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcremove");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
|
||||
command.setPermission("mcmmo.commands.mcremove");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setExecutor(new McremoveCommand());
|
||||
@@ -270,7 +269,6 @@ public final class CommandRegistrationHelper {
|
||||
public static void registerMmoupdateCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mmoupdate");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
|
||||
command.setPermission("mcmmo.commands.mmoupdate");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
|
||||
command.setExecutor(new MmoupdateCommand());
|
||||
@@ -358,4 +356,13 @@ public final class CommandRegistrationHelper {
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
|
||||
command.setExecutor(new VampirismCommand());
|
||||
}
|
||||
|
||||
public static void registerMcnotifyCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcnotify");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
|
||||
command.setPermission("mcmmo.commands.mcnotify");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify"));
|
||||
command.setExecutor(new McnotifyCommand());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.addlevels")) {
|
||||
if (!Permissions.addlevels(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.addlevels.others")) {
|
||||
if (!Permissions.addlevelsOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class AddxpCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.addxp")) {
|
||||
if (!Permissions.addxp(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -69,7 +70,7 @@ public class AddxpCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.addxp.others")) {
|
||||
if (!Permissions.addxpOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class HardcoreCommand implements CommandExecutor{
|
||||
@@ -17,7 +18,7 @@ public class HardcoreCommand implements CommandExecutor{
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -33,7 +34,7 @@ public class HardcoreCommand implements CommandExecutor{
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -43,7 +44,7 @@ public class HardcoreCommand implements CommandExecutor{
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public class HardcoreCommand implements CommandExecutor{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.modify")) {
|
||||
if (!Permissions.hardcoreModify(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@@ -17,7 +18,7 @@ public class McgodCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcgod")) {
|
||||
if (!Permissions.mcgod(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -44,7 +45,7 @@ public class McgodCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcgod.others")) {
|
||||
if (!Permissions.mcgodOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
@@ -18,7 +18,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrefresh")) {
|
||||
if (!Permissions.mcrefresh(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -33,13 +33,12 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
SkillTools.handleAbilitySpeedDecrease((Player) sender); //Remove enchants left over
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrefresh.others")) {
|
||||
if (!Permissions.mcrefreshOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -69,7 +68,6 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
SkillTools.handleAbilitySpeedDecrease(player); //Remove enchants left over
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.mmoedit")) {
|
||||
if (!Permissions.mmoedit(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.mmoedit.others")) {
|
||||
if (!Permissions.mmoeditOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillresetCommand implements CommandExecutor {
|
||||
@@ -22,7 +23,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset")) {
|
||||
if (!Permissions.skillreset(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -47,7 +48,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset." + skillType.toString().toLowerCase())) {
|
||||
if (!Permissions.skillreset(sender, skillType)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
skillName = SkillTools.getSkillName(skill);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
|
||||
if (!Permissions.skillreset(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -73,7 +74,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others")) {
|
||||
if (!Permissions.skillresetOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
skillName = SkillTools.getSkillName(skill);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
|
||||
if (!Permissions.skillresetOthers(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -113,7 +114,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skillType.toString().toLowerCase())) {
|
||||
if (!Permissions.skillresetOthers(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public class SkillresetCommand implements CommandExecutor {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skillType.toString().toLowerCase())) {
|
||||
if (!Permissions.skillresetOthers(sender, skillType)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class VampirismCommand implements CommandExecutor {
|
||||
@@ -22,7 +23,7 @@ public class VampirismCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
if (!Permissions.vampirismToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -38,7 +39,7 @@ public class VampirismCommand implements CommandExecutor {
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
if (!Permissions.vampirismToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class VampirismCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
if (!Permissions.vampirismToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public class VampirismCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.modify")) {
|
||||
if (!Permissions.vampirismModify(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
@@ -20,7 +21,7 @@ public class XprateCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xprate.reset")) {
|
||||
if (!Permissions.xprateReset(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -38,7 +39,7 @@ public class XprateCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xprate.set")) {
|
||||
if (!Permissions.xprateSet(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
@@ -20,11 +21,6 @@ public class InspectCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.inspect")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
@@ -36,7 +32,8 @@ public class InspectCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.hasPermission("mcmmo.commands.inspect.offline")) {
|
||||
// TODO: Why do we care if this is a player?
|
||||
if (sender instanceof Player && !Permissions.inspectOffline(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
@@ -67,7 +64,7 @@ public class InspectCommand implements CommandExecutor {
|
||||
if (sender instanceof Player) {
|
||||
Player inspector = (Player) sender;
|
||||
|
||||
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !inspector.hasPermission("mcmmo.commands.inspect.far")) {
|
||||
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar(inspector)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@@ -17,7 +18,7 @@ public class McabilityCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcability")) {
|
||||
if (!Permissions.mcability(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -35,7 +36,7 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcability.others")) {
|
||||
if (!Permissions.mcabilityOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.commands.PartySubcommandType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -17,6 +19,11 @@ public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!Permissions.mcmmoDescription(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
String description = LocaleLoader.getString("mcMMO.Description");
|
||||
String[] mcSplit = description.split(",");
|
||||
sender.sendMessage(mcSplit);
|
||||
@@ -36,7 +43,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.mcmmo.help")) {
|
||||
if (!Permissions.mcmmoHelp(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -54,20 +61,20 @@ public class McmmoCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void displayPartyCommands(CommandSender sender) {
|
||||
if (sender.hasPermission("mcmmo.commands.party")) {
|
||||
if (Permissions.party(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.chat.party")) {
|
||||
if (Permissions.partyChat(sender)) {
|
||||
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.ptp")) {
|
||||
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
|
||||
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
@@ -78,27 +85,27 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.skillreset")) {
|
||||
if (Permissions.skillreset(sender)) {
|
||||
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mcability")) {
|
||||
if (Permissions.mcability(sender)) {
|
||||
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.chat.admin")) {
|
||||
if (Permissions.adminChat(sender)) {
|
||||
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.inspect")) {
|
||||
if (Permissions.inspect(sender)) {
|
||||
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mmoedit")) {
|
||||
if (Permissions.mmoedit(sender)) {
|
||||
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mcgod")) {
|
||||
if (Permissions.mcgod(sender)) {
|
||||
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McnotifyCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
PlayerProfile profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (profile.useChatNotifications()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
|
||||
}
|
||||
|
||||
profile.toggleChatNotifications();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.gmail.nossr50.runnables.McRankAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
@@ -23,7 +24,7 @@ public class McrankCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrank")) {
|
||||
if (!Permissions.mcrank(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -43,7 +44,7 @@ public class McrankCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrank.others")) {
|
||||
if (!Permissions.mcrankOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -58,7 +59,7 @@ public class McrankCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !!sender.hasPermission("mcmmo.commands.mcrank.others.offline")) {
|
||||
if (sender instanceof Player && !Permissions.mcrankOffline(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
@@ -66,7 +67,7 @@ public class McrankCommand implements CommandExecutor {
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !sender.hasPermission("mcmmo.commands.mcrank.others.far")) {
|
||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.mcrankFar(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McTopAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@@ -72,7 +73,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !sender.hasPermission("mcmmo.commands.mctop." + skill.toLowerCase())) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
public class AdvancedConfig extends ConfigLoader {
|
||||
public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
private static AdvancedConfig instance;
|
||||
|
||||
private AdvancedConfig() {
|
||||
super("advanced.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static AdvancedConfig getInstance() {
|
||||
@@ -17,21 +16,24 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// TODO Do we need to use this?
|
||||
}
|
||||
protected void loadKeys() {}
|
||||
|
||||
/* GENERAL */
|
||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||
|
||||
/* ACROBATICS */
|
||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
||||
public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); }
|
||||
|
||||
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
|
||||
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
||||
public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); }
|
||||
|
||||
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
||||
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
||||
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
|
||||
public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); }
|
||||
|
||||
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||
@@ -63,6 +65,7 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||
|
||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); }
|
||||
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
|
||||
|
||||
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
|
||||
@@ -107,7 +110,10 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
||||
public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getShroomThumbChanceMax() { return config.getDouble("Skills.Herbalism.ShroomThumb_ChanceMax", 50.0D); }
|
||||
public int getShroomThumbMaxLevel() { return config.getInt("Skills.Herbalism.ShroomThumb_MaxBonusLevel", 1500); }
|
||||
|
||||
/* MINING */
|
||||
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
||||
@@ -122,6 +128,51 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); }
|
||||
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
||||
|
||||
public double getBlastDamageDecreaseRank1() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank1", 0.0D); }
|
||||
public double getBlastDamageDecreaseRank2() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank2", 0.0D); }
|
||||
public double getBlastDamageDecreaseRank3() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank3", 0.0D); }
|
||||
public double getBlastDamageDecreaseRank4() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank4", 25.0D); }
|
||||
public double getBlastDamageDecreaseRank5() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank5", 25.0D); }
|
||||
public double getBlastDamageDecreaseRank6() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank6", 50.0D); }
|
||||
public double getBlastDamageDecreaseRank7() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank7", 50.0D); }
|
||||
public double getBlastDamageDecreaseRank8() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank8", 100.0D); }
|
||||
|
||||
public double getOreBonusRank1() { return config.getDouble("Skills.Mining.OreBonus_Rank1", 35.0D); }
|
||||
public double getOreBonusRank2() { return config.getDouble("Skills.Mining.OreBonus_Rank2", 40.0D); }
|
||||
public double getOreBonusRank3() { return config.getDouble("Skills.Mining.OreBonus_Rank3", 45.0D); }
|
||||
public double getOreBonusRank4() { return config.getDouble("Skills.Mining.OreBonus_Rank4", 50.0D); }
|
||||
public double getOreBonusRank5() { return config.getDouble("Skills.Mining.OreBonus_Rank5", 55.0D); }
|
||||
public double getOreBonusRank6() { return config.getDouble("Skills.Mining.OreBonus_Rank6", 60.0D); }
|
||||
public double getOreBonusRank7() { return config.getDouble("Skills.Mining.OreBonus_Rank7", 65.0D); }
|
||||
public double getOreBonusRank8() { return config.getDouble("Skills.Mining.OreBonus_Rank8", 70.0D); }
|
||||
|
||||
public double getDebrisReductionRank1() { return config.getDouble("Skills.Mining.DebrisReduction_Rank1", 10.0D); }
|
||||
public double getDebrisReductionRank2() { return config.getDouble("Skills.Mining.DebrisReduction_Rank2", 20.0D); }
|
||||
public double getDebrisReductionRank3() { return config.getDouble("Skills.Mining.DebrisReduction_Rank3", 30.0D); }
|
||||
public double getDebrisReductionRank4() { return config.getDouble("Skills.Mining.DebrisReduction_Rank4", 30.0D); }
|
||||
public double getDebrisReductionRank5() { return config.getDouble("Skills.Mining.DebrisReduction_Rank5", 30.0D); }
|
||||
public double getDebrisReductionRank6() { return config.getDouble("Skills.Mining.DebrisReduction_Rank6", 30.0D); }
|
||||
public double getDebrisReductionRank7() { return config.getDouble("Skills.Mining.DebrisReduction_Rank7", 30.0D); }
|
||||
public double getDebrisReductionRank8() { return config.getDouble("Skills.Mining.DebrisReduction_Rank8", 30.0D); }
|
||||
|
||||
public int getDropMultiplierRank1() { return config.getInt("Skills.Mining.DropMultiplier_Rank1", 1); }
|
||||
public int getDropMultiplierRank2() { return config.getInt("Skills.Mining.DropMultiplier_Rank2", 1); }
|
||||
public int getDropMultiplierRank3() { return config.getInt("Skills.Mining.DropMultiplier_Rank3", 1); }
|
||||
public int getDropMultiplierRank4() { return config.getInt("Skills.Mining.DropMultiplier_Rank4", 1); }
|
||||
public int getDropMultiplierRank5() { return config.getInt("Skills.Mining.DropMultiplier_Rank5", 2); }
|
||||
public int getDropMultiplierRank6() { return config.getInt("Skills.Mining.DropMultiplier_Rank6", 2); }
|
||||
public int getDropMultiplierRank7() { return config.getInt("Skills.Mining.DropMultiplier_Rank7", 3); }
|
||||
public int getDropMultiplierRank8() { return config.getInt("Skills.Mining.DropMultiplier_Rank8", 3); }
|
||||
|
||||
public double getBlastRadiusModifierRank1() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank1", 1.0); }
|
||||
public double getBlastRadiusModifierRank2() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank2", 1.0); }
|
||||
public double getBlastRadiusModifierRank3() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank3", 2.0); }
|
||||
public double getBlastRadiusModifierRank4() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank4", 2.0); }
|
||||
public double getBlastRadiusModifierRank5() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank5", 3.0); }
|
||||
public double getBlastRadiusModifierRank6() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank6", 3.0); }
|
||||
public double getBlastRadiusModifierRank7() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank7", 4.0); }
|
||||
public double getBlastRadiusModifierRank8() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank8", 4.0); }
|
||||
|
||||
/* REPAIR */
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||
@@ -193,6 +244,8 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
||||
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
||||
|
||||
public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); }
|
||||
|
||||
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
||||
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.util.metrics.MetricsManager;
|
||||
|
||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||
super(relativePath, fileName);
|
||||
}
|
||||
|
||||
public AutoUpdateConfigLoader(String fileName) {
|
||||
super(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFile() {
|
||||
super.loadFile();
|
||||
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
||||
|
||||
Set<String> configKeys = config.getKeys(true);
|
||||
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
Set<String> oldKeys = new HashSet<String>(configKeys);
|
||||
oldKeys.removeAll(internalConfigKeys);
|
||||
|
||||
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
|
||||
newKeys.removeAll(configKeys);
|
||||
|
||||
// Don't need a re-save if we have old keys sticking around?
|
||||
// Would be less saving, but less... correct?
|
||||
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
|
||||
needSave = true;
|
||||
}
|
||||
|
||||
for (String key : oldKeys) {
|
||||
plugin.debug("Removing unused key: " + key);
|
||||
config.set(key, null);
|
||||
}
|
||||
|
||||
for (String key : newKeys) {
|
||||
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
|
||||
config.set(key, internalConfig.get(key));
|
||||
}
|
||||
|
||||
if (needSave) {
|
||||
// Get Bukkit's version of an acceptable config with new keys, and no old keys
|
||||
String output = config.saveToString();
|
||||
|
||||
// Convert to the superior 4 space indentation
|
||||
output = output.replace(" ", " ");
|
||||
|
||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||
while (output.indexOf('#') != -1) {
|
||||
output = output.substring(output.indexOf('\n', output.indexOf('#'))+1);
|
||||
}
|
||||
|
||||
// Read the internal config to get comments, then put them in the new one
|
||||
try {
|
||||
// Read internal
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
|
||||
HashMap<String, String> comments = new HashMap<String, String>();
|
||||
String temp = "";
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.contains("#")) {
|
||||
temp += line + "\n";
|
||||
}
|
||||
else if (line.contains(":")) {
|
||||
line = line.substring(0, line.indexOf(":") + 1);
|
||||
if(!temp.isEmpty()) {
|
||||
comments.put(line, temp);
|
||||
temp = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dump to the new one
|
||||
for (String key : comments.keySet()) {
|
||||
if (output.indexOf(key) != -1) {
|
||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Save it
|
||||
try {
|
||||
String saveName = fileName;
|
||||
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
|
||||
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
|
||||
saveName += ".new";
|
||||
}
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
|
||||
writer.write(output);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (String key : configKeys) {
|
||||
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
|
||||
MetricsManager.customConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,19 @@ package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
public class Config extends AutoUpdateConfigLoader {
|
||||
private static Config instance;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
@@ -35,8 +38,13 @@ public class Config extends ConfigLoader {
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
|
||||
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
||||
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
|
||||
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
||||
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
||||
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
|
||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
||||
|
||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||
|
||||
@@ -62,10 +70,14 @@ public class Config extends ConfigLoader {
|
||||
|
||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||
String str = cfg.getString(key);
|
||||
if (str == null)
|
||||
|
||||
if (str == null) {
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
if (str == null)
|
||||
}
|
||||
|
||||
if (str == "0") {
|
||||
str = "No value set for '" + key + "'";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -93,6 +105,13 @@ public class Config extends ConfigLoader {
|
||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||
|
||||
/* Particles */
|
||||
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
||||
public boolean getAbilityDeactivationEffectEnabled() { return config.getBoolean("Particles.Ability_Deactivation", true); }
|
||||
public boolean getDodgeEffectEnabled() { return config.getBoolean("Particles.Dodge", true); }
|
||||
public boolean getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", true); }
|
||||
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
|
||||
|
||||
/* PARTY SETTINGS */
|
||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
||||
@@ -118,30 +137,13 @@ public class Config extends ConfigLoader {
|
||||
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
|
||||
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
|
||||
|
||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
|
||||
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
|
||||
|
||||
/* Cooldowns */
|
||||
public int getAbilityCooldownGreenTerra() { return config.getInt("Abilities.Cooldowns.Green_Terra", 240); }
|
||||
public int getAbilityCooldownSuperBreaker() { return config.getInt("Abilities.Cooldowns.Super_Breaker", 240); }
|
||||
public int getAbilityCooldownGigaDrillBreaker() { return config.getInt("Abilities.Cooldowns.Giga_Drill_Breaker", 240); }
|
||||
public int getAbilityCooldownTreeFeller() { return config.getInt("Abilities.Cooldowns.Tree_Feller", 240); }
|
||||
public int getAbilityCooldownBerserk() { return config.getInt("Abilities.Cooldowns.Berserk", 240); }
|
||||
public int getAbilityCooldownSerratedStrikes() { return config.getInt("Abilities.Cooldowns.Serrated_Strikes", 240); }
|
||||
public int getAbilityCooldownSkullSplitter() { return config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); }
|
||||
public int getAbilityCooldownBlastMining() { return config.getInt("Abilities.Cooldowns.Blast_Mining", 60); }
|
||||
|
||||
/* Max ticks */
|
||||
public int getAbilityMaxTicksGreenTerra() { return config.getInt("Abilities.Max_Seconds.Green_Terra", 0); }
|
||||
public int getAbilityMaxTicksSuperBreaker() { return config.getInt("Abilities.Max_Seconds.Super_Breaker", 0); }
|
||||
public int getAbilityMaxTicksGigaDrillBreaker() { return config.getInt("Abilities.Max_Seconds.Giga_Drill_Breaker", 0); }
|
||||
public int getAbilityMaxTicksTreeFeller() { return config.getInt("Abilities.Max_Seconds.Tree_Feller", 0); }
|
||||
public int getAbilityMaxTicksBerserk() { return config.getInt("Abilities.Max_Seconds.Berserk", 0); }
|
||||
public int getAbilityMaxTicksSerratedStrikes() { return config.getInt("Abilities.Max_Seconds.Serrated_Strikes", 0); }
|
||||
public int getAbilityMaxTicksSkullSplitter() { return config.getInt("Abilities.Max_Seconds.Skull_Splitter", 0); }
|
||||
public int getAbilityMaxTicksBlastMining() { return config.getInt("Abilities.Max_Seconds.Blast_Mining", 0); }
|
||||
|
||||
/* Thresholds */
|
||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
||||
|
||||
@@ -149,281 +151,13 @@ public class Config extends ConfigLoader {
|
||||
* SKILL SETTINGS
|
||||
*/
|
||||
|
||||
/* Tool Requirements */
|
||||
public boolean getMiningRequiresTool() { return config.getBoolean("Skills.Mining.Requires_Pickaxe", true); }
|
||||
public boolean getExcavationRequiresTool() { return config.getBoolean("Skills.Excavation.Requires_Shovel", true); }
|
||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
|
||||
/* Excavation */
|
||||
public int getExcavationClayXP() { return config.getInt("Experience.Excavation.Clay", 40); }
|
||||
public int getExcavationDirtXP() { return config.getInt("Experience.Excavation.Dirt", 40); }
|
||||
public int getExcavationGrassXP() { return config.getInt("Experience.Excavation.Grass", 40); }
|
||||
public int getExcavationGravelXP() { return config.getInt("Experience.Excavation.Gravel", 40); }
|
||||
public int getExcavationMycelXP() { return config.getInt("Experience.Excavation.Mycel", 40); }
|
||||
public int getExcavationSandXP() { return config.getInt("Experience.Excavation.Sand", 40); }
|
||||
public int getExcavationSoulSandXP() { return config.getInt("Experience.Excavation.SoulSand", 40); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
/* Herbalism */
|
||||
public int getHerbalismXPSugarCane() { return config.getInt("Experience.Herbalism.Sugar_Cane", 30); }
|
||||
public int getHerbalismXPWheat() { return config.getInt("Experience.Herbalism.Wheat", 50); }
|
||||
public int getHerbalismXPCactus() { return config.getInt("Experience.Herbalism.Cactus", 30); }
|
||||
public int getHerbalismXPPumpkin() { return config.getInt("Experience.Herbalism.Pumpkin", 20); }
|
||||
public int getHerbalismXPFlowers() { return config.getInt("Experience.Herbalism.Flowers", 100); }
|
||||
public int getHerbalismXPMushrooms() { return config.getInt("Experience.Herbalism.Mushrooms", 150); }
|
||||
public int getHerbalismXPMelon() { return config.getInt("Experience.Herbalism.Melon", 20); }
|
||||
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
|
||||
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
|
||||
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
|
||||
public int getHerbalismXPCocoa() { return config.getInt("Experience.Herbalism.Cocoa", 30); }
|
||||
public int getHerbalismXPCarrot() { return config.getInt("Experience.Herbalism.Carrot", 50); }
|
||||
public int getHerbalismXPPotato() { return config.getInt("Experience.Herbalism.Potato", 50); }
|
||||
|
||||
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
|
||||
public boolean getHerbalismGreenThumbCobbleWallToMossyWall() { return config.getBoolean("Skills.Herbalism.Green_Thumb.CobbleWall_To_MossyWall", true); }
|
||||
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
|
||||
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
|
||||
|
||||
public boolean getBrownMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Brown_Mushrooms", true); }
|
||||
public boolean getCactiDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cacti", true); }
|
||||
public boolean getWheatDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Wheat", true); }
|
||||
public boolean getMelonsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Melons", true); }
|
||||
public boolean getNetherWartsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Nether_Warts", true); }
|
||||
public boolean getPumpkinsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Pumpkins", true); }
|
||||
public boolean getRedMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Mushrooms", true); }
|
||||
public boolean getRedRosesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Roses", true); }
|
||||
public boolean getSugarCaneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Sugar_Cane", true); }
|
||||
public boolean getVinesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Vines", true); }
|
||||
public boolean getWaterLiliesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Water_Lilies", true); }
|
||||
public boolean getYellowFlowersDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Yellow_Flowers", true); }
|
||||
public boolean getCocoaDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cocoa", true); }
|
||||
public boolean getCarrotDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Carrot", true); }
|
||||
public boolean getPotatoDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Potato", true); }
|
||||
|
||||
public boolean herbalismDoubleDropsDisabled() {
|
||||
return doubleDropsDisabled("Herbalism");
|
||||
}
|
||||
|
||||
/* Mining */
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
|
||||
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
|
||||
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
|
||||
public int getMiningXPLapisOre() { return config.getInt("Experience.Mining.Lapis", 400); }
|
||||
public int getMiningXPObsidian() { return config.getInt("Experience.Mining.Obsidian", 150); }
|
||||
public int getMiningXPNetherrack() { return config.getInt("Experience.Mining.Netherrack", 30); }
|
||||
public int getMiningXPGlowstone() { return config.getInt("Experience.Mining.Glowstone", 30); }
|
||||
public int getMiningXPCoalOre() { return config.getInt("Experience.Mining.Coal", 100); }
|
||||
public int getMiningXPStone() { return config.getInt("Experience.Mining.Stone", 30); }
|
||||
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
|
||||
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
|
||||
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
|
||||
public int getMiningXPEmeraldOre() { return config.getInt("Experience.Mining.Emerald", 1000); }
|
||||
|
||||
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
|
||||
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
|
||||
public boolean getEndStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.End_Stone", true); }
|
||||
public boolean getGlowstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Glowstone", true); }
|
||||
public boolean getGoldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Gold", true); }
|
||||
public boolean getIronDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Iron", true); }
|
||||
public boolean getLapisDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Lapis", true); }
|
||||
public boolean getMossyCobblestoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Moss_Stone", true); }
|
||||
public boolean getNetherrackDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Netherrack", true); }
|
||||
public boolean getObsidianDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Obsidian", true); }
|
||||
public boolean getRedstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Redstone", true); }
|
||||
public boolean getSandstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Sandstone", true); }
|
||||
public boolean getStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Stone", true); }
|
||||
public boolean getEmeraldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Emerald", true); }
|
||||
|
||||
public boolean miningDoubleDropsDisabled() {
|
||||
return doubleDropsDisabled("Mining");
|
||||
}
|
||||
|
||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
||||
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
|
||||
/* Smelting */
|
||||
public int getSmeltingXPCoal() { return config.getInt("Experience.Smelting.Coal", 10); }
|
||||
public int getSmeltingXPRedstone() { return config.getInt("Experience.Smelting.Redstone", 15); }
|
||||
public int getSmeltingXPIron() { return config.getInt("Experience.Smelting.Iron", 25); }
|
||||
public int getSmeltingXPGold() { return config.getInt("Experience.Smelting.Gold", 35); }
|
||||
public int getSmeltingXPDiamond() { return config.getInt("Experience.Smelting.Diamond", 75); }
|
||||
public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); }
|
||||
public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); }
|
||||
|
||||
/* Unarmed */
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
|
||||
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
||||
|
||||
/* Woodcutting */
|
||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
|
||||
|
||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||
|
||||
public boolean woodcuttingDoubleDropsDisabled() {
|
||||
return doubleDropsDisabled("Woodcutting");
|
||||
}
|
||||
|
||||
/* AFK Leveling */
|
||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Dogde Lightning */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Level Caps */
|
||||
public int getLevelCapAcrobatics() {
|
||||
return getLevelCap("Skills.Acrobatics.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapArchery() {
|
||||
return getLevelCap("Skills.Archery.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapAxes() {
|
||||
return getLevelCap("Skills.Axes.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapExcavation() {
|
||||
return getLevelCap("Skills.Excavation.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapFishing() {
|
||||
return getLevelCap("Skills.Fishing.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapHerbalism() {
|
||||
return getLevelCap("Skills.Herbalism.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapMining() {
|
||||
return getLevelCap("Skills.Mining.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapRepair() {
|
||||
return getLevelCap("Skills.Repair.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSmelting() {
|
||||
return getLevelCap("Skills.Smelting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSwords() {
|
||||
return getLevelCap("Skills.Swords.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapTaming() {
|
||||
return getLevelCap("Skills.Taming.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapUnarmed() {
|
||||
return getLevelCap("Skills.Unarmed.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapWoodcutting() {
|
||||
return getLevelCap("Skills.Woodcutting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getPowerLevelCap() {
|
||||
return getLevelCap("General.Power_Level_Cap");
|
||||
}
|
||||
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
|
||||
public boolean getAcrobaticsPVE() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVE", true); }
|
||||
public boolean getArcheryPVP() { return config.getBoolean("Skills.Archery.Enabled_For_PVP", true); }
|
||||
public boolean getArcheryPVE() { return config.getBoolean("Skills.Archery.Enabled_For_PVE", true); }
|
||||
public boolean getAxesPVP() { return config.getBoolean("Skills.Axes.Enabled_For_PVP", true); }
|
||||
public boolean getAxesPVE() { return config.getBoolean("Skills.Axes.Enabled_For_PVE", true); }
|
||||
public boolean getSwordsPVP() { return config.getBoolean("Skills.Swords.Enabled_For_PVP", true); }
|
||||
public boolean getSwordsPVE() { return config.getBoolean("Skills.Swords.Enabled_For_PVE", true); }
|
||||
public boolean getTamingPVP() { return config.getBoolean("Skills.Taming.Enabled_For_PVP", true); }
|
||||
public boolean getTamingPVE() { return config.getBoolean("Skills.Taming.Enabled_For_PVE", true); }
|
||||
public boolean getUnarmedPVP() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVP", true); }
|
||||
public boolean getUnarmedPVE() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVE", true); }
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getCreeperXP() { return config.getDouble("Experience.Combat.Multiplier.Creeper", 4.0); }
|
||||
public double getSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Skeleton", 2.0); }
|
||||
public double getSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Spider", 3.0); }
|
||||
public double getGhastXP() { return config.getDouble("Experience.Combat.Multiplier.Ghast", 3.0); }
|
||||
public double getSlimeXP() { return config.getDouble("Experience.Combat.Multiplier.Slime", 2.0); }
|
||||
public double getZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Zombie", 2.0); }
|
||||
public double getPigZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Pig_Zombie", 3.0); }
|
||||
public double getEndermanXP() { return config.getDouble("Experience.Combat.Multiplier.Enderman", 1.0); }
|
||||
public double getCaveSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Cave_Spider", 3.0); }
|
||||
public double getSilverfishXP() { return config.getDouble("Experience.Combat.Multiplier.Silverfish", 3.0); }
|
||||
public double getBlazeXP() { return config.getDouble("Experience.Combat.Multiplier.Blaze", 3.0); }
|
||||
public double getMagmaCubeXP() { return config.getDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0); }
|
||||
public double getEnderDragonXP() { return config.getDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0); }
|
||||
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
|
||||
public double getGiantXP() { return config.getDouble("Experience.Combat.Multiplier.Giant", 4.0); }
|
||||
public double getWitherXP() { return config.getDouble("Experience.Combat.Multiplier.Wither", 7.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
public double getWitchXP() { return config.getDouble("Experience.Combat.Multiplier.Witch", 4.0); }
|
||||
|
||||
/* XP Formula Multiplier */
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
public double getFormulaMultiplierTaming() { return config.getDouble("Experience.Formula.Multiplier.Taming", 1.0); }
|
||||
public double getFormulaMultiplierMining() { return config.getDouble("Experience.Formula.Multiplier.Mining", 1.0); }
|
||||
public double getFormulaMultiplierRepair() { return config.getDouble("Experience.Formula.Multiplier.Repair", 1.0); }
|
||||
public double getFormulaMultiplierWoodcutting() { return config.getDouble("Experience.Formula.Multiplier.Woodcutting", 1.0); }
|
||||
public double getFormulaMultiplierUnarmed() { return config.getDouble("Experience.Formula.Multiplier.Unarmed", 1.0); }
|
||||
public double getFormulaMultiplierHerbalism() { return config.getDouble("Experience.Formula.Multiplier.Herbalism", 1.0); }
|
||||
public double getFormulaMultiplierExcavation() { return config.getDouble("Experience.Formula.Multiplier.Excavation", 1.0); }
|
||||
public double getFormulaMultiplierArchery() { return config.getDouble("Experience.Formula.Multiplier.Archery", 1.0); }
|
||||
public double getFormulaMultiplierSwords() { return config.getDouble("Experience.Formula.Multiplier.Swords", 1.0); }
|
||||
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
||||
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
||||
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
||||
|
||||
private boolean doubleDropsDisabled(String skillName) {
|
||||
public boolean getDoubleDropsDisabled(SkillType skill) {
|
||||
String skillName = StringUtils.getCapitalized(skill.toString());
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
||||
|
||||
if (section == null) {
|
||||
mcMMO.p.getLogger().warning("The configuration files are outdated!"); //TODO Locale and more descriptive message!
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
for (String key : keys) {
|
||||
@@ -436,8 +170,88 @@ public class Config extends ConfigLoader {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private int getLevelCap(String configString) {
|
||||
int cap = config.getInt(configString, 0);
|
||||
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
|
||||
/* Acrobatics */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
/* Mining */
|
||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
||||
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
|
||||
/* Unarmed */
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
|
||||
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
||||
|
||||
/* Woodcutting */
|
||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
||||
|
||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
|
||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||
|
||||
/* AFK Leveling */
|
||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Level Caps */
|
||||
public int getPowerLevelCap() {
|
||||
int cap = config.getInt("General.Power_Level_Cap", 0);
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
public int getLevelCap(SkillType skill) {
|
||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
||||
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
|
||||
|
||||
/* XP Formula Multiplier */
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Multiplier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public class HiddenConfig {
|
||||
private static YamlConfiguration config;
|
||||
private static boolean chunkletsEnabled;
|
||||
private static int conversionRate;
|
||||
private static boolean useEnchantmentBuffs;
|
||||
|
||||
public HiddenConfig(String fileName) {
|
||||
HiddenConfig.fileName = fileName;
|
||||
@@ -29,6 +30,7 @@ public class HiddenConfig {
|
||||
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||
conversionRate = config.getInt("Options.ConversionRate", 1);
|
||||
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +41,8 @@ public class HiddenConfig {
|
||||
public int getConversionRate() {
|
||||
return conversionRate;
|
||||
}
|
||||
|
||||
public boolean useEnchantmentBuffs() {
|
||||
return useEnchantmentBuffs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ItemWeightsConfig extends ConfigLoader {
|
||||
private static ItemWeightsConfig instance;
|
||||
|
||||
private ItemWeightsConfig() {
|
||||
super("itemweights.yml");
|
||||
}
|
||||
|
||||
public static ItemWeightsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ItemWeightsConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
|
||||
public int getItemWeight(Material material) {
|
||||
String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_");
|
||||
int itemWeight = config.getInt("Item_Weights.Default");
|
||||
|
||||
if (config.getInt("Item_Weights." + materialName) > 0) {
|
||||
itemWeight = config.getInt("Item_Weights." + materialName);
|
||||
}
|
||||
return itemWeight;
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,16 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcpurge(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
|
||||
@@ -8,10 +8,16 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcremove(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
/* MySQL */
|
||||
|
||||
@@ -9,11 +9,17 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mmoupdate(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
@@ -42,4 +48,4 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
|
||||
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class SQLConversionTask implements Runnable {
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
String playerName = null;
|
||||
String party = null;
|
||||
//String party = null;
|
||||
String mining = null;
|
||||
String woodcutting = null;
|
||||
String repair = null;
|
||||
@@ -63,10 +63,13 @@ public class SQLConversionTask implements Runnable {
|
||||
if (character.length > 1) {
|
||||
mining = character[1];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Looks like we still have party as the 4th string in the array but we don't use it anymore
|
||||
if (character.length > 3) {
|
||||
party = character[3];
|
||||
}
|
||||
*/
|
||||
|
||||
if (character.length > 4) {
|
||||
miningXP = character[4];
|
||||
@@ -231,10 +234,12 @@ public class SQLConversionTask implements Runnable {
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
/*
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
*/
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -12,10 +14,13 @@ import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
@@ -26,6 +31,7 @@ public class McMMOPlayer {
|
||||
private boolean ptpEnabled = true;
|
||||
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
|
||||
private long ptpTimeout;
|
||||
private int itemShareModifier;
|
||||
private boolean partyChatMode;
|
||||
private boolean adminChatMode;
|
||||
|
||||
@@ -49,7 +55,7 @@ public class McMMOPlayer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.skills." + type.toString().toLowerCase())) {
|
||||
if (Permissions.skillEnabled(player, type)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +70,22 @@ public class McMMOPlayer {
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginXpGain(SkillType skillType, int xp) {
|
||||
if (xp == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillType.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
if (Permissions.skillEnabled(player, parentSkill)) {
|
||||
beginXpGain(parentSkill, xp / parentSkills.size());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Return if the experience has been shared
|
||||
if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) {
|
||||
return;
|
||||
@@ -81,10 +103,6 @@ public class McMMOPlayer {
|
||||
public void beginUnsharedXpGain(SkillType skillType, int xp) {
|
||||
xp = modifyXpGain(skillType, xp);
|
||||
|
||||
if (xp == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
applyXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
@@ -125,7 +143,7 @@ public class McMMOPlayer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Misc.getPowerLevelCap() < getPowerLevel() + 1)) {
|
||||
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -140,23 +158,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Too many permission checks here, is there no way to avoid that?
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp *= 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp *= 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp *= 2.5;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp *= 2;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
xp *= 1.5;
|
||||
}
|
||||
|
||||
xp = PerksUtils.handleXpPerks(player, xp);
|
||||
return xp;
|
||||
}
|
||||
|
||||
@@ -256,6 +258,20 @@ public class McMMOPlayer {
|
||||
ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public int getItemShareModifier() {
|
||||
if (itemShareModifier < 10) {
|
||||
setItemShareModifier(10);
|
||||
}
|
||||
return itemShareModifier;
|
||||
}
|
||||
|
||||
public void setItemShareModifier(int modifier) {
|
||||
if (modifier < 10) {
|
||||
modifier = 10;
|
||||
}
|
||||
itemShareModifier = modifier;
|
||||
}
|
||||
|
||||
public boolean getAdminChatMode() {
|
||||
return adminChatMode;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
@@ -37,6 +39,7 @@ public class PlayerProfile {
|
||||
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
||||
pickaxePreparationMode, axePreparationMode;
|
||||
private boolean abilityUse = true;
|
||||
private boolean displaySkillNotifications = true;
|
||||
|
||||
// Timestamps
|
||||
private long recentlyHurt;
|
||||
@@ -129,7 +132,7 @@ public class PlayerProfile {
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3)));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4)));
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5)));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldownValues.get(6)));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(cooldownValues.get(6)));
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
||||
}
|
||||
|
||||
@@ -261,7 +264,7 @@ public class PlayerProfile {
|
||||
if (character.length > 30)
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
|
||||
if (character.length > 31)
|
||||
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(character[31]));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31]));
|
||||
if (character.length > 32)
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
if (character.length > 33) {
|
||||
@@ -307,7 +310,7 @@ public class PlayerProfile {
|
||||
+ ", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA)
|
||||
+ ", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)
|
||||
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
|
||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLITTER)
|
||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
Database.write("UPDATE " + tablePrefix + "skills SET "
|
||||
@@ -390,7 +393,7 @@ public class PlayerProfile {
|
||||
writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SKULL_SPLIITER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SKULL_SPLITTER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":");
|
||||
writer.append(hudType.toString()).append(":");
|
||||
writer.append(skills.get(SkillType.FISHING)).append(":");
|
||||
@@ -669,7 +672,7 @@ public class PlayerProfile {
|
||||
case GREEN_TERRA:
|
||||
return greenTerraMode;
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
case SKULL_SPLITTER:
|
||||
return skullSplitterMode;
|
||||
|
||||
case TREE_FELLER:
|
||||
@@ -707,7 +710,7 @@ public class PlayerProfile {
|
||||
greenTerraMode = bool;
|
||||
break;
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
case SKULL_SPLITTER:
|
||||
skullSplitterMode = bool;
|
||||
break;
|
||||
|
||||
@@ -747,7 +750,7 @@ public class PlayerProfile {
|
||||
case GREEN_TERRA:
|
||||
return greenTerraInformed;
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
case SKULL_SPLITTER:
|
||||
return skullSplitterInformed;
|
||||
|
||||
case TREE_FELLER:
|
||||
@@ -789,7 +792,7 @@ public class PlayerProfile {
|
||||
greenTerraInformed = bool;
|
||||
break;
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
case SKULL_SPLITTER:
|
||||
skullSplitterInformed = bool;
|
||||
break;
|
||||
|
||||
@@ -830,6 +833,18 @@ public class PlayerProfile {
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Ability Notifications
|
||||
*/
|
||||
|
||||
public boolean useChatNotifications() {
|
||||
return displaySkillNotifications;
|
||||
}
|
||||
|
||||
public void toggleChatNotifications() {
|
||||
displaySkillNotifications = !displaySkillNotifications;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cooldowns
|
||||
*/
|
||||
@@ -889,13 +904,12 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public int getChildSkillLevel(SkillType skillType) {
|
||||
switch (skillType) {
|
||||
case SMELTING:
|
||||
return ((getSkillLevel(SkillType.MINING) / 4) + (getSkillLevel(SkillType.REPAIR) / 4)); //TODO: Make this cleaner somehow
|
||||
|
||||
default:
|
||||
return 0;
|
||||
Set<SkillType> parents = FamilyTree.getParents(skillType);
|
||||
int sum = 0;
|
||||
for (SkillType parent : parents) {
|
||||
sum += Math.min(getSkillLevel(parent), 1000);
|
||||
}
|
||||
return sum / parents.size();
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(SkillType skillType) {
|
||||
|
||||
@@ -9,4 +9,8 @@ public class McMMOAdminChatEvent extends McMMOChatEvent {
|
||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
||||
super(plugin, sender, displayName, message);
|
||||
}
|
||||
|
||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
|
||||
super(plugin, sender, displayName, message, isAsync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
|
||||
super(isAsync);
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
this.displayName = displayName;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The plugin responsible for this event, note this can be null
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,11 @@ public class McMMOPartyChatEvent extends McMMOChatEvent {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message, boolean isAsync) {
|
||||
super(plugin, sender, displayName, message, isAsync);
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the party the message will be sent to
|
||||
*/
|
||||
|
||||
@@ -26,11 +26,4 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
|
||||
public int getLevelsGained() {
|
||||
return levelsGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param levelsGained int number of levels gained in this event
|
||||
*/
|
||||
public void setLevelsGained(int levelsGained) {
|
||||
this.levelsGained = levelsGained;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -17,24 +17,23 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
||||
import com.gmail.nossr50.skills.excavation.Excavation;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
@@ -44,6 +43,7 @@ import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
@@ -60,13 +60,14 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (mcMMO.placeStore.isTrue(b)) {
|
||||
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
|
||||
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
||||
if (b.equals(futureEmptyBlock)) {
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
}
|
||||
@@ -74,9 +75,9 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.getRelative(direction).hasMetadata("pistonTrack")) {
|
||||
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) {
|
||||
mcMMO.placeStore.setTrue(b.getRelative(direction));
|
||||
b.getRelative(direction).removeMetadata("pistonTrack", plugin);
|
||||
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,19 +104,19 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
if (BlockChecks.shouldBeWatched(blockState)) {
|
||||
mcMMO.placeStore.setTrue(blockState);
|
||||
}
|
||||
|
||||
if (Repair.anvilMessagesEnabled) {
|
||||
int blockID = block.getTypeId();
|
||||
int blockID = blockState.getTypeId();
|
||||
|
||||
if (blockID == Repair.anvilID) {
|
||||
Repair.placedAnvilCheck(player, blockID);
|
||||
@@ -139,19 +140,22 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
Block block = event.getBlock();
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockChecks.canBeGreenTerra(block)) {
|
||||
if (BlockChecks.affectedByGreenTerra(blockState)) {
|
||||
HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName());
|
||||
|
||||
/* Green Terra */
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && player.hasPermission("mcmmo.ability.herbalism.greenterra")) {
|
||||
if (herbalismManager.canActivateAbility()) {
|
||||
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@@ -159,77 +163,58 @@ public class BlockListener implements Listener {
|
||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (player.hasPermission("mcmmo.skills.herbalism")) {
|
||||
Herbalism.herbalismProcCheck(block, mcMMOPlayer, plugin); //Double drops
|
||||
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, mcMMOPlayer, plugin); //Triple drops
|
||||
//Double drops
|
||||
herbalismManager.herbalismBlockCheck(blockState);
|
||||
|
||||
//Triple drops
|
||||
if (herbalismManager.canGreenTerraPlant()) {
|
||||
herbalismManager.herbalismBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockChecks.canBeSuperBroken(block) && player.hasPermission("mcmmo.skills.mining") && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (Mining.requiresTool) {
|
||||
if (ItemChecks.isPickaxe(heldItem)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.miningBlockCheck(block);
|
||||
else if (BlockChecks.affectedBySuperBreaker(blockState) && ItemChecks.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
miningManager.miningBlockCheck(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.miningBlockCheck(block);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
miningManager.miningBlockCheck(block);
|
||||
}
|
||||
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockChecks.isLog(block) && player.hasPermission("mcmmo.skills.woodcutting") && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && player.hasPermission("mcmmo.ability.woodcutting.treefeller") && ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginTreeFeller(mcMMOPlayer, block);
|
||||
else if (BlockChecks.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginTreeFeller(blockState, player);
|
||||
}
|
||||
else {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginWoodcutting(mcMMOPlayer, block);
|
||||
Woodcutting.beginWoodcutting(player, blockState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Woodcutting.beginWoodcutting(mcMMOPlayer, block);
|
||||
Woodcutting.beginWoodcutting(player, blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockChecks.canBeGigaDrillBroken(block) && player.hasPermission("mcmmo.skills.excavation") && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (Excavation.requiresTool) {
|
||||
if (ItemChecks.isShovel(heldItem)) {
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
else if (BlockChecks.affectedByGigaDrillBreaker(blockState) && ItemChecks.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(blockState)) {
|
||||
ExcavationManager excavationManager = SkillManagerStore.getInstance().getExcavationManager(player.getName());
|
||||
excavationManager.excavationBlockCheck(blockState);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||
}
|
||||
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
excavationManager.gigaDrillBreaker(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove metadata from placed watched blocks */
|
||||
if (BlockChecks.shouldBeWatched(block) && mcMMO.placeStore.isTrue(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
if (BlockChecks.shouldBeWatched(blockState) && mcMMO.placeStore.isTrue(blockState)) {
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,19 +231,24 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
String playerName = player.getName();
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
if (player.hasPermission("mcmmo.ability.herbalism.hylianluck") && ItemChecks.isSword(heldItem)) {
|
||||
Herbalism.hylianLuck(block, player, event);
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canUseHylianLuck()) {
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processHylianLuck(blockState)) {
|
||||
blockState.update(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && player.hasPermission("mcmmo.ability.smelting.fluxmining") && !mcMMO.placeStore.isTrue(block)) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.fluxMining(event);
|
||||
else if (SkillManagerStore.getInstance().getSmeltingManager(playerName).canUseFluxMining(blockState)) {
|
||||
if (SkillManagerStore.getInstance().getSmeltingManager(playerName).processFluxMining(blockState)) {
|
||||
blockState.update(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,34 +265,45 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
Block block = event.getBlock();
|
||||
BlockState blockState = event.getBlock().getState();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*
|
||||
* We check permissions here before processing activation.
|
||||
*/
|
||||
if (BlockChecks.canActivateAbilities(block)) {
|
||||
if (BlockChecks.canActivateAbilities(blockState)) {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && player.hasPermission("mcmmo.ability.herbalism.greenterra")) {
|
||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||
if ((ItemChecks.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemChecks.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
|
||||
SkillTools.removeAbilityBuff(heldItem);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockChecks.affectedBySuperBreaker(blockState)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockChecks.affectedByGigaDrillBreaker(blockState))) {
|
||||
SkillTools.handleAbilitySpeedDecrease(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.affectedByGreenTerra(blockState) || BlockChecks.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(block) && player.hasPermission("mcmmo.ability.woodcutting.treefeller")) {
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(blockState) && Permissions.treeFeller(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.canBeSuperBroken(block) && player.hasPermission("mcmmo.ability.mining.superbreaker")) {
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && player.hasPermission("mcmmo.ability.excavation.gigadrillbreaker")) {
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW || (block.getType() == Material.SMOOTH_BRICK && block.getData() == 0x0)) && player.hasPermission("mcmmo.ability.unarmed.berserk")) {
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockChecks.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
@@ -312,8 +313,8 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(block)) {
|
||||
player.playSound(block.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(blockState)) {
|
||||
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,50 +331,54 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
// Except right here, which is for the Green Thumb activation, not the normal effect of Green Terra
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block) && player.hasPermission("mcmmo.ability.herbalism.greenthumbblocks")) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).canGreenTerraBlock(blockState)) {
|
||||
if (SkillManagerStore.getInstance().getHerbalismManager(playerName).processGreenTerra(blockState)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||
if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (heldItem.getType() == Material.AIR) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
|
||||
|
||||
event.setInstaBreak(true);
|
||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||
}
|
||||
}
|
||||
// Another perm check for the cracked blocks activation
|
||||
else if (BlockChecks.canBeCracked(block) && player.hasPermission("mcmmo.ability.unarmed.blockcracker")) {
|
||||
Unarmed.blockCracker(player, block);
|
||||
else if (BlockChecks.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) {
|
||||
if (Unarmed.blockCracker(player, blockState)) {
|
||||
blockState.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) {
|
||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(blockState)) {
|
||||
if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
Woodcutting.beginLeafBlower(player, block);
|
||||
Woodcutting.beginLeafBlower(player, blockState);
|
||||
}
|
||||
}
|
||||
else if (!(heldItem.getType() == Material.SHEARS)) {
|
||||
event.setInstaBreak(true);
|
||||
Woodcutting.beginLeafBlower(player, block);
|
||||
Woodcutting.beginLeafBlower(player, blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -33,14 +32,13 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -65,13 +63,12 @@ public class EntityListener implements Listener {
|
||||
if (entity instanceof FallingBlock) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block) && !mcMMO.placeStore.isSpawnedMob(entity)) {
|
||||
if (mcMMO.placeStore.isTrue(block) && !entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
mcMMO.placeStore.addSpawnedMob(entity);
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
else if (mcMMO.placeStore.isSpawnedMob(entity)) {
|
||||
else if (entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
mcMMO.placeStore.removeSpawnedMob(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,15 +105,23 @@ public class EntityListener implements Listener {
|
||||
if (defender instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
|
||||
// TODO: Is this even possible?
|
||||
if (!defendingPlayer.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
if (!(Permissions.friendlyFire((Player) attacker) && Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
if (attacker instanceof Player) {
|
||||
Player attackingPlayer = (Player) attacker;
|
||||
|
||||
if (defendingPlayer == attackingPlayer) {
|
||||
return;
|
||||
}
|
||||
else if (PartyManager.inSameParty(defendingPlayer, attackingPlayer)) {
|
||||
if (!(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +129,7 @@ public class EntityListener implements Listener {
|
||||
if (defender instanceof LivingEntity) {
|
||||
LivingEntity livingDefender = (LivingEntity) defender;
|
||||
|
||||
if (!Misc.isInvincible(livingDefender, event)) {
|
||||
if (!CombatTools.isInvincible(livingDefender, event.getDamage())) {
|
||||
CombatTools.combatChecks(event, attacker, livingDefender);
|
||||
}
|
||||
}
|
||||
@@ -150,10 +155,15 @@ public class EntityListener implements Listener {
|
||||
DamageCause cause = event.getCause();
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (CombatTools.isInvincible(livingEntity, event.getDamage())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (livingEntity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (!player.isOnline() || Misc.isNPCPlayer(player)) {
|
||||
// TODO: Is it even possible for the player to be off-line here?
|
||||
if (!player.isOnline() || Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,28 +176,102 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Misc.isInvincible(player, event)) {
|
||||
if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) {
|
||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
|
||||
acrobaticsManager.rollCheck(event);
|
||||
}
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.demolitionsExpertise(event);
|
||||
}
|
||||
switch (cause) {
|
||||
case FALL:
|
||||
if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canRoll()) {
|
||||
event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).rollCheck(event.getDamage()));
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
profile.actualizeRecentlyHurt();
|
||||
if (event.getDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BLOCK_EXPLOSION:
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||
|
||||
if (miningManager.canUseDemolitionsExpertise()) {
|
||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
profile.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
else if (livingEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) livingEntity;
|
||||
AnimalTamer owner = pet.getOwner();
|
||||
|
||||
if ((!Misc.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner));
|
||||
tamingManager.preventDamage(event);
|
||||
if (Taming.canPreventDamage(pet, owner)) {
|
||||
Player player = (Player) owner;
|
||||
Wolf wolf = (Wolf) pet;
|
||||
|
||||
switch (cause) {
|
||||
case CONTACT:
|
||||
case FIRE:
|
||||
case LAVA:
|
||||
if (Taming.canUseEnvironmentallyAware(player)) {
|
||||
Taming.processEnvironmentallyAware(player, wolf, event.getDamage());
|
||||
}
|
||||
return;
|
||||
|
||||
case FALL:
|
||||
if (Taming.canUseEnvironmentallyAware(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
|
||||
case ENTITY_ATTACK:
|
||||
case PROJECTILE:
|
||||
if (Taming.canUseThickFur(player)) {
|
||||
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
case FIRE_TICK:
|
||||
if (Taming.canUseThickFur(player)) {
|
||||
Taming.processThickFurFire(wolf);
|
||||
}
|
||||
return;
|
||||
|
||||
case MAGIC:
|
||||
case POISON:
|
||||
case WITHER:
|
||||
if (Taming.canUseHolyHound(player)) {
|
||||
Taming.processHolyHound(wolf, event.getDamage());
|
||||
}
|
||||
return;
|
||||
|
||||
case BLOCK_EXPLOSION:
|
||||
case ENTITY_EXPLOSION:
|
||||
case LIGHTNING:
|
||||
if (Taming.canUseShockProof(player)) {
|
||||
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,7 +292,6 @@ public class EntityListener implements Listener {
|
||||
entity.setFireTicks(0);
|
||||
BleedTimer.remove(entity);
|
||||
Archery.arrowRetrievalCheck(entity);
|
||||
mcMMO.placeStore.removeSpawnedMob(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,14 +301,14 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (Misc.isSpawnerXPEnabled) {
|
||||
if (Misc.isSpawnerXPEnabled || event.getEntity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnReason reason = event.getSpawnReason();
|
||||
|
||||
if (reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) {
|
||||
mcMMO.placeStore.addSpawnedMob(event.getEntity());
|
||||
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,11 +325,10 @@ public class EntityListener implements Listener {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName());
|
||||
|
||||
if (Permissions.biggerBombs(player)) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.biggerBombs(event);
|
||||
if (miningManager.canUseBiggerBombs()) {
|
||||
event.setRadius(miningManager.biggerBombs(event.getRadius()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,10 +347,12 @@ public class EntityListener implements Listener {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(plugin.getTNTPlayer(id).getName());
|
||||
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.blastMiningDropProcessing(event);
|
||||
if (miningManager.canUseBlastMining()) {
|
||||
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
|
||||
event.setYield(0);
|
||||
}
|
||||
|
||||
plugin.removeFromTNTTracker(id);
|
||||
}
|
||||
@@ -287,7 +371,7 @@ public class EntityListener implements Listener {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -309,23 +393,31 @@ public class EntityListener implements Listener {
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, event);
|
||||
break;
|
||||
if (Permissions.farmersDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, event);
|
||||
break;
|
||||
if (Permissions.farmersDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getHerbalismManager(player.getName()).farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, event);
|
||||
break;
|
||||
if (Permissions.fishermansDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, event);
|
||||
break;
|
||||
if (Permissions.fishermansDiet(player)) {
|
||||
event.setFoodLevel(SkillManagerStore.getInstance().getFishingManager(player.getName()).handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
@@ -343,21 +435,24 @@ public class EntityListener implements Listener {
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.awardTamingXP(event);
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if (entity != null && !entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).awardTamingXP(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player) {
|
||||
Player player = (Player) event.getTarget();
|
||||
Tameable tameable = (Tameable) event.getEntity();
|
||||
|
||||
if (Misc.isFriendlyPet(player, tameable)) {
|
||||
if (CombatTools.isFriendlyPet(player, tameable)) {
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
Player owner = (Player) tameable.getOwner();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -13,15 +13,18 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InventoryListener implements Listener{
|
||||
@@ -33,37 +36,47 @@ public class InventoryListener implements Listener{
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
InventoryType inventoryType = event.getInventory().getType();
|
||||
HumanEntity player = event.getPlayer();
|
||||
|
||||
if (inventoryType == InventoryType.FURNACE) {
|
||||
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
|
||||
Furnace furnace = inventory.getHolder();
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (inventory instanceof FurnaceInventory) {
|
||||
Furnace furnace = (Furnace) inventory.getHolder();
|
||||
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
BlockState furnaceBlock = furnace.getBlock().getState();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.addToOpenFurnaceTracker(furnaceBlock, event.getPlayer().getName());
|
||||
plugin.addToOpenFurnaceTracker(furnaceBlock, player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
InventoryType inventoryType = event.getInventory().getType();
|
||||
HumanEntity player = event.getPlayer();
|
||||
|
||||
if (inventoryType == InventoryType.FURNACE) {
|
||||
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
|
||||
Furnace furnace = inventory.getHolder();
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (inventory instanceof FurnaceInventory) {
|
||||
Furnace furnace = (Furnace) inventory.getHolder();
|
||||
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
BlockState furnaceBlock = furnace.getBlock().getState();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.removeFromFurnaceTracker(furnaceBlock);
|
||||
@@ -73,19 +86,20 @@ public class InventoryListener implements Listener{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
BlockState furnaceBlock = event.getBlock().getState();
|
||||
|
||||
if (furnaceBlock instanceof Furnace) {
|
||||
ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (player != null) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.fuelEfficiency(event);
|
||||
|
||||
if (!Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.fuelEfficiency(player)) {
|
||||
event.setBurnTime(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).fuelEfficiency(event.getBurnTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,19 +107,20 @@ public class InventoryListener implements Listener{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
BlockState furnaceBlock = event.getBlock().getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
if (furnaceBlock instanceof Furnace) {
|
||||
ItemStack smelting = ((Furnace) furnaceBlock).getInventory().getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (player != null) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.smeltProcessing(event);
|
||||
if (!Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||
event.setResult(SkillManagerStore.getInstance().getSmeltingManager(player.getName()).smeltProcessing(event.getSource().getType(), event.getResult()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,27 +128,23 @@ public class InventoryListener implements Listener{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
BlockState furnaceBlock = event.getBlock().getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack result = inventory.getResult();
|
||||
if (furnaceBlock instanceof Furnace) {
|
||||
ItemStack result = ((Furnace) furnaceBlock).getInventory().getResult();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) {
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(event.getPlayer());
|
||||
|
||||
if (mcMMOPlayer.getPlayer().equals(plugin.getFurnacePlayer(furnaceBlock))) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer);
|
||||
smeltingManager.vanillaXPBoost(event);
|
||||
event.setExpToDrop(SkillManagerStore.getInstance().getSmeltingManager(event.getPlayer().getName()).vanillaXPBoost(event.getExpToDrop()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
SkillTools.removeAbilityBuff(item); //Remove enchants if they try to move them in an inventory
|
||||
SkillTools.removeAbilityBuff(event.getCurrentItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -17,6 +18,8 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
@@ -24,21 +27,18 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
@@ -58,28 +58,6 @@ public class PlayerListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PlayerDeath events where the event is modified.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerDeathHigher(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = Users.getPlayer(player).getProfile();
|
||||
|
||||
if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
for (ItemStack item : event.getDrops()) {
|
||||
SkillTools.removeAbilityBuff(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerDeath events.
|
||||
*
|
||||
@@ -93,11 +71,11 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.hardcoremodeBypass(player)) {
|
||||
if (!Permissions.hardcoreBypass(player)) {
|
||||
Player killer = player.getKiller();
|
||||
|
||||
if (killer != null && Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
@@ -117,7 +95,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,6 +113,24 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerLogin events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLoginEvent(PlayerLoginEvent event) {
|
||||
if (event.getResult() == Result.ALLOWED) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Users.addUser(player).getProfile().actualizeRespawnATS();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PlayerDropItem events that involve modifying the event.
|
||||
*
|
||||
@@ -147,7 +143,10 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
SkillTools.removeAbilityBuff(event.getItemDrop().getItemStack());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,23 +158,26 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player) || !Permissions.fishing(player)) {
|
||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
int skillLevel = mcMMOPlayer.getProfile().getSkillLevel(SkillType.FISHING);
|
||||
FishingManager fishingManager = SkillManagerStore.getInstance().getFishingManager(player.getName());
|
||||
|
||||
switch (event.getState()) {
|
||||
case CAUGHT_FISH:
|
||||
Fishing.beginFishing(mcMMOPlayer, skillLevel, event);
|
||||
fishingManager.handleFishing((Item) event.getCaught());
|
||||
|
||||
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
|
||||
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
|
||||
}
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
Entity entity = event.getCaught();
|
||||
|
||||
if (entity instanceof LivingEntity && skillLevel >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shakeMob(player)) {
|
||||
Fishing.beginShakeMob(player, (LivingEntity) entity, skillLevel);
|
||||
if (fishingManager.canShake(entity)) {
|
||||
fishingManager.shakeCheck((LivingEntity) entity);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -194,7 +196,7 @@ public class PlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
Item item = event.getItem();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -214,7 +216,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,13 +233,6 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/* We can't use the other check here because a profile hasn't been created yet.*/
|
||||
if (player == null || player.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Users.addUser(player).getProfile().actualizeRespawnATS();
|
||||
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
Motd.displayAll(player);
|
||||
}
|
||||
@@ -246,7 +241,10 @@ public class PlayerListener implements Listener {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
SkillTools.handleAbilitySpeedDecrease(player); //Remove enchants left over in case of disconnect or server crash
|
||||
if (Permissions.updateNotifications(player) && mcMMO.p.updateAvailable) {
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.outdated"));
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.newavailable"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +255,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,7 +271,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -285,7 +283,7 @@ public class PlayerListener implements Listener {
|
||||
int blockID = block.getTypeId();
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.anvilID && Permissions.repair(player) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||
if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||
mcMMO.repairManager.handleRepair(Users.getPlayer(player), heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
@@ -297,18 +295,21 @@ public class PlayerListener implements Listener {
|
||||
player.updateInventory();
|
||||
}
|
||||
/* BLAST MINING CHECK */
|
||||
else if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.detonate(event);
|
||||
else if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) {
|
||||
if (blockID == Material.TNT.getId()) {
|
||||
event.setCancelled(true); // Don't detonate the TNT if they're too close
|
||||
}
|
||||
else {
|
||||
SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.detonate(event);
|
||||
if (SkillManagerStore.getInstance().getMiningManager(player.getName()).canDetonate()) {
|
||||
SkillManagerStore.getInstance().getMiningManager(player.getName()).remoteDetonation();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -327,20 +328,21 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
Block block = event.getClickedBlock();
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
/* ACTIVATION & ITEM CHECKS */
|
||||
if (BlockChecks.canActivateAbilities(block)) {
|
||||
if (SkillTools.abilitiesEnabled) {
|
||||
if (BlockChecks.canActivateHerbalism(block)) {
|
||||
if (BlockChecks.canActivateAbilities(blockState)) {
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
if (BlockChecks.canActivateHerbalism(blockState)) {
|
||||
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@@ -356,16 +358,28 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(heldItem, player, block);
|
||||
HerbalismManager herbalismManager = SkillManagerStore.getInstance().getHerbalismManager(player.getName());
|
||||
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
|
||||
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && SkillTools.blockBreakSimulate(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* SHROOM THUMB CHECK */
|
||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||
if (herbalismManager.processShroomThumb(blockState) && SkillTools.blockBreakSimulate(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (SkillTools.abilitiesEnabled) {
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
SkillTools.activationCheck(player, SkillType.AXES);
|
||||
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||
@@ -388,12 +402,10 @@ public class PlayerListener implements Listener {
|
||||
Material type = heldItem.getType();
|
||||
|
||||
if (type == Material.RAW_FISH) {
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.summonOcelot();
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).summonOcelot();
|
||||
}
|
||||
else if (type == Material.BONE) {
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.summonWolf();
|
||||
SkillManagerStore.getInstance().getTamingManager(player.getName()).summonWolf();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +425,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,11 +439,11 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage());
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage(), true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (mcMMOPlayer.getAdminChatMode()) {
|
||||
ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage());
|
||||
ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage(), true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,12 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
@@ -32,15 +28,11 @@ public class WorldListener implements Listener {
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onStructureGrow(StructureGrowEvent event) {
|
||||
TreeType species = event.getSpecies();
|
||||
Location location = event.getLocation();
|
||||
|
||||
if (species == TreeType.BROWN_MUSHROOM || species == TreeType.RED_MUSHROOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.placeStore.isTrue(event.getLocation().getBlock())) {
|
||||
for (BlockState block : event.getBlocks()) {
|
||||
mcMMO.placeStore.setFalse(block.getBlock());
|
||||
if (mcMMO.placeStore.isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) {
|
||||
for (BlockState blockState : event.getBlocks()) {
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,22 +79,4 @@ public class WorldListener implements Listener {
|
||||
|
||||
mcMMO.placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor ChunkLoad events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
Chunk chunk = event.getChunk();
|
||||
Entity[] entities = chunk.getEntities();
|
||||
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof LivingEntity || entity instanceof FallingBlock) {
|
||||
mcMMO.placeStore.loadChunk(chunk.getX(), chunk.getZ(), event.getWorld(), entities);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,12 @@ import java.util.List;
|
||||
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
@@ -32,6 +35,7 @@ import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomEntityConfig;
|
||||
@@ -39,8 +43,8 @@ import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.runnables.PartiesLoader;
|
||||
import com.gmail.nossr50.party.runnables.PartyAutoKick;
|
||||
import com.gmail.nossr50.runnables.MobStoreCleaner;
|
||||
import com.gmail.nossr50.runnables.SaveTimer;
|
||||
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;
|
||||
@@ -49,6 +53,9 @@ import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.SpoutTools;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
import com.gmail.nossr50.util.UpdateCheck;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
@@ -59,7 +66,7 @@ public class mcMMO extends JavaPlugin {
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
||||
private HashMap<BlockState, String> furnaceTracker = new HashMap<BlockState, String>();
|
||||
|
||||
public static mcMMO p;
|
||||
|
||||
@@ -75,52 +82,81 @@ public class mcMMO extends JavaPlugin {
|
||||
private static String usersFile;
|
||||
private static String modDirectory;
|
||||
|
||||
// Update Check
|
||||
public boolean updateAvailable;
|
||||
|
||||
// Spout Check
|
||||
public static boolean spoutEnabled = false;
|
||||
|
||||
// XP Event Check
|
||||
private boolean xpEventEnabled = false;
|
||||
|
||||
// Metadata Values
|
||||
public static FixedMetadataValue metadataValue;
|
||||
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
p = this;
|
||||
setupFilePaths();
|
||||
setupSpout();
|
||||
loadConfigFiles();
|
||||
try {
|
||||
p = this;
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
Users.loadUsers();
|
||||
setupFilePaths();
|
||||
setupSpout();
|
||||
loadConfigFiles();
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
Users.loadUsers();
|
||||
}
|
||||
|
||||
registerEvents();
|
||||
|
||||
// Setup the leader boards
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
||||
Database.checkConnected();
|
||||
Database.createStructure();
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards();
|
||||
}
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
||||
}
|
||||
|
||||
getLogger().info("Version " + getDescription().getVersion() + " is enabled!");
|
||||
|
||||
scheduleTasks();
|
||||
registerCommands();
|
||||
|
||||
MetricsManager.setup();
|
||||
|
||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||
|
||||
checkForUpdates();
|
||||
|
||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||
Permissions.generateWorldTeleportPermissions();
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
getLogger().severe("There was an error while enabling mcMMO!");
|
||||
|
||||
registerEvents();
|
||||
if (!(t instanceof ExceptionInInitializerError)) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
else {
|
||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||
}
|
||||
|
||||
// Setup the leader boards
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
||||
Database.checkConnected();
|
||||
Database.createStructure();
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards();
|
||||
}
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
||||
}
|
||||
|
||||
getLogger().info("Version " + getDescription().getVersion() + " is enabled!");
|
||||
|
||||
scheduleTasks();
|
||||
registerCommands();
|
||||
|
||||
MetricsManager.setup();
|
||||
|
||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||
|
||||
new MobStoreCleaner(); // Automatically starts and stores itself
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,6 +170,22 @@ public class mcMMO extends JavaPlugin {
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
if (Config.getInstance().getUpdateCheckEnabled()) {
|
||||
try {
|
||||
updateAvailable = UpdateCheck.updateAvailable();
|
||||
}
|
||||
catch (Exception e) {
|
||||
updateAvailable = false;
|
||||
}
|
||||
|
||||
if (updateAvailable) {
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player by name.
|
||||
* </br>
|
||||
@@ -176,11 +228,16 @@ public class mcMMO extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties();
|
||||
try {
|
||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties();
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
}
|
||||
catch (NullPointerException e) {}
|
||||
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
|
||||
if (Config.getInstance().getBackupsEnabled()) {
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
@@ -190,6 +247,15 @@ public class mcMMO extends JavaPlugin {
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
if (e instanceof NoClassDefFoundError) {
|
||||
getLogger().severe("Backup class not found!");
|
||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||
}
|
||||
else {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("Was disabled."); //How informative!
|
||||
@@ -201,8 +267,7 @@ public class mcMMO extends JavaPlugin {
|
||||
TreasuresConfig.getInstance();
|
||||
HiddenConfig.getInstance();
|
||||
AdvancedConfig.getInstance();
|
||||
|
||||
|
||||
new ChildConfig();
|
||||
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
@@ -291,6 +356,7 @@ public class mcMMO extends JavaPlugin {
|
||||
CommandRegistrationHelper.registerSkillresetCommand();
|
||||
CommandRegistrationHelper.registerHardcoreCommand();
|
||||
CommandRegistrationHelper.registerVampirismCommand();
|
||||
CommandRegistrationHelper.registerMcnotifyCommand();
|
||||
|
||||
// Spout commands
|
||||
CommandRegistrationHelper.registerXplockCommand();
|
||||
@@ -376,19 +442,19 @@ public class mcMMO extends JavaPlugin {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public void addToOpenFurnaceTracker(Block furnace, String playerName) {
|
||||
public void addToOpenFurnaceTracker(BlockState furnace, String playerName) {
|
||||
furnaceTracker.put(furnace, playerName);
|
||||
}
|
||||
|
||||
public boolean furnaceIsTracked(Block furnace) {
|
||||
public boolean furnaceIsTracked(BlockState furnace) {
|
||||
return furnaceTracker.containsKey(furnace);
|
||||
}
|
||||
|
||||
public void removeFromFurnaceTracker(Block furnace) {
|
||||
public void removeFromFurnaceTracker(BlockState furnace) {
|
||||
furnaceTracker.remove(furnace);
|
||||
}
|
||||
|
||||
public Player getFurnacePlayer(Block furnace) {
|
||||
public Player getFurnacePlayer(BlockState furnace) {
|
||||
return getServer().getPlayer(furnaceTracker.get(furnace));
|
||||
}
|
||||
|
||||
@@ -419,4 +485,8 @@ public class mcMMO extends JavaPlugin {
|
||||
public void toggleXpEventEnabled() {
|
||||
xpEventEnabled = !xpEventEnabled;
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
getLogger().info("[Debug] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.gmail.nossr50.mods;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
@@ -47,19 +46,19 @@ public final class ModChecks {
|
||||
/**
|
||||
* Get the custom block associated with an block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @param blockState The block to check
|
||||
* @return the block if it exists, null otherwise
|
||||
*/
|
||||
public static CustomBlock getCustomBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
public static CustomBlock getCustomBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (!CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return b;
|
||||
if (CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,19 +78,110 @@ public final class ModChecks {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a custom block.
|
||||
* Check if a custom block is a woodcutting block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents a log, false otherwise
|
||||
*/
|
||||
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block should not activate abilites.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents an ability block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a mining block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block is custom, false otherwise
|
||||
*/
|
||||
public static boolean isCustomMiningBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
public static boolean isCustomMiningBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
if (CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an excavation block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block is custom, false otherwise
|
||||
*/
|
||||
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an herbalism block.
|
||||
*
|
||||
* @param blockState The block to check
|
||||
* @return true if the block is custom, false otherwise
|
||||
*/
|
||||
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,13 +195,15 @@ public final class ModChecks {
|
||||
* @param block The block to check
|
||||
* @return true if the block represents leaves, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLeafBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
public static boolean isCustomLeafBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,13 +217,15 @@ public final class ModChecks {
|
||||
* @param block The block to check
|
||||
* @return true if the block represents a log, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLogBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
public static boolean isCustomLogBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customLogs.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
if (CustomBlocksConfig.getInstance().customLogs.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,16 +236,18 @@ public final class ModChecks {
|
||||
/**
|
||||
* Check if a custom block is an ore block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @param blockState The block to check
|
||||
* @return true if the block represents an ore, false otherwise
|
||||
*/
|
||||
public static boolean isCustomOreBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
public static boolean isCustomOreBlock(BlockState blockState) {
|
||||
if (customBlocksEnabled) {
|
||||
ItemStack item = blockState.getData().toItemStack();
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customOres.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
if (CustomBlocksConfig.getInstance().customOres.contains(item)) {
|
||||
for (CustomBlock block : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ public class Party {
|
||||
private boolean locked;
|
||||
private ShareHandler.ShareMode xpShareMode = ShareHandler.ShareMode.NONE;
|
||||
private ShareHandler.ShareMode itemShareMode = ShareHandler.ShareMode.NONE;
|
||||
private boolean shareLootDrops = true;
|
||||
private boolean shareMiningDrops = true;
|
||||
private boolean shareHerbalismDrops = true;
|
||||
private boolean shareWoodcuttingDrops = true;
|
||||
|
||||
public List<OfflinePlayer> getMembers() {
|
||||
return members;
|
||||
@@ -47,6 +51,39 @@ public class Party {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public boolean sharingLootDrops() {
|
||||
return shareLootDrops;
|
||||
}
|
||||
|
||||
public boolean sharingMiningDrops() {
|
||||
return shareMiningDrops;
|
||||
}
|
||||
|
||||
public boolean sharingHerbalismDrops() {
|
||||
return shareHerbalismDrops;
|
||||
}
|
||||
|
||||
public boolean sharingWoodcuttingDrops() {
|
||||
return shareWoodcuttingDrops;
|
||||
}
|
||||
|
||||
public List<String> getItemShareCategories() { //TODO Locale the category names!
|
||||
List<String> shareCategories = new ArrayList<String>();
|
||||
if (sharingLootDrops()) {
|
||||
shareCategories.add("Loot");
|
||||
}
|
||||
if (sharingMiningDrops()) {
|
||||
shareCategories.add("Mining");
|
||||
}
|
||||
if (sharingHerbalismDrops()) {
|
||||
shareCategories.add("Herbalism");
|
||||
}
|
||||
if (sharingWoodcuttingDrops()) {
|
||||
shareCategories.add("Woodcutting");
|
||||
}
|
||||
return shareCategories;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -78,4 +115,20 @@ public class Party {
|
||||
public ShareHandler.ShareMode getItemShareMode() {
|
||||
return itemShareMode;
|
||||
}
|
||||
|
||||
public void setSharingLootDrops(boolean enabled) {
|
||||
this.shareLootDrops = enabled;
|
||||
}
|
||||
|
||||
public void setSharingMiningDrops(boolean enabled) {
|
||||
this.shareMiningDrops = enabled;
|
||||
}
|
||||
|
||||
public void setSharingHerbalismDrops(boolean enabled) {
|
||||
this.shareHerbalismDrops = enabled;
|
||||
}
|
||||
|
||||
public void setSharingWoodcuttingDrops(boolean enabled) {
|
||||
this.shareWoodcuttingDrops = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class PartyManager {
|
||||
List<Player> nearMembers = new ArrayList<Player>();
|
||||
if (party != null) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (player != member && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
if (!player.getName().equals(member.getName()) && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
nearMembers.add(member);
|
||||
}
|
||||
}
|
||||
@@ -223,6 +223,7 @@ public final class PartyManager {
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
mcMMOPlayer.removeParty();
|
||||
mcMMOPlayer.setItemShareModifier(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +240,7 @@ public final class PartyManager {
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
mcMMOPlayer.removeParty();
|
||||
mcMMOPlayer.setItemShareModifier(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,6 +296,10 @@ public final class PartyManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getParty() == party) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
|
||||
addToParty(player, mcMMOPlayer, party);
|
||||
}
|
||||
@@ -339,6 +345,10 @@ public final class PartyManager {
|
||||
public static void joinInvitedParty(Player player, McMMOPlayer mcMMOPlayer) {
|
||||
Party invite = mcMMOPlayer.getPartyInvite();
|
||||
|
||||
if (mcMMOPlayer.getParty() == invite) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parties.contains(invite)) {
|
||||
parties.add(invite);
|
||||
}
|
||||
@@ -356,6 +366,10 @@ public final class PartyManager {
|
||||
* @param party The party
|
||||
*/
|
||||
public static void addToParty(OfflinePlayer player, McMMOPlayer mcMMOPlayer, Party party) {
|
||||
if (mcMMOPlayer.getParty() == party) {
|
||||
return;
|
||||
}
|
||||
|
||||
informPartyMembersJoin(player, party);
|
||||
mcMMOPlayer.setParty(party);
|
||||
party.getMembers().add(player);
|
||||
|
||||
@@ -8,8 +8,10 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.ItemWeightsConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -34,6 +36,9 @@ public final class ShareHandler {
|
||||
|
||||
private ShareHandler() {}
|
||||
|
||||
private static List<Player> nearMembers;
|
||||
private static int partySize;
|
||||
|
||||
/**
|
||||
* Distribute Xp amongst party members.
|
||||
*
|
||||
@@ -48,7 +53,7 @@ public final class ShareHandler {
|
||||
switch (party.getXpShareMode()) {
|
||||
case EQUAL:
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
@@ -86,38 +91,95 @@ public final class ShareHandler {
|
||||
Item item = event.getItem();
|
||||
ItemStack itemStack = item.getItemStack();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player winningPlayer = null;
|
||||
|
||||
ItemStack newStack = itemStack.clone();
|
||||
newStack.setAmount(1);
|
||||
|
||||
if (ItemChecks.isMobDrop(itemStack) && !party.sharingLootDrops()) {
|
||||
return false;
|
||||
}
|
||||
else if (ItemChecks.isMiningDrop(itemStack) && !party.sharingMiningDrops()) {
|
||||
return false;
|
||||
}
|
||||
else if (ItemChecks.isHerbalismDrop(itemStack) && !party.sharingHerbalismDrops()) {
|
||||
return false;
|
||||
}
|
||||
else if (ItemChecks.isWoodcuttingDrop(itemStack) && !party.sharingWoodcuttingDrops()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (party.getItemShareMode()) {
|
||||
case EQUAL:
|
||||
|
||||
return false;
|
||||
case RANDOM:
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
McMMOPlayer mcMMOTarget;
|
||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int partySize = nearMembers.size() + 1;
|
||||
nearMembers.add(player);
|
||||
partySize = nearMembers.size();
|
||||
|
||||
event.setCancelled(true);
|
||||
item.remove();
|
||||
int itemWeight = ItemWeightsConfig.getInstance().getItemWeight(itemStack.getType());
|
||||
|
||||
for (int i = 0; i < itemStack.getAmount(); i++) {
|
||||
int highestRoll = 0;
|
||||
|
||||
for (Player member : nearMembers) {
|
||||
McMMOPlayer mcMMOMember = Users.getPlayer(member);
|
||||
int itemShareModifier = mcMMOMember.getItemShareModifier();
|
||||
int diceRoll = Misc.getRandom().nextInt(itemShareModifier);
|
||||
|
||||
if (diceRoll > highestRoll) {
|
||||
highestRoll = diceRoll;
|
||||
|
||||
if (winningPlayer != null) {
|
||||
McMMOPlayer mcMMOWinning = Users.getPlayer(winningPlayer);
|
||||
mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight);
|
||||
}
|
||||
|
||||
winningPlayer = member;
|
||||
}
|
||||
else {
|
||||
mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight);
|
||||
}
|
||||
}
|
||||
|
||||
mcMMOTarget = Users.getPlayer(winningPlayer);
|
||||
mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight);
|
||||
|
||||
if (winningPlayer.getInventory().addItem(newStack).size() != 0) {
|
||||
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack);
|
||||
}
|
||||
winningPlayer.updateInventory();
|
||||
}
|
||||
return true;
|
||||
case RANDOM:
|
||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
partySize = nearMembers.size() + 1;
|
||||
|
||||
event.setCancelled(true);
|
||||
item.remove();
|
||||
|
||||
Player targetPlayer;
|
||||
|
||||
ItemStack newStack = itemStack.clone();
|
||||
newStack.setAmount(1);
|
||||
|
||||
//TODO Improve this, if possible make this faster.
|
||||
for (int i = 0; i < itemStack.getAmount(); i++) {
|
||||
int randomMember = Misc.getRandom().nextInt(partySize);
|
||||
if (randomMember >= nearMembers.size()) {
|
||||
targetPlayer = player;
|
||||
winningPlayer = player;
|
||||
} else {
|
||||
targetPlayer = nearMembers.get(randomMember);
|
||||
winningPlayer = nearMembers.get(randomMember);
|
||||
}
|
||||
targetPlayer.getInventory().addItem(newStack);
|
||||
targetPlayer.updateInventory();
|
||||
|
||||
if (winningPlayer.getInventory().addItem(newStack).size() != 0) {
|
||||
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), newStack);
|
||||
}
|
||||
winningPlayer.updateInventory();
|
||||
}
|
||||
return true;
|
||||
case NONE:
|
||||
@@ -125,5 +187,4 @@ public final class ShareHandler {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,11 +16,6 @@ public class PartyAcceptCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.accept")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
player = (Player) sender;
|
||||
|
||||
@@ -14,11 +14,6 @@ import com.gmail.nossr50.util.Users;
|
||||
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.owner")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
|
||||
@@ -13,12 +13,8 @@ public class PartyChangePasswordCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.password")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
unprotectParty(sender, playerParty);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.chat.commands.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
@@ -39,7 +40,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.party")) {
|
||||
if (!Permissions.party(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -62,6 +63,12 @@ public class PartyCommand implements CommandExecutor {
|
||||
return printUsage();
|
||||
}
|
||||
|
||||
// Can't use this for lock/unlock since they're handled by the same command
|
||||
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case JOIN:
|
||||
return partyJoinCommand.onCommand(sender, command, label, args);
|
||||
|
||||
@@ -17,11 +17,6 @@ public class PartyCreateCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.create")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -14,11 +14,6 @@ import com.gmail.nossr50.util.Users;
|
||||
public class PartyDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.disband")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
|
||||
@@ -23,11 +23,6 @@ public class PartyExpShareCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.party.expshare")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PartyHelpCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party <lock|unlock>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||
return true;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyInfoCommand implements CommandExecutor {
|
||||
@@ -51,6 +52,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
private void displayShareModeInfo() {
|
||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||
boolean itemSharingActive = playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE;
|
||||
|
||||
if (!xpShareEnabled && !itemShareEnabled) {
|
||||
return;
|
||||
@@ -73,6 +75,9 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
||||
if (itemSharingActive) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories()));
|
||||
}
|
||||
}
|
||||
|
||||
private void displayPartyHeader() {
|
||||
|
||||
@@ -21,11 +21,6 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.invite")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) {
|
||||
|
||||
@@ -23,11 +23,6 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.party.itemshare")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
@@ -35,22 +30,50 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
||||
handleChangingShareMode(ShareMode.NONE);
|
||||
}
|
||||
// else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
||||
// handleChangingShareMode(ShareMode.EQUAL);
|
||||
// }
|
||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
||||
handleChangingShareMode(ShareMode.EQUAL);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("random")) {
|
||||
handleChangingShareMode(ShareMode.RANDOM);
|
||||
}
|
||||
else {
|
||||
// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
boolean toggle = false;
|
||||
|
||||
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("on")|| args[2].equalsIgnoreCase("enabled")) {
|
||||
toggle = true;
|
||||
}
|
||||
else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("off")|| args[2].equalsIgnoreCase("disabled")) {
|
||||
toggle = false;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("loot")) {
|
||||
playerParty.setSharingLootDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("mining")) {
|
||||
playerParty.setSharingMiningDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("herbalism")) {
|
||||
playerParty.setSharingHerbalismDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("woodcutting")) {
|
||||
playerParty.setSharingWoodcuttingDrops(toggle);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
}
|
||||
notifyToggleItemShareCategory(args, toggle);
|
||||
return true;
|
||||
|
||||
default:
|
||||
// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -62,4 +85,16 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyToggleItemShareCategory(String[] args, boolean toggle) {
|
||||
String state = "disabled";
|
||||
|
||||
if (toggle) {
|
||||
state = "enabled";
|
||||
}
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(args[1]), state));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,6 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.join")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -16,11 +16,6 @@ import com.gmail.nossr50.util.Users;
|
||||
public class PartyKickCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.kick")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyLockCommand implements CommandExecutor {
|
||||
@@ -55,7 +56,7 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
* Handle locking a party.
|
||||
*/
|
||||
private void lockParty(CommandSender sender, Command command) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.lock")) {
|
||||
if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +76,7 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
* @return true if party is successfully unlocked, false otherwise.
|
||||
*/
|
||||
private void unlockParty(CommandSender sender, Command command) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.unlock")) {
|
||||
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,6 @@ public class PartyQuitCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.quit")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
player = (Player) sender;
|
||||
|
||||
@@ -15,11 +15,6 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("mcmmo.commands.party.rename")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||
String leaderName = playerParty.getLeader();
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ public enum PartySubcommandType {
|
||||
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
||||
return QUIT;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("leader")) {
|
||||
return OWNER;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
return EXPSHARE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.party.commands;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -38,7 +39,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
playerProfile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.ptp.toggle")) {
|
||||
if (!Permissions.partyTeleportToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -47,7 +48,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.ptp.acceptall")) {
|
||||
if (!Permissions.partyTeleportAcceptAll(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -63,7 +64,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.ptp.accept")) {
|
||||
if (!Permissions.partyTeleportAccept(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
@@ -118,15 +119,17 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO: Someone want to clarify what's going on with these dynamic permissions?
|
||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||
String perm = "mcmmo.commands.ptp.world.";
|
||||
World targetWorld = target.getWorld();
|
||||
World playerWorld = player.getWorld();
|
||||
|
||||
if (!Permissions.hasDynamicPermission(target, perm + "all", "op")) {
|
||||
if (!Permissions.hasDynamicPermission(target, perm + target.getWorld().getName(), "op")) {
|
||||
if (!Permissions.partyTeleportAllWorlds(target)) {
|
||||
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
|
||||
return true;
|
||||
}
|
||||
else if (target.getWorld() != player.getWorld() && !Permissions.hasDynamicPermission(target, perm + player.getWorld().getName(), "op")) {
|
||||
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class McTopAsync implements Runnable {
|
||||
@@ -31,7 +33,7 @@ public class McTopAsync implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.mctop." + query.toLowerCase())) {
|
||||
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class MobStoreCleaner implements Runnable {
|
||||
private int taskID;
|
||||
|
||||
public MobStoreCleaner() {
|
||||
taskID = -1;
|
||||
start();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (taskID >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||
taskID = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (taskID < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
||||
taskID = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mcMMO.placeStore.cleanMobLists();
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,18 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
private SkillType skill;
|
||||
protected SkillType skill;
|
||||
private String skillString;
|
||||
|
||||
protected Player player;
|
||||
@@ -49,8 +51,8 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
isLucky = player.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase());
|
||||
hasEndurance = (player.hasPermission("mcmmo.perks.activationtime.twelveseconds") || player.hasPermission("mcmmo.perks.activationtime.eightseconds") || player.hasPermission("mcmmo.perks.activationtime.fourseconds"));
|
||||
isLucky = Permissions.lucky(sender, skill);
|
||||
hasEndurance = (Permissions.twelveSecondActivationBoost(sender) || Permissions.eightSecondActivationBoost(sender) || Permissions.fourSecondActivationBoost(sender));
|
||||
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
@@ -124,27 +126,13 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
|
||||
protected String[] calculateLengthDisplayValues() {
|
||||
int maxLength = skill.getAbility().getMaxTicks();
|
||||
int length = 2 + (int) (skillValue / Misc.abilityLengthIncreaseLevel);
|
||||
int enduranceLength = 0;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.activationtime.twelveseconds")) {
|
||||
enduranceLength = length + 12;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.activationtime.eightseconds")) {
|
||||
enduranceLength = length + 8;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.activationtime.fourseconds")) {
|
||||
enduranceLength = length + 4;
|
||||
}
|
||||
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||
|
||||
if (maxLength != 0) {
|
||||
if (length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
|
||||
if (enduranceLength > maxLength) {
|
||||
enduranceLength = maxLength;
|
||||
}
|
||||
}
|
||||
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
|
||||
@@ -1,30 +1,44 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public abstract class SkillManager {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected int skillLevel;
|
||||
protected int activationChance;
|
||||
protected SkillType skill;
|
||||
|
||||
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill);
|
||||
this.activationChance = SkillTools.calculateActivationChance(Permissions.lucky(mcMMOPlayer.getPlayer(), skill));
|
||||
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
|
||||
this.skill = skill;
|
||||
}
|
||||
|
||||
public McMMOPlayer getMcMMOPlayer() {
|
||||
return mcMMOPlayer;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return mcMMOPlayer.getPlayer();
|
||||
}
|
||||
|
||||
public PlayerProfile getProfile() {
|
||||
return mcMMOPlayer.getProfile();
|
||||
}
|
||||
|
||||
public int getSkillLevel() {
|
||||
return skillLevel;
|
||||
return mcMMOPlayer.getProfile().getSkillLevel(skill);
|
||||
}
|
||||
|
||||
public int getActivationChance() {
|
||||
return activationChance;
|
||||
}
|
||||
|
||||
public void applyXpGain(int xp) {
|
||||
mcMMOPlayer.beginXpGain(skill, xp);
|
||||
}
|
||||
}
|
||||
|
||||
128
src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java
Normal file
128
src/main/java/com/gmail/nossr50/skills/SkillManagerStore.java
Normal file
@@ -0,0 +1,128 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.axes.AxeManager;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillManagerStore {
|
||||
private static SkillManagerStore instance;
|
||||
|
||||
private HashMap<String, AcrobaticsManager> acrobaticsManagers = new HashMap<String, AcrobaticsManager>();
|
||||
private HashMap<String, ArcheryManager> archeryManagers = new HashMap<String, ArcheryManager>();
|
||||
private HashMap<String, AxeManager> axeManagers = new HashMap<String, AxeManager>();
|
||||
private HashMap<String, ExcavationManager> excavationManagers = new HashMap<String, ExcavationManager>();
|
||||
private HashMap<String, FishingManager> fishingManagers = new HashMap<String, FishingManager>();
|
||||
private HashMap<String, HerbalismManager> herbalismManagers = new HashMap<String, HerbalismManager>();
|
||||
private HashMap<String, MiningManager> miningManagers = new HashMap<String, MiningManager>();
|
||||
private HashMap<String, SmeltingManager> smeltingManagers = new HashMap<String, SmeltingManager>();
|
||||
private HashMap<String, SwordsManager> swordsManagers = new HashMap<String, SwordsManager>();
|
||||
private HashMap<String, TamingManager> tamingManagers = new HashMap<String, TamingManager>();
|
||||
private HashMap<String, UnarmedManager> unarmedManagers = new HashMap<String, UnarmedManager>();
|
||||
|
||||
public static SkillManagerStore getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SkillManagerStore();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public AcrobaticsManager getAcrobaticsManager(String playerName) {
|
||||
if (!acrobaticsManagers.containsKey(playerName)) {
|
||||
acrobaticsManagers.put(playerName, new AcrobaticsManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return acrobaticsManagers.get(playerName);
|
||||
}
|
||||
|
||||
public ArcheryManager getArcheryManager(String playerName) {
|
||||
if (!archeryManagers.containsKey(playerName)) {
|
||||
archeryManagers.put(playerName, new ArcheryManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return archeryManagers.get(playerName);
|
||||
}
|
||||
|
||||
public AxeManager getAxeManager(String playerName) {
|
||||
if (!axeManagers.containsKey(playerName)) {
|
||||
axeManagers.put(playerName, new AxeManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return axeManagers.get(playerName);
|
||||
}
|
||||
|
||||
public ExcavationManager getExcavationManager(String playerName) {
|
||||
if (!excavationManagers.containsKey(playerName)) {
|
||||
excavationManagers.put(playerName, new ExcavationManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return excavationManagers.get(playerName);
|
||||
}
|
||||
|
||||
public FishingManager getFishingManager(String playerName) {
|
||||
if (!fishingManagers.containsKey(playerName)) {
|
||||
fishingManagers.put(playerName, new FishingManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return fishingManagers.get(playerName);
|
||||
}
|
||||
|
||||
public HerbalismManager getHerbalismManager(String playerName) {
|
||||
if (!herbalismManagers.containsKey(playerName)) {
|
||||
herbalismManagers.put(playerName, new HerbalismManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return herbalismManagers.get(playerName);
|
||||
}
|
||||
|
||||
public MiningManager getMiningManager(String playerName) {
|
||||
if (!miningManagers.containsKey(playerName)) {
|
||||
miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return miningManagers.get(playerName);
|
||||
}
|
||||
|
||||
public SmeltingManager getSmeltingManager(String playerName) {
|
||||
if (!smeltingManagers.containsKey(playerName)) {
|
||||
smeltingManagers.put(playerName, new SmeltingManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return smeltingManagers.get(playerName);
|
||||
}
|
||||
|
||||
public SwordsManager getSwordsManager(String playerName) {
|
||||
if (!swordsManagers.containsKey(playerName)) {
|
||||
swordsManagers.put(playerName, new SwordsManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return swordsManagers.get(playerName);
|
||||
}
|
||||
|
||||
public TamingManager getTamingManager(String playerName) {
|
||||
if (!tamingManagers.containsKey(playerName)) {
|
||||
tamingManagers.put(playerName, new TamingManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return tamingManagers.get(playerName);
|
||||
}
|
||||
|
||||
public UnarmedManager getUnarmedManager(String playerName) {
|
||||
if (!unarmedManagers.containsKey(playerName)) {
|
||||
unarmedManagers.put(playerName, new UnarmedManager(Users.getPlayer(playerName)));
|
||||
}
|
||||
|
||||
return unarmedManagers.get(playerName);
|
||||
}
|
||||
}
|
||||
@@ -3,23 +3,34 @@ package com.gmail.nossr50.skills.acrobatics;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
|
||||
public class Acrobatics {
|
||||
public final class Acrobatics {
|
||||
public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax();
|
||||
public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel();
|
||||
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
|
||||
public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
|
||||
|
||||
public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax();
|
||||
public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel();
|
||||
public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
||||
|
||||
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
|
||||
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
|
||||
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
|
||||
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
|
||||
|
||||
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
|
||||
public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier();
|
||||
|
||||
public static boolean pvpEnabled = Config.getInstance().getAcrobaticsPVP();
|
||||
public static boolean pveEnabled = Config.getInstance().getAcrobaticsPVE();
|
||||
|
||||
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
|
||||
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
|
||||
|
||||
private Acrobatics() {};
|
||||
|
||||
protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) {
|
||||
return Math.max(damage / damageModifier, 1);
|
||||
}
|
||||
|
||||
protected static int calculateModifiedRollDamage(int damage, int damageThreshold) {
|
||||
return Math.max(damage - damageThreshold, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public abstract class AcrobaticsEventHandler {
|
||||
protected AcrobaticsManager manager;
|
||||
|
||||
protected EntityDamageEvent event;
|
||||
protected int damage;
|
||||
protected int skillModifier;
|
||||
protected int modifiedDamage;
|
||||
|
||||
protected AcrobaticsEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
this.damage = event.getDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the skill modifier applied for this event.
|
||||
*/
|
||||
protected abstract void calculateSkillModifier();
|
||||
|
||||
/**
|
||||
* Calculate the modified damage for this event.
|
||||
*/
|
||||
protected abstract void calculateModifiedDamage();
|
||||
|
||||
/**
|
||||
* Modify the damage dealt by this event.
|
||||
*/
|
||||
protected abstract void modifyEventDamage();
|
||||
|
||||
/**
|
||||
* Send the ability message for this event.
|
||||
*/
|
||||
protected abstract void sendAbilityMessage();
|
||||
|
||||
/**
|
||||
* Process Xp gain from this event.
|
||||
*/
|
||||
protected abstract void processXpGain(int xp);
|
||||
|
||||
/**
|
||||
* Check to ensure you're not gaining XP after you die.
|
||||
*
|
||||
* @param damage The damage to be dealt
|
||||
* @return true if the damage is fatal, false otherwise
|
||||
*/
|
||||
protected boolean isFatal(int damage) {
|
||||
Player player = manager.getMcMMOPlayer().getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player) || player.getHealth() - damage < 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,129 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class AcrobaticsManager extends SkillManager {
|
||||
public AcrobaticsManager (McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.ACROBATICS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for fall damage reduction.
|
||||
*
|
||||
* @param event The event to check
|
||||
*/
|
||||
public void rollCheck(EntityDamageEvent event) {
|
||||
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
||||
public boolean canRoll() {
|
||||
Player player = getPlayer();
|
||||
|
||||
double chance;
|
||||
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player);
|
||||
}
|
||||
|
||||
if (eventHandler.isGraceful) {
|
||||
chance = (Acrobatics.gracefulRollMaxChance / Acrobatics.gracefulRollMaxBonusLevel) * eventHandler.skillModifier;
|
||||
}
|
||||
else {
|
||||
chance = (Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * eventHandler.skillModifier;
|
||||
public boolean canDodge(Entity damager) {
|
||||
if (Permissions.dodge(getPlayer())) {
|
||||
if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) {
|
||||
return true;
|
||||
}
|
||||
else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXpGain(eventHandler.damage * Acrobatics.rollXpModifier);
|
||||
}
|
||||
else if (!eventHandler.isFatal(event.getDamage())) {
|
||||
eventHandler.processXpGain(eventHandler.damage * Acrobatics.fallXpModifier);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for dodge damage reduction.
|
||||
* Handle the damage reduction and XP gain from the Dodge ability
|
||||
*
|
||||
* @param event The event to check
|
||||
* @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
|
||||
*/
|
||||
public void dodgeCheck(EntityDamageEvent event) {
|
||||
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
||||
public int dodgeCheck(int damage) {
|
||||
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
|
||||
Player player = getPlayer();
|
||||
|
||||
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
|
||||
if (!isFatal(modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
|
||||
ParticleEffectUtils.playDodgeEffect(player);
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXpGain(eventHandler.damage * Acrobatics.dodgeXpModifier);
|
||||
PlayerProfile playerProfile = getProfile();
|
||||
|
||||
if (playerProfile.useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
||||
}
|
||||
|
||||
// Why do we check respawn cooldown here?
|
||||
if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
|
||||
applyXpGain(damage * Acrobatics.dodgeXpModifier);
|
||||
}
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the damage reduction and XP gain from the Roll ability
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public int rollCheck(int damage) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (player.isSneaking() && Permissions.gracefulRoll(player)) {
|
||||
return gracefulRollCheck(damage);
|
||||
}
|
||||
|
||||
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
|
||||
|
||||
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
||||
applyXpGain(damage * Acrobatics.rollXpModifier);
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(damage)) {
|
||||
applyXpGain(damage * Acrobatics.fallXpModifier);
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the damage reduction and XP gain from the Graceful Roll ability
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
private int gracefulRollCheck(int damage) {
|
||||
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
|
||||
|
||||
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) {
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
||||
applyXpGain(damage * Acrobatics.rollXpModifier);
|
||||
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(damage)) {
|
||||
applyXpGain(damage * Acrobatics.fallXpModifier);
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
|
||||
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
|
||||
}
|
||||
|
||||
private boolean isFatal(int damage) {
|
||||
return getPlayer().getHealth() - damage < 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class DodgeEventHandler extends AcrobaticsEventHandler {
|
||||
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
|
||||
super(manager, event);
|
||||
|
||||
calculateSkillModifier();
|
||||
calculateModifiedDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateModifiedDamage() {
|
||||
int modifiedDamage = damage / 2;
|
||||
|
||||
if (modifiedDamage <= 0) {
|
||||
modifiedDamage = 1;
|
||||
}
|
||||
|
||||
this.modifiedDamage = modifiedDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(modifiedDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendAbilityMessage() {
|
||||
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processXpGain(int xp) {
|
||||
McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
|
||||
|
||||
if (System.currentTimeMillis() >= mcMMOPlayer.getProfile().getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
|
||||
manager.getMcMMOPlayer().beginXpGain(SkillType.ACROBATICS, xp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
protected boolean isGraceful;
|
||||
private int damageThreshold;
|
||||
|
||||
protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
|
||||
super(manager, event);
|
||||
|
||||
isGracefulRoll();
|
||||
calculateSkillModifier();
|
||||
calculateDamageThreshold();
|
||||
calculateModifiedDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateSkillModifier() {
|
||||
int skillModifer = manager.getSkillLevel();
|
||||
|
||||
if (isGraceful) {
|
||||
skillModifer = skillModifer * 2;
|
||||
}
|
||||
|
||||
skillModifer = SkillTools.skillCheck(skillModifer, Acrobatics.rollMaxBonusLevel);
|
||||
this.skillModifier = skillModifer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateModifiedDamage() {
|
||||
int modifiedDamage = damage - damageThreshold;
|
||||
|
||||
if (modifiedDamage < 0) {
|
||||
modifiedDamage = 0;
|
||||
}
|
||||
|
||||
this.modifiedDamage = modifiedDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(modifiedDamage);
|
||||
|
||||
if (event.getDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void sendAbilityMessage() {
|
||||
Player player = manager.getMcMMOPlayer().getPlayer();
|
||||
|
||||
if (isGraceful) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void processXpGain(int xp) {
|
||||
manager.getMcMMOPlayer().beginXpGain(SkillType.ACROBATICS, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this is a graceful roll.
|
||||
*/
|
||||
private void isGracefulRoll() {
|
||||
Player player = manager.getMcMMOPlayer().getPlayer();
|
||||
|
||||
if (Permissions.gracefulRoll(player)) {
|
||||
this.isGraceful = player.isSneaking();
|
||||
}
|
||||
else {
|
||||
this.isGraceful = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the damage threshold for this event.
|
||||
*/
|
||||
private void calculateDamageThreshold() {
|
||||
int damageThreshold = 7;
|
||||
|
||||
if (isGraceful) {
|
||||
damageThreshold = damageThreshold * 2;
|
||||
}
|
||||
|
||||
this.damageThreshold = damageThreshold;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class Archery {
|
||||
@@ -26,9 +25,6 @@ public class Archery {
|
||||
public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax();
|
||||
public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
|
||||
|
||||
public static boolean pvpEnabled = Config.getInstance().getArcheryPVP();
|
||||
public static boolean pveEnabled = Config.getInstance().getArcheryPVE();
|
||||
|
||||
public static double distanceXpModifer = 0.025;
|
||||
|
||||
protected static void incrementTrackerValue(LivingEntity livingEntity) {
|
||||
@@ -62,7 +58,7 @@ public class Archery {
|
||||
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) {
|
||||
TrackedEntity trackedEntity = entityIterator.next();
|
||||
|
||||
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
|
||||
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
|
||||
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
|
||||
entityIterator.remove();
|
||||
return;
|
||||
|
||||
@@ -45,9 +45,9 @@ public class ArcheryCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = Permissions.archeryBonus(player);
|
||||
canSkillShot = Permissions.bonusDamage(player, skill);
|
||||
canDaze = Permissions.daze(player);
|
||||
canRetrieve = Permissions.trackArrows(player);
|
||||
canRetrieve = Permissions.arrowRetrieval(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,23 +1,49 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ArcheryManager extends SkillManager {
|
||||
public ArcheryManager (McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
public boolean canDaze(LivingEntity target) {
|
||||
return target instanceof Player && Permissions.daze(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canSkillShot() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return SkillTools.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
|
||||
}
|
||||
|
||||
public boolean canTrackArrows() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate bonus XP awarded for Archery when hitting a far-away target.
|
||||
*
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
*/
|
||||
public void distanceXpBonus(LivingEntity target) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = getPlayer();
|
||||
Location shooterLocation = player.getLocation();
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
@@ -25,61 +51,65 @@ public class ArcheryManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
double squaredDistance = shooterLocation.distanceSquared(targetLocation);
|
||||
|
||||
// Cap distance at 100^2 to prevent teleport exploit.
|
||||
// TODO: Better way to handle this would be great...
|
||||
if (squaredDistance > 10000) {
|
||||
squaredDistance = 10000;
|
||||
}
|
||||
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
|
||||
|
||||
int bonusXp = (int) (squaredDistance * Archery.distanceXpModifer);
|
||||
mcMMOPlayer.beginXpGain(SkillType.ARCHERY, bonusXp);
|
||||
applyXpGain((int) (squaredDistance * Archery.distanceXpModifer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Track arrows fired for later retrieval.
|
||||
*
|
||||
* @param livingEntity Entity damaged by the arrow
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
*/
|
||||
public void trackArrows(LivingEntity livingEntity) {
|
||||
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
||||
|
||||
double chance = (Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * eventHandler.skillModifier;
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.addToTracker();
|
||||
public void trackArrows(LivingEntity target) {
|
||||
if (SkillTools.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
|
||||
Archery.incrementTrackerValue(target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Daze.
|
||||
* Handle the effects of the Daze ability
|
||||
*
|
||||
* @param defender Defending player
|
||||
* @param event The event to modify
|
||||
* @param defender The player being affected by the ability
|
||||
* @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
|
||||
*/
|
||||
public void dazeCheck(Player defender, EntityDamageEvent event) {
|
||||
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
||||
public int dazeCheck(Player defender, int damage) {
|
||||
Player attacker = getPlayer();
|
||||
|
||||
double chance = (Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * eventHandler.skillModifier;
|
||||
if (SkillTools.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
||||
Location dazedLocation = defender.getLocation();
|
||||
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.handleDazeEffect();
|
||||
eventHandler.sendAbilityMessages();
|
||||
defender.teleport(dazedLocation);
|
||||
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
|
||||
|
||||
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||
}
|
||||
|
||||
if (getProfile().useChatNotifications()) {
|
||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
}
|
||||
|
||||
return damage + Archery.dazeModifier;
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle archery bonus damage.
|
||||
* Handle the effects of the Skill Shot ability
|
||||
*
|
||||
* @param event The event to modify.
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @return the modified event damage
|
||||
*/
|
||||
public void skillShot(EntityDamageEvent event) {
|
||||
if (skillLevel >= Archery.skillShotIncreaseLevel && Permissions.archeryBonus(mcMMOPlayer.getPlayer())) {
|
||||
SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event);
|
||||
public int skillShotCheck(int damage) {
|
||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||
int archeryBonus = (int) (damage * damageBonusPercent);
|
||||
|
||||
eventHandler.calculateDamageBonus();
|
||||
eventHandler.modifyEventDamage();
|
||||
}
|
||||
return damage + archeryBonus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
|
||||
public class ArrowTrackingEventHandler {
|
||||
private ArcheryManager manager;
|
||||
private LivingEntity entity;
|
||||
|
||||
protected int skillModifier;
|
||||
|
||||
protected ArrowTrackingEventHandler (ArcheryManager manager, LivingEntity entity) {
|
||||
this.manager = manager;
|
||||
this.entity = entity;
|
||||
|
||||
calculateSkillModifier();
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.retrieveMaxBonusLevel);
|
||||
}
|
||||
|
||||
protected void addToTracker() {
|
||||
Archery.incrementTrackerValue(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class DazeEventHandler {
|
||||
private ArcheryManager manager;
|
||||
private EntityDamageEvent event;
|
||||
private Player defender;
|
||||
|
||||
private final static int DAZE_CHANCE = 50;
|
||||
|
||||
protected int skillModifier;
|
||||
|
||||
protected DazeEventHandler (ArcheryManager manager, EntityDamageEvent event, Player defender) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
this.defender = defender;
|
||||
|
||||
calculateSkillModifier();
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.dazeMaxBonusLevel);
|
||||
}
|
||||
|
||||
protected void handleDazeEffect() {
|
||||
Location location = defender.getLocation();
|
||||
|
||||
if (Misc.getRandom().nextInt(100) > DAZE_CHANCE) {
|
||||
location.setPitch(90);
|
||||
}
|
||||
else {
|
||||
location.setPitch(-90);
|
||||
}
|
||||
|
||||
defender.teleport(location);
|
||||
event.setDamage(event.getDamage() + Archery.dazeModifier);
|
||||
}
|
||||
|
||||
protected void sendAbilityMessages() {
|
||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class SkillShotEventHandler {
|
||||
private ArcheryManager manager;
|
||||
private EntityDamageEvent event;
|
||||
|
||||
protected double damageBonusPercent;
|
||||
|
||||
protected SkillShotEventHandler(ArcheryManager manager, EntityDamageEvent event) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
protected void calculateDamageBonus() {
|
||||
this.damageBonusPercent = ((manager.getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage);
|
||||
|
||||
if (damageBonusPercent > Archery.skillShotMaxBonusPercentage) {
|
||||
damageBonusPercent = Archery.skillShotMaxBonusPercentage;
|
||||
}
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
int damage = event.getDamage();
|
||||
int archeryBonus = (int) (damage * damageBonusPercent);
|
||||
|
||||
event.setDamage(damage + archeryBonus);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
@@ -8,34 +9,26 @@ import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class TrackedEntity implements Runnable {
|
||||
private LivingEntity livingEntity;
|
||||
private UUID id;
|
||||
private int arrowCount;
|
||||
private int previousTicksLived;
|
||||
private int taskId;
|
||||
private BukkitScheduler scheduler;
|
||||
|
||||
protected TrackedEntity(LivingEntity livingEntity) {
|
||||
this.livingEntity = livingEntity;
|
||||
this.scheduler = Bukkit.getScheduler();
|
||||
this.id = livingEntity.getUniqueId();
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||
}
|
||||
|
||||
//LivingEntity.isDead() isn't a reliable way to know if an entity is still active
|
||||
//This method must not be called more than once per server tick
|
||||
private boolean isActive() {
|
||||
int currentTicksLived = livingEntity.getTicksLived();
|
||||
|
||||
if (currentTicksLived == previousTicksLived) {
|
||||
return false;
|
||||
}
|
||||
|
||||
previousTicksLived = currentTicksLived;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected LivingEntity getLivingEntity() {
|
||||
return livingEntity;
|
||||
}
|
||||
|
||||
protected UUID getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
protected int getArrowCount() {
|
||||
return arrowCount;
|
||||
}
|
||||
@@ -46,7 +39,7 @@ public class TrackedEntity implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isActive()) {
|
||||
if (!livingEntity.isValid()) {
|
||||
Archery.removeFromTracker(this);
|
||||
scheduler.cancelTask(taskId);
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class AxeBonusDamageEventHandler {
|
||||
private int skillLevel;
|
||||
private EntityDamageByEntityEvent event;
|
||||
private int damageBonus;
|
||||
|
||||
public AxeBonusDamageEventHandler(AxeManager manager, EntityDamageByEntityEvent event) {
|
||||
this.skillLevel = manager.getSkillLevel();
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
protected void calculateDamageBonus() {
|
||||
int increaseLevel = Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus;
|
||||
|
||||
/* Add 1 DMG for every 50 skill levels (default value) */
|
||||
damageBonus = skillLevel / increaseLevel;
|
||||
|
||||
if (damageBonus > Axes.bonusDamageMaxBonus) {
|
||||
damageBonus = Axes.bonusDamageMaxBonus;
|
||||
}
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
int damage = event.getDamage();
|
||||
|
||||
event.setDamage(damage + damageBonus);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,148 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AxeManager extends SkillManager {
|
||||
public AxeManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.AXES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply bonus to damage done by axes.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void bonusDamage(EntityDamageByEntityEvent event) {
|
||||
AxeBonusDamageEventHandler eventHandler = new AxeBonusDamageEventHandler(this, event);
|
||||
public boolean canUseAxeMastery() {
|
||||
return Permissions.bonusDamage(getPlayer(), skill);
|
||||
}
|
||||
|
||||
eventHandler.calculateDamageBonus();
|
||||
eventHandler.modifyEventDamage();
|
||||
public boolean canCriticalHit(LivingEntity target) {
|
||||
return target.isValid() && Permissions.criticalStrikes(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canImpact(LivingEntity target) {
|
||||
return target.isValid() && Permissions.armorImpact(getPlayer()) && Axes.hasArmor(target);
|
||||
}
|
||||
|
||||
public boolean canGreaterImpact(LivingEntity target) {
|
||||
return target.isValid() && Permissions.greaterImpact(getPlayer()) && !Axes.hasArmor(target);
|
||||
}
|
||||
|
||||
public boolean canUseSkullSplitter(LivingEntity target) {
|
||||
return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for critical chances on axe damage.
|
||||
* Handle the effects of the Axe Mastery ability
|
||||
*
|
||||
* @param event The event to modify
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @return the modified event damage
|
||||
*/
|
||||
public void criticalHitCheck(EntityDamageByEntityEvent event, LivingEntity target) {
|
||||
CriticalHitEventHandler eventHandler = new CriticalHitEventHandler(this, event, target);
|
||||
public int axeMasteryCheck(int damage) {
|
||||
int axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus);
|
||||
|
||||
double chance = (Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * eventHandler.skillModifier;
|
||||
return damage + axeBonus;
|
||||
}
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessages();
|
||||
/**
|
||||
* Handle the effects of the Critical Hit ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @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
|
||||
*/
|
||||
public int criticalHitCheck(LivingEntity target, int damage) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (SkillTools.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
|
||||
return (int) (damage * Axes.criticalHitPVPModifier);
|
||||
}
|
||||
|
||||
return (int) (damage * Axes.criticalHitPVEModifier);
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Impact ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by Impact
|
||||
*/
|
||||
public void impactCheck(LivingEntity target) {
|
||||
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
||||
|
||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||
if (ItemChecks.isArmor(armor) && SkillTools.activationSuccessful(getPlayer(), skill, Axes.impactChance)) {
|
||||
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
||||
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
||||
double maxDurabilityDamage = (ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityDamageModifier;
|
||||
|
||||
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Impact ability.
|
||||
* Handle the effects of the Greater Impact ability
|
||||
*
|
||||
* @param event The event to modify
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @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
|
||||
*/
|
||||
public void impact(EntityDamageByEntityEvent event, LivingEntity target) {
|
||||
ImpactEventHandler eventHandler = new ImpactEventHandler(this, event, target);
|
||||
public int greaterImpactCheck(LivingEntity target, int damage) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!eventHandler.applyImpact()) {
|
||||
eventHandler.applyGreaterImpact();
|
||||
if (SkillTools.activationSuccessful(player, skill, Axes.greaterImpactChance)) {
|
||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
||||
|
||||
if (getProfile().useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
|
||||
}
|
||||
}
|
||||
|
||||
return damage + Axes.greaterImpactBonusDamage;
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Skull Splitter ability.
|
||||
* Handle the effects of the Skull Splitter ability
|
||||
*
|
||||
* @param target The entity hit by Skull Splitter
|
||||
* @param damage The base damage to deal
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void skullSplitter(LivingEntity target, int damage) {
|
||||
SkullSplitterEventHandler eventHandler = new SkullSplitterEventHandler(mcMMOPlayer.getPlayer(), damage, target);
|
||||
eventHandler.applyAbilityEffects();
|
||||
public void skullSplitterCheck(LivingEntity target, int damage) {
|
||||
CombatTools.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
|
||||
public class Axes {
|
||||
public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax();
|
||||
@@ -13,6 +16,7 @@ public class Axes {
|
||||
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier();
|
||||
|
||||
public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel();
|
||||
public static double impactChance = AdvancedConfig.getInstance().getImpactChance();
|
||||
public static double impactMaxDurabilityDamageModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D;
|
||||
|
||||
public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
|
||||
@@ -21,6 +25,13 @@ public class Axes {
|
||||
|
||||
public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
|
||||
|
||||
public static boolean pvpEnabled = Config.getInstance().getAxesPVP();
|
||||
public static boolean pveEnabled = Config.getInstance().getAxesPVE();
|
||||
protected static boolean hasArmor(LivingEntity target) {
|
||||
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
|
||||
if (ItemChecks.isArmor(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public class AxesCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkullSplitter = Permissions.skullSplitter(player);
|
||||
canCritical = Permissions.criticalHit(player);
|
||||
canBonusDamage = Permissions.axeBonus(player);
|
||||
canImpact = Permissions.impact(player);
|
||||
canCritical = Permissions.criticalStrikes(player);
|
||||
canBonusDamage = Permissions.bonusDamage(player, skill);
|
||||
canImpact = Permissions.armorImpact(player);
|
||||
canGreaterImpact = Permissions.greaterImpact(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
|
||||
public class CriticalHitEventHandler {
|
||||
private AxeManager manager;
|
||||
private EntityDamageByEntityEvent event;
|
||||
private int damage;
|
||||
|
||||
protected LivingEntity defender;
|
||||
protected int skillModifier;
|
||||
|
||||
public CriticalHitEventHandler(AxeManager manager, EntityDamageByEntityEvent event, LivingEntity defender) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
this.defender = defender;
|
||||
this.damage = event.getDamage();
|
||||
|
||||
calculateSkillModifier();
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
if (defender instanceof Player) {
|
||||
event.setDamage((int) (damage * Axes.criticalHitPVPModifier));
|
||||
}
|
||||
else {
|
||||
event.setDamage((int) (damage * Axes.criticalHitPVEModifier));
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendAbilityMessages() {
|
||||
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||
|
||||
if (defender instanceof Player) {
|
||||
((Player) defender).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateSkillModifier() {
|
||||
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Axes.criticalHitMaxBonusLevel);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class ImpactEventHandler {
|
||||
private AxeManager manager;
|
||||
private Player player;
|
||||
private EntityDamageByEntityEvent event;
|
||||
private short durabilityDamage = 1;
|
||||
private EntityEquipment entityEquipment;
|
||||
protected LivingEntity defender;
|
||||
boolean impactApplied;
|
||||
|
||||
public ImpactEventHandler(AxeManager manager, EntityDamageByEntityEvent event, LivingEntity defender) {
|
||||
this.manager = manager;
|
||||
this.player = manager.getMcMMOPlayer().getPlayer();
|
||||
this.event = event;
|
||||
this.defender = defender;
|
||||
this.entityEquipment = defender.getEquipment();
|
||||
}
|
||||
|
||||
protected boolean applyImpact() {
|
||||
// Every 50 Skill Levels you gain 1 durability damage (default values)
|
||||
durabilityDamage += (short) (manager.getSkillLevel() / Axes.impactIncreaseLevel);
|
||||
// getArmorContents.length can't be used because it's always equal to 4 (no armor = air block)
|
||||
boolean hasArmor = false;
|
||||
|
||||
for (ItemStack itemStack : entityEquipment.getArmorContents()) {
|
||||
if (ItemChecks.isArmor(itemStack)) {
|
||||
hasArmor = true;
|
||||
|
||||
if (Misc.getRandom().nextInt(100) < 25) {
|
||||
damageArmor(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasArmor;
|
||||
}
|
||||
|
||||
private void damageArmor(ItemStack armor) {
|
||||
// Modifier simulate the durability enchantment behavior
|
||||
float modifier = 1;
|
||||
|
||||
if (armor.containsEnchantment(Enchantment.DURABILITY)) {
|
||||
modifier /= armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1;
|
||||
}
|
||||
|
||||
float modifiedDurabilityDamage = durabilityDamage * modifier;
|
||||
short maxDurabilityDamage = ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability();
|
||||
maxDurabilityDamage *= Axes.impactMaxDurabilityDamageModifier;
|
||||
|
||||
if (modifiedDurabilityDamage > maxDurabilityDamage) {
|
||||
modifiedDurabilityDamage = maxDurabilityDamage;
|
||||
}
|
||||
|
||||
armor.setDurability((short) (modifiedDurabilityDamage + armor.getDurability()));
|
||||
}
|
||||
|
||||
protected void applyGreaterImpact() {
|
||||
if (!Permissions.greaterImpact(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(manager.getActivationChance()) <= Axes.greaterImpactChance) {
|
||||
handleGreaterImpactEffect();
|
||||
sendAbilityMessge();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleGreaterImpactEffect() {
|
||||
event.setDamage(event.getDamage() + Axes.greaterImpactBonusDamage);
|
||||
defender.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
||||
}
|
||||
|
||||
private void sendAbilityMessge() {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
||||
|
||||
if (defender instanceof Player) {
|
||||
((Player) defender).sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class SkullSplitterEventHandler {
|
||||
private Player player;
|
||||
private LivingEntity target;
|
||||
private int damage;
|
||||
|
||||
protected SkullSplitterEventHandler(Player player, int damage, LivingEntity target) {
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
protected void applyAbilityEffects() {
|
||||
CombatTools.applyAbilityAoE(player, target, damage / Axes.skullSplitterModifier, SkillType.AXES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.gmail.nossr50.skills.child;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ChildConfig extends AutoUpdateConfigLoader {
|
||||
public ChildConfig() {
|
||||
super("child.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill()) {
|
||||
plugin.debug("Finding parents of " + skill.name());
|
||||
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
|
||||
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
|
||||
boolean useDefaults = false; // If we had an error we back out and use defaults
|
||||
for (String name : parentNames) {
|
||||
try {
|
||||
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
|
||||
FamilyTree.enforceNotChildSkill(parentSkill);
|
||||
parentSkills.add(parentSkill);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||
useDefaults = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (useDefaults) {
|
||||
parentSkills.clear();
|
||||
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||
/* We do less checks in here because it's from inside our jar.
|
||||
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
||||
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
||||
*/
|
||||
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
// Register them
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||
FamilyTree.registerParent(skill, parentSkill);
|
||||
}
|
||||
}
|
||||
}
|
||||
FamilyTree.closeRegistration();
|
||||
}
|
||||
}
|
||||
49
src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java
Normal file
49
src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.gmail.nossr50.skills.child;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class FamilyTree {
|
||||
private static HashMap<SkillType, Set<SkillType>> tree = new HashMap<SkillType, Set<SkillType>>();
|
||||
|
||||
public static Set<SkillType> getParents(SkillType childSkill) {
|
||||
enforceChildSkill(childSkill);
|
||||
|
||||
// We do not check if we have the child skill in question, as not having it would mean we did something wrong, and an NPE is desired.
|
||||
return tree.get(childSkill);
|
||||
}
|
||||
|
||||
protected static void registerParent(SkillType childSkill, SkillType parentSkill) {
|
||||
enforceChildSkill(childSkill);
|
||||
enforceNotChildSkill(parentSkill);
|
||||
|
||||
if (!tree.containsKey(childSkill)) {
|
||||
tree.put(childSkill, EnumSet.noneOf(SkillType.class));
|
||||
}
|
||||
|
||||
tree.get(childSkill).add(parentSkill);
|
||||
}
|
||||
|
||||
protected static void closeRegistration() {
|
||||
for (SkillType childSkill : tree.keySet()) {
|
||||
Set<SkillType> immutableSet = Collections.unmodifiableSet(tree.get(childSkill));
|
||||
tree.put(childSkill, immutableSet);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void enforceChildSkill(SkillType skill) {
|
||||
if (!skill.isChildSkill()) {
|
||||
throw new IllegalArgumentException(skill.name() + " is not a child skill!");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void enforceNotChildSkill(SkillType skill) {
|
||||
if (skill.isChildSkill()) {
|
||||
throw new IllegalArgumentException(skill.name() + " is a child skill!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,130 +3,57 @@ package com.gmail.nossr50.skills.excavation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class Excavation {
|
||||
public static boolean requiresTool = Config.getInstance().getExcavationRequiresTool();
|
||||
|
||||
/**
|
||||
* Check to see if treasures were found.
|
||||
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @param mcMMOPlayer The player who broke the block
|
||||
* @param blockState The {@link BlockState} of the block to check.
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
public static void excavationProcCheck(Block block, McMMOPlayer mcMMOPlayer) {
|
||||
Material material = block.getType();
|
||||
int xp;
|
||||
|
||||
switch (material) {
|
||||
case CLAY:
|
||||
xp = Config.getInstance().getExcavationClayXP();
|
||||
break;
|
||||
|
||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case DIRT:
|
||||
xp = Config.getInstance().getExcavationDirtXP();
|
||||
break;
|
||||
return TreasuresConfig.getInstance().excavationFromDirt;
|
||||
|
||||
case GRASS:
|
||||
xp = Config.getInstance().getExcavationGrassXP();
|
||||
break;
|
||||
|
||||
case GRAVEL:
|
||||
xp = Config.getInstance().getExcavationGravelXP();
|
||||
break;
|
||||
|
||||
case MYCEL:
|
||||
xp = Config.getInstance().getExcavationMycelXP();
|
||||
break;
|
||||
return TreasuresConfig.getInstance().excavationFromGrass;
|
||||
|
||||
case SAND:
|
||||
xp = Config.getInstance().getExcavationSandXP();
|
||||
break;
|
||||
return TreasuresConfig.getInstance().excavationFromSand;
|
||||
|
||||
case GRAVEL:
|
||||
return TreasuresConfig.getInstance().excavationFromGravel;
|
||||
|
||||
case CLAY:
|
||||
return TreasuresConfig.getInstance().excavationFromClay;
|
||||
|
||||
case MYCEL:
|
||||
return TreasuresConfig.getInstance().excavationFromMycel;
|
||||
|
||||
case SOUL_SAND:
|
||||
xp = Config.getInstance().getExcavationSoulSandXP();
|
||||
break;
|
||||
return TreasuresConfig.getInstance().excavationFromSoulSand;
|
||||
|
||||
default:
|
||||
xp = ModChecks.getCustomBlock(block).getXpGain();;
|
||||
break;
|
||||
return new ArrayList<ExcavationTreasure>();
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
if (Permissions.excavationTreasures(player)) {
|
||||
switch (material) {
|
||||
case DIRT:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromDirt;
|
||||
break;
|
||||
|
||||
case GRASS:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromGrass;
|
||||
break;
|
||||
|
||||
case SAND:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromSand;
|
||||
break;
|
||||
|
||||
case GRAVEL:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromGravel;
|
||||
break;
|
||||
|
||||
case CLAY:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromClay;
|
||||
break;
|
||||
|
||||
case MYCEL:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromMycel;
|
||||
break;
|
||||
|
||||
case SOUL_SAND:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromSoulSand;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = block.getLocation();
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) {
|
||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyExcavation(player));
|
||||
|
||||
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
Misc.dropItem(location, treasure.getDrop());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mcMMOPlayer.beginXpGain(SkillType.EXCAVATION, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle triple drops from Giga Drill Breaker.
|
||||
*
|
||||
* @param mcMMOPlayer The player using the ability
|
||||
* @param block The block to check
|
||||
*/
|
||||
public static void gigaDrillBreaker(McMMOPlayer mcMMOPlayer, Block block) {
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
}
|
||||
}
|
||||
protected static int getBlockXP(BlockState blockState) {
|
||||
int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
|
||||
|
||||
if (xp == 0 && ModChecks.isCustomExcavationBlock(blockState)) {
|
||||
xp = ModChecks.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ExcavationCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canGigaDrill = Permissions.gigaDrillBreaker(player);
|
||||
canTreasureHunt = Permissions.excavationTreasures(player);
|
||||
canTreasureHunt = Permissions.excavationTreasureHunter(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gmail.nossr50.skills.excavation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class ExcavationManager extends SkillManager {
|
||||
public ExcavationManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.EXCAVATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process treasure drops & XP gain for Excavation.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public void excavationBlockCheck(BlockState blockState) {
|
||||
int xp = Excavation.getBlockXP(blockState);
|
||||
|
||||
if (Permissions.excavationTreasureHunter(getPlayer())) {
|
||||
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
|
||||
|
||||
if (!treasures.isEmpty()) {
|
||||
int skillLevel = getSkillLevel();
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel() && SkillTools.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
|
||||
xp += treasure.getXp();
|
||||
Misc.dropItem(location, treasure.getDrop());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Giga Drill Breaker ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public void gigaDrillBreaker(BlockState blockState) {
|
||||
excavationBlockCheck(blockState);
|
||||
excavationBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +1,41 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public final class Fishing {
|
||||
static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance();
|
||||
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier5();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank5();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank5();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier5();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank5();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5();}},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier4();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank4();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank4();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier4();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank4();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4();}},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier3();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank3();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank3();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier3();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank3();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3();}},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier2();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank2();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank2();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier2();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank2();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2();}},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier1();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank1();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank1();}};
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier1();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank1();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1();}};
|
||||
|
||||
int numerical;
|
||||
|
||||
@@ -66,204 +53,149 @@ public final class Fishing {
|
||||
}
|
||||
|
||||
// TODO: Get rid of that
|
||||
public static int fishermansDietRankLevel1 = ADVANCED_CONFIG.getFishermanDietRankChange();
|
||||
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||
public static final double STORM_MODIFIER = 0.909;
|
||||
|
||||
private Fishing() {}
|
||||
|
||||
/**
|
||||
* Begins Fisherman's Diet ability
|
||||
* Finds the possible drops of an entity
|
||||
*
|
||||
* @param player Player using the ability
|
||||
* @param rankChange ???
|
||||
* @param event Event to process
|
||||
* @param target Targeted entity
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
*/
|
||||
public static void beginFishermansDiet(Player player, int rankChange, FoodLevelChangeEvent event) {
|
||||
// TODO: The permission should probably not be checked here
|
||||
// TODO: Also I don't like the idea of moving event around
|
||||
if (!Permissions.fishermansDiet(player)) {
|
||||
protected static void findPossibleDrops(LivingEntity target, Map<ItemStack, Integer> possibleDrops) {
|
||||
switch (target.getType()) {
|
||||
case BLAZE:
|
||||
possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100);
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
case SPIDER:
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50);
|
||||
possibleDrops.put(new ItemStack(Material.STRING), 50);
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
possibleDrops.put(new ItemStack(Material.FEATHER), 34);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33);
|
||||
possibleDrops.put(new ItemStack(Material.EGG), 33);
|
||||
break;
|
||||
|
||||
case COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 49);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49);
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 99);
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100);
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50);
|
||||
break;
|
||||
|
||||
case IRON_GOLEM:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12);
|
||||
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
|
||||
possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
possibleDrops.put(new ItemStack(Material.PORK), 100);
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50);
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100);
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2);
|
||||
possibleDrops.put(new ItemStack(Material.BONE), 49);
|
||||
possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49);
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100);
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1);
|
||||
possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9);
|
||||
possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.REDSTONE), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12);
|
||||
possibleDrops.put(new ItemStack(Material.STICK), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SUGAR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.POTION), 13);
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2);
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
SkillTools.handleFoodSkills(player, SkillType.FISHING, event, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins Shake Mob ability
|
||||
* Randomly chooses a drop among the list
|
||||
*
|
||||
* @param player Player using the ability
|
||||
* @param mob Targeted mob
|
||||
* @param skillLevel Fishing level of the player
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
* @return Chosen ItemStack
|
||||
*/
|
||||
public static void beginShakeMob(Player player, LivingEntity mob, int skillLevel) {
|
||||
ShakeMob.process(player, mob, skillLevel);
|
||||
protected static ItemStack chooseDrop(Map<ItemStack, Integer> possibleDrops) {
|
||||
int dropProbability = Misc.getRandom().nextInt(100);
|
||||
int cumulatedProbability = 0;
|
||||
|
||||
for (Entry<ItemStack, Integer> entry : possibleDrops.entrySet()) {
|
||||
cumulatedProbability += entry.getValue();
|
||||
|
||||
if (dropProbability < cumulatedProbability) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins Fishing
|
||||
*
|
||||
* @param mcMMOPlayer Player fishing
|
||||
* @param skillLevel Fishing level of the player
|
||||
* @param event Event to process
|
||||
*/
|
||||
public static void beginFishing(McMMOPlayer mcMMOPlayer, int skillLevel, PlayerFishEvent event) {
|
||||
int treasureXp = 0;
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
FishingTreasure treasure = checkForTreasure(player, skillLevel);
|
||||
|
||||
if (treasure != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
|
||||
treasureXp = treasure.getXp();
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (Permissions.fishingMagic(player) && beginMagicHunter(player, skillLevel, treasureDrop, player.getWorld().hasStorm())) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||
}
|
||||
|
||||
// Drop the original catch at the feet of the player and set the treasure as the real catch
|
||||
Item caught = (Item) event.getCaught();
|
||||
Misc.dropItem(player.getEyeLocation(), caught.getItemStack());
|
||||
caught.setItemStack(treasureDrop);
|
||||
}
|
||||
|
||||
mcMMOPlayer.beginXpGain(SkillType.FISHING, Config.getInstance().getFishingBaseXP() + treasureXp);
|
||||
event.setExpToDrop(event.getExpToDrop() * getVanillaXpMultiplier(skillLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for treasure
|
||||
*
|
||||
* @param player Player fishing
|
||||
* @param skillLevel Fishing level of the player
|
||||
* @return Chosen treasure
|
||||
*/
|
||||
private static FishingTreasure checkForTreasure(Player player, int skillLevel) {
|
||||
if (!Config.getInstance().getFishingDropsEnabled() || !Permissions.fishingTreasures(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
|
||||
int maxLevel = treasure.getMaxLevel();
|
||||
|
||||
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
|
||||
rewards.add(treasure);
|
||||
}
|
||||
}
|
||||
|
||||
if (rewards.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
|
||||
|
||||
if (Misc.getRandom().nextDouble() * activationChance > treasure.getDropChance()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
|
||||
}
|
||||
|
||||
return treasure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes for treasure
|
||||
*
|
||||
* @param player Player fishing
|
||||
* @param skillLevel Fishing level of the player
|
||||
* @param itemStack ItemStack to enchant
|
||||
* @param storm World's weather
|
||||
* @return True if the ItemStack has been enchanted
|
||||
*/
|
||||
private static boolean beginMagicHunter(Player player, int skillLevel, ItemStack itemStack, boolean storm) {
|
||||
if (!ItemChecks.isEnchantable(itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
|
||||
|
||||
if (storm) {
|
||||
activationChance = (int) (activationChance * 0.909);
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier(skillLevel) * ADVANCED_CONFIG.getFishingMagicMultiplier()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
|
||||
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
if (enchantment.canEnchantItem(itemStack)) {
|
||||
possibleEnchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
||||
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
||||
|
||||
boolean enchanted = false;
|
||||
int specificChance = 1;
|
||||
|
||||
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
||||
boolean conflicts = false;
|
||||
|
||||
for (Enchantment currentEnchantment : itemStack.getEnchantments().keySet()) {
|
||||
conflicts = currentEnchantment.conflictsWith(possibleEnchantment);
|
||||
|
||||
if (conflicts) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) {
|
||||
itemStack.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
|
||||
|
||||
specificChance++;
|
||||
enchanted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return enchanted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loot tier for a given skill level
|
||||
*
|
||||
* @param skillLevel Fishing skill level
|
||||
* @return Loot tier
|
||||
*/
|
||||
public static int getLootTier(int skillLevel) {
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vanilla xp multiplier for a given skill level
|
||||
*
|
||||
* @param skillLevel Fishing skill level
|
||||
* @return Shake Mob probability
|
||||
*/
|
||||
public static int getVanillaXpMultiplier(int skillLevel) {
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getVanillaXPBoostModifier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.fishing;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
lootTier = Fishing.getLootTier((int) skillValue);
|
||||
lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier();
|
||||
|
||||
//TREASURE HUNTER
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
@@ -41,7 +42,7 @@ public class FishingCommand extends SkillCommand {
|
||||
magicChanceLucky = treasureHunterStrings[1];
|
||||
|
||||
//SHAKE
|
||||
String[] shakeStrings = calculateAbilityDisplayValues(ShakeMob.getShakeProbability((int) skillValue));
|
||||
String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability());
|
||||
shakeChance = shakeStrings[0];
|
||||
shakeChanceLucky = shakeStrings[1];
|
||||
|
||||
@@ -51,9 +52,9 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = Permissions.fishingTreasures(player);
|
||||
canMagicHunt = Permissions.fishingMagic(player);
|
||||
canShake = Permissions.shakeMob(player);
|
||||
canTreasureHunt = Permissions.fishingTreasureHunter(player);
|
||||
canMagicHunt = Permissions.magicHunter(player);
|
||||
canShake = Permissions.shake(player);
|
||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class FishingManager extends SkillManager {
|
||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.FISHING);
|
||||
}
|
||||
|
||||
public boolean canShake(Entity target) {
|
||||
Player player = getPlayer();
|
||||
|
||||
return target instanceof LivingEntity && SkillTools.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Fisherman's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
|
||||
return SkillTools.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the results from a successful fishing trip
|
||||
*
|
||||
* @param fishingCatch The {@link Item} initially caught
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
|
||||
treasure = getFishingTreasure();
|
||||
}
|
||||
|
||||
if (treasure != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
|
||||
treasureXp = treasure.getXp();
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (Permissions.magicHunter(player) && ItemChecks.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||
}
|
||||
|
||||
// Drop the original catch at the feet of the player and set the treasure as the real catch
|
||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
}
|
||||
|
||||
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the vanilla XP boost for Fishing
|
||||
*
|
||||
* @param experience The amount of experience initially awarded by the event
|
||||
* @return the modified event damage
|
||||
*/
|
||||
public int handleVanillaXpBoost(int experience) {
|
||||
return experience * getVanillaXpMultiplier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Shake ability
|
||||
*
|
||||
* @param mob The {@link LivingEntity} affected by the ability
|
||||
*/
|
||||
public void shakeCheck(LivingEntity target) {
|
||||
if (SkillTools.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
|
||||
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
||||
|
||||
Fishing.findPossibleDrops(target, possibleDrops);
|
||||
|
||||
if (possibleDrops.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack drop = Fishing.chooseDrop(possibleDrops);
|
||||
|
||||
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
|
||||
if (drop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extra processing depending on the mob and drop type
|
||||
switch (target.getType()) {
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) target;
|
||||
|
||||
if (drop.getType() == Material.WOOL) {
|
||||
if (sheep.isSheared()) {
|
||||
return;
|
||||
}
|
||||
|
||||
drop.setDurability(sheep.getColor().getWoolData());
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) target;
|
||||
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER) {
|
||||
switch (drop.getType()) {
|
||||
case SKULL_ITEM:
|
||||
drop.setDurability((short) 1);
|
||||
break;
|
||||
|
||||
case ARROW:
|
||||
drop.setType(Material.COAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Misc.dropItem(target.getLocation(), drop);
|
||||
CombatTools.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Treasure Hunter ability for Fishing
|
||||
*
|
||||
* @return The {@link FishingTreasure} found, or null if no treasure was found.
|
||||
*/
|
||||
private FishingTreasure getFishingTreasure() {
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
|
||||
int maxLevel = treasure.getMaxLevel();
|
||||
|
||||
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
|
||||
rewards.add(treasure);
|
||||
}
|
||||
}
|
||||
|
||||
if (rewards.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (!SkillTools.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
|
||||
}
|
||||
|
||||
return treasure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Magic Hunter ability
|
||||
*
|
||||
* @param treasureDrop The {@link ItemStack} to enchant
|
||||
* @return true if the item has been enchanted
|
||||
*/
|
||||
private boolean handleMagicHunter(ItemStack treasureDrop) {
|
||||
Player player = getPlayer();
|
||||
int activationChance = this.activationChance;
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
activationChance *= Fishing.STORM_MODIFIER;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
|
||||
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
if (enchantment.canEnchantItem(treasureDrop)) {
|
||||
possibleEnchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
||||
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
||||
|
||||
boolean enchanted = false;
|
||||
int specificChance = 1;
|
||||
|
||||
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
||||
boolean conflicts = false;
|
||||
|
||||
for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) {
|
||||
conflicts = currentEnchantment.conflictsWith(possibleEnchantment);
|
||||
|
||||
if (conflicts) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) {
|
||||
treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
|
||||
|
||||
specificChance++;
|
||||
enchanted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return enchanted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loot tier
|
||||
*
|
||||
* @return the loot tier
|
||||
*/
|
||||
public int getLootTier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Shake Mob probability
|
||||
*
|
||||
* @return Shake Mob probability
|
||||
*/
|
||||
public int getShakeProbability() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getShakeChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vanilla XP multiplier
|
||||
*
|
||||
* @return the vanilla XP multiplier
|
||||
*/
|
||||
private int getVanillaXpMultiplier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getVanillaXPBoostModifier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public final class ShakeMob {
|
||||
private ShakeMob() {}
|
||||
|
||||
/**
|
||||
* Begins Tree Feller
|
||||
*
|
||||
* @param player Player using Shake Mob
|
||||
* @param mob Targeted entity
|
||||
* @param skillLevel Fishing level of the player
|
||||
*/
|
||||
public static void process(Player player, LivingEntity mob, int skillLevel) {
|
||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
|
||||
|
||||
if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
||||
|
||||
findPossibleDrops(mob, possibleDrops);
|
||||
|
||||
if (possibleDrops.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack drop = chooseDrop(possibleDrops);
|
||||
|
||||
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
|
||||
if (drop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extra processing depending on the mob and drop type
|
||||
switch (mob.getType()) {
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) mob;
|
||||
|
||||
if (drop.getType() == Material.WOOL) {
|
||||
if (sheep.isSheared()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Find a cleaner way to do this, maybe by using Sheep.getColor().getWoolData() (available since 1.4.7-R0.1)
|
||||
Wool wool = (Wool) drop.getData();
|
||||
|
||||
wool.setColor(sheep.getColor());
|
||||
drop.setDurability(wool.getData());
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) mob;
|
||||
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER) {
|
||||
switch (drop.getType()) {
|
||||
case SKULL_ITEM:
|
||||
drop.setDurability((short) 1);
|
||||
break;
|
||||
case ARROW:
|
||||
drop.setType(Material.COAL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Misc.dropItem(mob.getLocation(), drop);
|
||||
CombatTools.dealDamage(mob, 1); // We may want to base the damage on the entity max health
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the possible drops of an entity
|
||||
*
|
||||
* @param mob Targeted entity
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
*/
|
||||
private static void findPossibleDrops(LivingEntity mob, Map<ItemStack, Integer> possibleDrops) {
|
||||
switch (mob.getType()) {
|
||||
case BLAZE:
|
||||
possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100);
|
||||
break;
|
||||
case CAVE_SPIDER:
|
||||
case SPIDER:
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50);
|
||||
possibleDrops.put(new ItemStack(Material.STRING), 50);
|
||||
break;
|
||||
case CHICKEN:
|
||||
possibleDrops.put(new ItemStack(Material.FEATHER), 34);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33);
|
||||
possibleDrops.put(new ItemStack(Material.EGG), 33);
|
||||
break;
|
||||
case COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 49);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49);
|
||||
break;
|
||||
case CREEPER:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 99);
|
||||
break;
|
||||
case ENDERMAN:
|
||||
possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100);
|
||||
break;
|
||||
case GHAST:
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50);
|
||||
break;
|
||||
case IRON_GOLEM:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12);
|
||||
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
|
||||
break;
|
||||
case MAGMA_CUBE:
|
||||
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
|
||||
break;
|
||||
case MUSHROOM_COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
|
||||
possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
|
||||
break;
|
||||
case PIG:
|
||||
possibleDrops.put(new ItemStack(Material.PORK), 100);
|
||||
break;
|
||||
case PIG_ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50);
|
||||
break;
|
||||
case SHEEP:
|
||||
possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100);
|
||||
break;
|
||||
case SKELETON:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2);
|
||||
possibleDrops.put(new ItemStack(Material.BONE), 49);
|
||||
possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49);
|
||||
break;
|
||||
case SLIME:
|
||||
possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100);
|
||||
break;
|
||||
case SNOWMAN:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
|
||||
break;
|
||||
case SQUID:
|
||||
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
|
||||
break;
|
||||
case WITCH:
|
||||
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1);
|
||||
possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9);
|
||||
possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.REDSTONE), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12);
|
||||
possibleDrops.put(new ItemStack(Material.STICK), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SUGAR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.POTION), 13);
|
||||
break;
|
||||
case ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2);
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly chooses a drop among the list
|
||||
*
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
* @return Chosen ItemStack
|
||||
*/
|
||||
private static ItemStack chooseDrop(Map<ItemStack, Integer> possibleDrops) {
|
||||
int dropProbability = Misc.getRandom().nextInt(100);
|
||||
int cumulatedProbability = 0;
|
||||
|
||||
for (Entry<ItemStack, Integer> entry : possibleDrops.entrySet()) {
|
||||
cumulatedProbability += entry.getValue();
|
||||
|
||||
if (dropProbability < cumulatedProbability) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Shake Mob probability for a given skill level
|
||||
*
|
||||
* @param skillLevel Fishing skill level
|
||||
* @return Shake Mob probability
|
||||
*/
|
||||
public static int getShakeProbability(int skillLevel) {
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getShakeChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
|
||||
/**
|
||||
* Convert plants affected by the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public class GreenTerraTimer implements Runnable {
|
||||
private BlockState blockState;
|
||||
|
||||
public GreenTerraTimer(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user