mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
205 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3eb265c5f7 | ||
|
|
049338e83b | ||
|
|
a336e9f460 | ||
|
|
0294cf8c4a | ||
|
|
c5183309ae | ||
|
|
0a15cb1e13 | ||
|
|
9546cc42b2 | ||
|
|
ac01262655 | ||
|
|
6ea962c1fa | ||
|
|
9e35283273 | ||
|
|
9c8e1d9c9f | ||
|
|
7d324b3fd4 | ||
|
|
badc5738ff | ||
|
|
8feaf4410f | ||
|
|
4e224d761e | ||
|
|
e775abdc5a | ||
|
|
60754c9380 | ||
|
|
c890ff5605 | ||
|
|
9f9c0059a5 | ||
|
|
4eabd417b9 | ||
|
|
c218de9567 | ||
|
|
4b5ca5ecf4 | ||
|
|
edbf46a751 | ||
|
|
c9c90bb86a | ||
|
|
437a608d2b | ||
|
|
b638eef1c6 | ||
|
|
b7cec8a0c4 | ||
|
|
28578bd6b0 | ||
|
|
160004fa7e | ||
|
|
f4332761f9 | ||
|
|
a4d1a18850 | ||
|
|
c3e1e55e9c | ||
|
|
e20bcd19b9 | ||
|
|
1fbf213ada | ||
|
|
c2d2359a8c | ||
|
|
586a2a065e | ||
|
|
adf43b7e35 | ||
|
|
45a4cddeef | ||
|
|
69f62551c7 | ||
|
|
f1bdf502be | ||
|
|
e89b3795f8 | ||
|
|
20b169e8eb | ||
|
|
1480ee2779 | ||
|
|
41c9741b72 | ||
|
|
f9e5096ceb | ||
|
|
a9b2a4940e | ||
|
|
f66c6ab8fc | ||
|
|
73902d5f92 | ||
|
|
0bb5f9f297 | ||
|
|
16ad8502d2 | ||
|
|
ad68e6057e | ||
|
|
54b4faeeff | ||
|
|
a7f69545f2 | ||
|
|
93ea558ec3 | ||
|
|
d0cdc208e3 | ||
|
|
0d7c483bd5 | ||
|
|
3f211c6277 | ||
|
|
79e93edfef | ||
|
|
44e8efda36 | ||
|
|
9726ac6f12 | ||
|
|
898d8c6449 | ||
|
|
01006ed76d | ||
|
|
2936823d03 | ||
|
|
7d05d53f9e | ||
|
|
f3074461ed | ||
|
|
146f832919 | ||
|
|
a622707608 | ||
|
|
6da43b15c8 | ||
|
|
d0bb7b075e | ||
|
|
c1ecd74644 | ||
|
|
a1aada0777 | ||
|
|
c55a8eeccd | ||
|
|
73cc8adcab | ||
|
|
7bb05f7f26 | ||
|
|
7f0803c3f6 | ||
|
|
1185ea4f96 | ||
|
|
43db51a664 | ||
|
|
d35cdc91f8 | ||
|
|
8d643277c0 | ||
|
|
5be1858b45 | ||
|
|
13d6e16630 | ||
|
|
dcb1cbbdb7 | ||
|
|
f7f077be3e | ||
|
|
3d79416520 | ||
|
|
c559e70270 | ||
|
|
efcc15d89d | ||
|
|
d17fe6bb7a | ||
|
|
01235ff398 | ||
|
|
3d6e490505 | ||
|
|
bd3491d210 | ||
|
|
d139146e0b | ||
|
|
b36da06fad | ||
|
|
d20c5e1773 | ||
|
|
0afc0d59a4 | ||
|
|
26481c547a | ||
|
|
45fe8c182b | ||
|
|
c25ddd0dbc | ||
|
|
efc9a10fdf | ||
|
|
a8eb9dfedf | ||
|
|
87cf5cb932 | ||
|
|
e1ca2c0b98 | ||
|
|
a9295751c8 | ||
|
|
2a46a5c00a | ||
|
|
d3b7af3c5f | ||
|
|
db59f24873 | ||
|
|
5645bf7982 | ||
|
|
6cbf87b52c | ||
|
|
bc642deebd | ||
|
|
e84a9643f8 | ||
|
|
e9af0ebdc5 | ||
|
|
29ee8a035b | ||
|
|
81ac4e8d01 | ||
|
|
ecc68d373f | ||
|
|
3032572f18 | ||
|
|
bcee6abb65 | ||
|
|
7e0b8ddf50 | ||
|
|
91dcb508b3 | ||
|
|
d549e2722d | ||
|
|
3bb29c8308 | ||
|
|
0121228d88 | ||
|
|
cbafa7110a | ||
|
|
06791beabd | ||
|
|
68b9857409 | ||
|
|
112a0df8c2 | ||
|
|
73717278ff | ||
|
|
5fa79926db | ||
|
|
06f97ac2f1 | ||
|
|
c2b4961b8d | ||
|
|
9b3838b912 | ||
|
|
946ea19371 | ||
|
|
419e011d0b | ||
|
|
b0157c9bd2 | ||
|
|
37d146e8fa | ||
|
|
063d982750 | ||
|
|
fbfeaa0f95 | ||
|
|
9b11b02658 | ||
|
|
3e435c419a | ||
|
|
1b37ba8daa | ||
|
|
b529219a0e | ||
|
|
d9b3eff18f | ||
|
|
cb5ada6ec9 | ||
|
|
baf7ffd441 | ||
|
|
2b4ca80a95 | ||
|
|
b5963936fd | ||
|
|
354ed9ede0 | ||
|
|
7ad9b8ff3e | ||
|
|
6dc522a044 | ||
|
|
3e91bc8c1e | ||
|
|
3218c544dc | ||
|
|
1ae11da036 | ||
|
|
84e36d758e | ||
|
|
06ede80435 | ||
|
|
dbc57060ee | ||
|
|
798bd46d0a | ||
|
|
c95f388d8d | ||
|
|
a9024ebc6b | ||
|
|
33bc2d8a6b | ||
|
|
cc60f2f308 | ||
|
|
edaa51593b | ||
|
|
e2265dd6f7 | ||
|
|
e1cf89c3bf | ||
|
|
8cd1541893 | ||
|
|
9d510815b4 | ||
|
|
44d22d93da | ||
|
|
f7405a82e6 | ||
|
|
04f3e44c3a | ||
|
|
6cc207a10c | ||
|
|
6b5e615a23 | ||
|
|
46268a7cf3 | ||
|
|
3682fbf531 | ||
|
|
0928b54d90 | ||
|
|
5a10339adc | ||
|
|
7c412cbec8 | ||
|
|
d235ca8ed8 | ||
|
|
97511be64a | ||
|
|
3bd5aaa251 | ||
|
|
ae2d9d8387 | ||
|
|
33c9694d26 | ||
|
|
dbede7f81a | ||
|
|
c8ad2bb454 | ||
|
|
18c52a5e23 | ||
|
|
ca1954ff80 | ||
|
|
5a3574734c | ||
|
|
5c6d10b2db | ||
|
|
7e96ced4c4 | ||
|
|
8da259cabc | ||
|
|
f978d739bb | ||
|
|
7b2d50e93e | ||
|
|
8bec50663f | ||
|
|
f4f5063efe | ||
|
|
11782ac34d | ||
|
|
bfec3fff36 | ||
|
|
d8c0a56577 | ||
|
|
ff1326a44f | ||
|
|
1fa4fccbcc | ||
|
|
323b41fd58 | ||
|
|
3d2b881b0e | ||
|
|
def41af469 | ||
|
|
4750aba763 | ||
|
|
5a9249dee1 | ||
|
|
064fc0a8e2 | ||
|
|
67de70432c | ||
|
|
facd71bd71 | ||
|
|
96e6270520 | ||
|
|
51c45e86ce |
@@ -7,6 +7,74 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.3.08
|
||||
+ Added more notifications about Vampirism and Hardcore mode on player death
|
||||
+ Added information about Hardcore mode when joining a server running Hardcore mode
|
||||
+ Added new hidden.yml inside the jar for very sensitive config options for advanced users
|
||||
+ Added option to disable Chunklets for servers which do not have doubledrops and do not care about xp farming
|
||||
+ Added new "Max_Seconds" setting in config.yml to limit the max time of abilities
|
||||
+ Added new repair configs to allow customization of the repair skill
|
||||
+ Added message to inform users about hardcore mode on login
|
||||
= Fixed exploit where you could gain tons of Acrobatics XP from spamming Ender Pearls
|
||||
= Fixed normal pistons marking a block as user-placed on retract if it wasn't a sticky piston (thanks turt2live!)
|
||||
= Fixed handling of the Unbreaking enchantment so that tools are actually damaged as they should now
|
||||
= Fixed hurting pet cats with serrated strikes
|
||||
! Changed Hardcore Vampirism to require the victim to have at least half the skill level of the killer in order for vampirism to proc (this is to avoid exploitation)
|
||||
! Changed Hardcore Vampirism to steal a minimum of 1 skill level from a player no matter the percentage
|
||||
! Changed Hardcore & Vampirism to not be executed if percentages were set to zero or below
|
||||
! Changed Vampirism to actually remove stats from the victim
|
||||
! Changed Vampirism to inform the victim of their stat loss
|
||||
! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed.
|
||||
! Changed Metrics to also report if the server uses plugin profiling
|
||||
- Removed level and item settings from Repair skill in config.yml
|
||||
|
||||
Version 1.3.07
|
||||
+ Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file.
|
||||
+ Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
|
||||
+ Added ability to repair custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
|
||||
+ Added ability to repair custom armor. Enable custom armor in the config file, then enter the data in the armor.yml file.
|
||||
+ Added functionality which makes a new folder in all world files "mcmmo_data" to store player placed block information in
|
||||
+ Added new configurable Hardcore mode functionality to mcMMO
|
||||
+ Added new configurable Vampirism PVP stat leech for Hardcore mode
|
||||
+ Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode'
|
||||
+ Added configurable level curve multiplier which allows for tweaking the steepness of the XP needed to level formula
|
||||
+ Added a permission node for Archery bonus damage
|
||||
+ Added a permission node for Greater Impact ability
|
||||
+ Added permission nodes for Treasure & Magic Hunter for Fishing
|
||||
+ Added a permission node for Farmer's Diet
|
||||
+ Added config options for enabling/disabling specific double drops
|
||||
+ Added automatic zip backup of flatfile database & config files
|
||||
+ Added config options to enable/disable specific skills for PVP & PVE
|
||||
= Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down.
|
||||
= Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick
|
||||
= Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change
|
||||
= Fixed bug where an arrow could bounce off entities on daze proc
|
||||
= Fixed bug where a player could gain Acrobatics experience while riding a cart
|
||||
= Fixed /party not working properly with 2 arguments
|
||||
= Fixed /party not showing properly the member list
|
||||
= Fixed /ability not checking the right permission
|
||||
= Fixed rare NPE on /party command
|
||||
= Fixed Arrow Retrieval dropping only one arrow
|
||||
= Fixed /p and /a incompatibilities with bChatManager
|
||||
= Fixed Iron Grip working reversely
|
||||
= Fixed NPE when user clicked the HUD button with Spout
|
||||
= Fixed bug where the permission node for Impact didn't work
|
||||
= Fixed some bypass nodes defaulting true for Ops
|
||||
= Fixed bug with trying to use Chimera Wing while standing on a half-block
|
||||
= Fixed duplication bug when a placed block was mined after a server restart
|
||||
= Fixed exploit where shooting yourself with an arrow gave Archery XP
|
||||
! Changed the mcMMO motd to link to the new website rather than the wiki
|
||||
! Changed bleeding ticks damage to 1 from 2
|
||||
! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch
|
||||
! Changed Super Breaker to be non-functional when used with a Silk Touch enchanted pick
|
||||
! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server
|
||||
! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency
|
||||
! Changed skill commands to only display what you have permissions for
|
||||
! Changed mcMMO to use a new storage system for player placed blocks
|
||||
- Removed some unused permission nodes
|
||||
- Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth)
|
||||
- Removed level requirement for repairing string tools from the config file
|
||||
|
||||
Version 1.3.06
|
||||
+ Added Iron Golem XP for aggressive golems
|
||||
+ Added permissions check to skill functions
|
||||
@@ -31,7 +99,7 @@ Version 1.3.06
|
||||
! Changed Bleeding to now stack to a finite number on Monsters and will wear off eventually
|
||||
! Changed how we handled the config file to prevent any bugs when returning values
|
||||
! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO
|
||||
! Changed mcremove to check for users in the MySQL DB before sending queries to remove them
|
||||
! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them
|
||||
! Changed how the tree feller threshold worked for the better
|
||||
! Changed /mcremove to no longer kick players when they are removed from database
|
||||
! Changed /mcremove to work on offline users for FlatFile
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
== mcMMO
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Forums
|
||||
http://forums.mcmmo.info Talk with developers and the community about mcMMO here
|
||||
|
||||
=== Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
|
||||
|
||||
73
extras/repair.chain.yml
Normal file
73
extras/repair.chain.yml
Normal file
@@ -0,0 +1,73 @@
|
||||
#
|
||||
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
|
||||
# All repair configs have a main section titled "Repairables"
|
||||
# Afterwards, all sub-items are considered a Repairable to be loaded
|
||||
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability
|
||||
#
|
||||
# ItemId: This is the id of the item to be repairable.
|
||||
## This is required to be set.
|
||||
#
|
||||
# ItemType: This is the type of item to be repaired, this is only important to permissions.
|
||||
## Valid values are ARMOR, TOOL, and OTHER.
|
||||
## This defaults to OTHER.
|
||||
#
|
||||
# MaterialType: This is the type of the material of the item to be repaired, this is only important for permissions.
|
||||
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
|
||||
## This defaults to OTHER.
|
||||
#
|
||||
# RepairMaterialId: This is the id of the item used to repair this repairable.
|
||||
## This is required to be set.
|
||||
#
|
||||
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
|
||||
## A value of -1 means to ignore all metadata when repairing.
|
||||
## This defaults to -1
|
||||
#
|
||||
# MaximumDurability: This is the maximum durability of the item.
|
||||
## This is required to be set.
|
||||
#
|
||||
# MinimumLevel: This is the minimum repair level needed to repair this item.
|
||||
## Valid values are > 0
|
||||
## This defaults to 0
|
||||
#
|
||||
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
|
||||
## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3
|
||||
## This defaults to 2
|
||||
#
|
||||
# XpMultiplier: This is the amount to multiply the xp bonus by.
|
||||
## This defaults to 1
|
||||
#
|
||||
#
|
||||
# The following is an example of a repair.*.yml config which adds the ability to repair Chainmail armor using fire.
|
||||
#
|
||||
#
|
||||
###
|
||||
Repairables:
|
||||
ChainHelmet:
|
||||
ItemId: 302
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 165
|
||||
MinimumQuantity: 5
|
||||
XpMultiplier: 2
|
||||
ChainChest:
|
||||
ItemId: 303
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 240
|
||||
MinimumQuantity: 8
|
||||
XpMultiplier: 2
|
||||
ChainLegs:
|
||||
ItemId: 304
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 225
|
||||
MinimumQuantity: 7
|
||||
XpMultiplier: 2
|
||||
ChainBoots:
|
||||
ItemId: 305
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
RepairMaterialMetadata: -1
|
||||
MaximumDurability: 195
|
||||
MinimumQuantity: 4
|
||||
XpMultiplier: 2
|
||||
2
pom.xml
2
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.06</version>
|
||||
<version>1.3.08</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.api;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ExperienceAPI {
|
||||
@@ -61,7 +61,7 @@ public class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXP(skillType, XP);
|
||||
Users.getProfile(player).addXP(player, skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class CommandHelper {
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
|
||||
@@ -10,8 +10,8 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
//TODO: Any way we can make this work for offline use?
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MccCommand implements CommandExecutor {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("m.mccLeaderboards"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Permissions.getInstance().mcAbility(player)) {
|
||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
|
||||
@@ -22,11 +22,11 @@ public class McmmoCommand implements CommandExecutor {
|
||||
if (Config.getInstance().spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer sPlayer = (SpoutPlayer) sender;
|
||||
|
||||
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "nossr50@gmail.com", Material.DIAMOND);
|
||||
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Donation Info:");
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "mcmmodev@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -17,11 +17,12 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
private final String location = mcMMO.usersFile;
|
||||
private final String location;
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McremoveCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
this.location = plugin.usersFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,9 +10,9 @@ 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.skills.Skills;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
|
||||
|
||||
@@ -57,18 +57,13 @@ public class PartyCommand implements CommandExecutor {
|
||||
|
||||
for (Player p : partyInstance.getAllMembers(player)) {
|
||||
if (p.equals(partyInstance.getPartyLeader(partyName))) {
|
||||
tempList = ChatColor.GOLD + p.getName();
|
||||
tempList += ChatColor.GOLD;
|
||||
}
|
||||
else {
|
||||
tempList = ChatColor.WHITE + p.getName();
|
||||
tempList += ChatColor.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
if (isLeader) {
|
||||
tempList += ChatColor.GOLD + playerName;
|
||||
}
|
||||
else {
|
||||
tempList += ChatColor.WHITE + playerName;
|
||||
tempList += p.getName() + " ";
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] { partyName }));
|
||||
@@ -166,11 +161,6 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!partyInstance.isParty(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PP.inParty()) {
|
||||
if (args[0].equalsIgnoreCase("password")) {
|
||||
if (isLeader) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -82,30 +84,33 @@ public class AcrobaticsCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
dodgeChance = "20";
|
||||
rollChance = "100";
|
||||
gracefulRollChance = "100";
|
||||
dodgeChance = "20.00%";
|
||||
rollChance = "100.00%";
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 800) {
|
||||
dodgeChance = "20";
|
||||
rollChance = String.valueOf(skillValue / 10);
|
||||
gracefulRollChance = "100";
|
||||
dodgeChance = "20.00%";
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 500) {
|
||||
dodgeChance = String.valueOf(skillValue / 40);
|
||||
rollChance = String.valueOf(skillValue / 10);
|
||||
gracefulRollChance = "100";
|
||||
dodgeChance = percent.format(skillValue / 4000);
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
dodgeChance = String.valueOf(skillValue / 40);
|
||||
rollChance = String.valueOf(skillValue / 10);
|
||||
gracefulRollChance = String.valueOf(skillValue / 5);
|
||||
dodgeChance = percent.format(skillValue / 4000);
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = percent.format(skillValue / 500);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canDodge = permInstance.dodge(player);
|
||||
canRoll = permInstance.roll(player);
|
||||
canGracefulRoll = permInstance.gracefulRoll(player);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -10,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ArcheryCommand implements CommandExecutor {
|
||||
@@ -18,6 +21,10 @@ public class ArcheryCommand implements CommandExecutor {
|
||||
private String dazeChance;
|
||||
private String retrieveChance;
|
||||
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -33,20 +40,43 @@ public class ArcheryCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
|
||||
if (canSkillShot || canDaze || canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canSkillShot || canDaze || canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
|
||||
|
||||
@@ -54,15 +84,25 @@ public class ArcheryCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
skillShotBonus = "200";
|
||||
dazeChance = "50";
|
||||
retrieveChance = "100";
|
||||
skillShotBonus = "200.00%";
|
||||
dazeChance = "50.00%";
|
||||
retrieveChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
skillShotBonus = String.valueOf((int) skillValue / 5);
|
||||
dazeChance = String.valueOf(skillValue / 20);
|
||||
retrieveChance = String.valueOf(skillValue / 10);
|
||||
skillShotBonus = percent.format(((int) skillValue / 50) * 0.1D); //TODO: Not sure if this is the best way to calculate this or not...
|
||||
dazeChance = percent.format(skillValue / 2000);
|
||||
retrieveChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canSkillShot = permInstance.archeryBonus(player);
|
||||
canDaze = permInstance.daze(player);
|
||||
canRetrieve = permInstance.trackArrows(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -9,6 +11,7 @@ import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AxesCommand implements CommandExecutor {
|
||||
@@ -19,6 +22,12 @@ public class AxesCommand implements CommandExecutor {
|
||||
private String greaterImpactDamage;
|
||||
private String skullSplitterLength;
|
||||
|
||||
private boolean canSkullSplitter;
|
||||
private boolean canCritical;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canImpact;
|
||||
private boolean canGreaterImpact;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -34,51 +43,91 @@ public class AxesCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.AXES);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Axes.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Axes") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
|
||||
if (canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
|
||||
}
|
||||
|
||||
if (canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
impactDamage = String.valueOf(5 + ((int) skillValue / 30));
|
||||
skullSplitterLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
greaterImpactDamage = "2";
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
critChance = "37.5";
|
||||
if (skillValue >= 750) {
|
||||
critChance = "37.50";
|
||||
bonusDamage = "4";
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
else if (skillValue >= 750) {
|
||||
critChance = "37.5";
|
||||
bonusDamage = "4";
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
else if (skillValue >= 200) {
|
||||
critChance = String.valueOf(skillValue / 20);
|
||||
critChance = percent.format(skillValue / 2000);
|
||||
bonusDamage = "4";
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
else {
|
||||
critChance = String.valueOf(skillValue / 20);
|
||||
critChance = percent.format(skillValue / 2000);
|
||||
bonusDamage = String.valueOf((int) skillValue / 50);
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canSkullSplitter = permInstance.skullSplitter(player);
|
||||
canCritical = permInstance.criticalHit(player);
|
||||
canBonusDamage = permInstance.axeBonus(player);
|
||||
canImpact = permInstance.impact(player);
|
||||
canGreaterImpact = permInstance.greaterImpact(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,16 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ExcavationCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
private String gigaDrillBreakerLength;
|
||||
|
||||
private boolean canGigaDrill;
|
||||
private boolean canTreasureHunt;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -31,17 +35,28 @@ public class ExcavationCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.EXCAVATION);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Excavation.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Excavation") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
|
||||
if (canGigaDrill || canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);
|
||||
|
||||
@@ -51,4 +66,11 @@ public class ExcavationCommand implements CommandExecutor {
|
||||
private void dataCalculations(float skillValue) {
|
||||
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canGigaDrill = permInstance.gigaDrillBreaker(player);
|
||||
canTreasureHunt = permInstance.excavationTreasures(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -9,11 +11,19 @@ import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class FishingCommand implements CommandExecutor {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -27,29 +37,68 @@ public class FishingCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
lootTier = Fishing.getFishingLootTier(PP);
|
||||
dataCalculations(lootTier);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { Fishing.getFishingLootTier(PP) }));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Info"));
|
||||
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
if (canTreasureHunt || canMagicHunt || canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt || canMagicHunt || canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
}
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataCalculations(int lootTier) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canTreasureHunt = permInstance.fishingTreasures(player);
|
||||
canMagicHunt = permInstance.fishingMagic(player);
|
||||
canShake = permInstance.shakeMob(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class HerbalismCommand implements CommandExecutor {
|
||||
@@ -20,6 +24,13 @@ public class HerbalismCommand implements CommandExecutor {
|
||||
private String farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
|
||||
private boolean canGreenTerra;
|
||||
private boolean canGreenThumbWheat;
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -35,24 +46,59 @@ public class HerbalismCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.HERBALISM);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Herbalism.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Herbalism") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
||||
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled )|| canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
||||
}
|
||||
|
||||
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled ) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);
|
||||
|
||||
@@ -60,49 +106,63 @@ public class HerbalismCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1500) {
|
||||
greenThumbChance = "100";
|
||||
greenThumbChance = "100.00%";
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "5";
|
||||
doubleDropChance = "100";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 1000) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "5";
|
||||
doubleDropChance = "100";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 800) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "4";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 600) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "3";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 400) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "3";
|
||||
farmersDietRank = "2";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 200) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "2";
|
||||
farmersDietRank = "1";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "1";
|
||||
farmersDietRank = "1";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canGreenTerra = permInstance.greenTerra(player);
|
||||
canGreenThumbWheat = permInstance.greenThumbWheat(player);
|
||||
canGreenThumbBlocks = permInstance.greenThumbBlocks(player);
|
||||
canFarmersDiet = permInstance.farmersDiet(player);
|
||||
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
|
||||
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,36 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MiningCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
private String doubleDropChance;
|
||||
private String superBreakerLength;
|
||||
private int blastMiningRank;
|
||||
private int blastRadiusIncrease;
|
||||
private int blastDamageDecrease;
|
||||
private String blastMiningRank;
|
||||
private String blastRadiusIncrease;
|
||||
private String blastDamageDecrease;
|
||||
|
||||
private boolean canSuperBreaker;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canBlast;
|
||||
private boolean canBiggerBombs;
|
||||
private boolean canDemoExpert;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -35,41 +47,73 @@ public class MiningCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.MINING);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Mining.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Mining") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 125) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (blastMiningRank - 1)) }));
|
||||
if (canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled ) || canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
|
||||
|
||||
if (canBlast) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
|
||||
}
|
||||
|
||||
if (canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled ) || canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 125) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1)) }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
|
||||
}
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.MINING, player, args);
|
||||
@@ -78,61 +122,75 @@ public class MiningCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
superBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
blastMiningRank = 8;
|
||||
blastDamageDecrease = 100;
|
||||
blastRadiusIncrease = 4;
|
||||
doubleDropChance = "100";
|
||||
blastMiningRank = "8";
|
||||
blastDamageDecrease = "100.00%";
|
||||
blastRadiusIncrease = "4";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 875) {
|
||||
blastMiningRank = 7;
|
||||
blastDamageDecrease = 50;
|
||||
blastRadiusIncrease = 3;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "7";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 750) {
|
||||
blastMiningRank = 6;
|
||||
blastDamageDecrease = 50;
|
||||
blastRadiusIncrease = 3;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "6";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 625) {
|
||||
blastMiningRank = 5;
|
||||
blastDamageDecrease = 25;
|
||||
blastRadiusIncrease = 2;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "5";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 500) {
|
||||
blastMiningRank = 4;
|
||||
blastDamageDecrease = 25;
|
||||
blastRadiusIncrease = 2;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "4";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 375) {
|
||||
blastMiningRank = 3;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 1;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "3";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 250) {
|
||||
blastMiningRank = 2;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 1;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "2";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 125) {
|
||||
blastMiningRank = 1;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 0;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "1";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else {
|
||||
blastMiningRank = 0;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 0;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "0";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canBiggerBombs = permInstance.biggerBombs(player);
|
||||
canBlast = permInstance.blastMining(player);
|
||||
canDemoExpert = permInstance.demolitionsExpertise(player);
|
||||
canDoubleDrop = permInstance.miningDoubleDrops(player);
|
||||
canSuperBreaker = permInstance.superBreaker(player);
|
||||
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class RepairCommand implements CommandExecutor {
|
||||
@@ -19,6 +24,22 @@ public class RepairCommand implements CommandExecutor {
|
||||
private String repairMasteryBonus;
|
||||
private String superRepairChance;
|
||||
|
||||
private boolean canSuperRepair;
|
||||
private boolean canMasterRepair;
|
||||
private boolean canArcaneForge;
|
||||
private boolean canRepairStone;
|
||||
private boolean canRepairIron;
|
||||
private boolean canRepairGold;
|
||||
private boolean canRepairDiamond;
|
||||
private boolean canRepairString;
|
||||
private boolean canRepairLeather;
|
||||
private boolean canRepairWood;
|
||||
|
||||
private int diamondLevel;
|
||||
private int goldLevel;
|
||||
private int ironLevel;
|
||||
private int stoneLevel;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -34,26 +55,73 @@ public class RepairCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.REPAIR);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
int arcaneForgingRank = Repair.getArcaneForgingRank(PP);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Repair.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Repair") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { Config.getInstance().getRepairDiamondLevelRequirement() }), LocaleLoader.getString("Repair.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
|
||||
if (canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
|
||||
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
|
||||
}
|
||||
|
||||
/* Repair Level Requirements */
|
||||
|
||||
if (canRepairStone && stoneLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.14", new Object[] { stoneLevel }), LocaleLoader.getString("Repair.Effect.15") }));
|
||||
}
|
||||
|
||||
if (canRepairIron && ironLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.12", new Object[] { ironLevel }), LocaleLoader.getString("Repair.Effect.13") }));
|
||||
}
|
||||
|
||||
if (canRepairGold && goldLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.10", new Object[] { goldLevel }), LocaleLoader.getString("Repair.Effect.11") }));
|
||||
}
|
||||
|
||||
if (canRepairDiamond && diamondLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { diamondLevel }), LocaleLoader.getString("Repair.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
|
||||
}
|
||||
|
||||
if (canArcaneForge || canMasterRepair || canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
|
||||
|
||||
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
|
||||
}
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
|
||||
|
||||
@@ -61,13 +129,41 @@ public class RepairCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
repairMasteryBonus = String.valueOf(skillValue / 5);
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
// We're using pickaxes here, not the best but works
|
||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
|
||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
|
||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
|
||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
|
||||
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
||||
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
||||
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
||||
|
||||
repairMasteryBonus = percent.format(skillValue / 500);
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
superRepairChance = "100";
|
||||
superRepairChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
superRepairChance = String.valueOf(skillValue / 10);
|
||||
superRepairChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canSuperRepair = permInstance.repairBonus(player);
|
||||
canMasterRepair = permInstance.repairMastery(player);
|
||||
canArcaneForge = permInstance.arcaneForging(player);
|
||||
canRepairDiamond = permInstance.diamondRepair(player);
|
||||
canRepairGold = permInstance.goldRepair(player);
|
||||
canRepairIron = permInstance.ironRepair(player);
|
||||
canRepairStone = permInstance.stoneRepair(player);
|
||||
canRepairString = permInstance.stringRepair(player);
|
||||
canRepairLeather = permInstance.leatherRepair(player);
|
||||
canRepairWood = permInstance.woodRepair(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -10,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SwordsCommand implements CommandExecutor {
|
||||
@@ -19,6 +22,10 @@ public class SwordsCommand implements CommandExecutor {
|
||||
private String bleedChance;
|
||||
private String serratedStrikesLength;
|
||||
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -34,23 +41,46 @@ public class SwordsCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.SWORDS);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Swords.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Swords") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
|
||||
if (canBleed || canCounter || canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canBleed || canCounter || canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.SWORDS, player, args);
|
||||
|
||||
@@ -58,22 +88,32 @@ public class SwordsCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 750) {
|
||||
bleedLength = "3";
|
||||
bleedChance = "75";
|
||||
counterAttackChance = "30";
|
||||
bleedChance = "75.00%";
|
||||
counterAttackChance = "30.00%";
|
||||
}
|
||||
else if (skillValue >= 600) {
|
||||
bleedLength = "2";
|
||||
bleedChance = String.valueOf(skillValue / 10);
|
||||
counterAttackChance = "30";
|
||||
bleedChance = percent.format(skillValue / 1000);
|
||||
counterAttackChance = "30.00%";
|
||||
}
|
||||
else {
|
||||
bleedLength = "2";
|
||||
bleedChance = String.valueOf(skillValue / 10);
|
||||
counterAttackChance = String.valueOf(skillValue / 20);
|
||||
bleedChance = percent.format(skillValue / 1000);
|
||||
counterAttackChance = percent.format(skillValue / 2000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canBleed = permInstance.swordsBleed(player);
|
||||
canCounter = permInstance.counterAttack(player);
|
||||
canSerratedStrike = permInstance.serratedStrikes(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -11,12 +13,22 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class TamingCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
private String goreChance;
|
||||
|
||||
private boolean canBeastLore;
|
||||
private boolean canGore;
|
||||
private boolean canSharpenedClaws;
|
||||
private boolean canEnvironmentallyAware;
|
||||
private boolean canThickFur;
|
||||
private boolean canShockProof;
|
||||
private boolean canCallWild;
|
||||
private boolean canFastFood;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -32,61 +44,102 @@ public class TamingCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.TAMING);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Taming.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Taming") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
|
||||
if (canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
|
||||
if (canBeastLore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
|
||||
if (canSharpenedClaws) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9 ") }));
|
||||
if (canEnvironmentallyAware) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
|
||||
if (canThickFur) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
|
||||
}
|
||||
|
||||
if (canFastFood) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
|
||||
}
|
||||
|
||||
if (canCallWild) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canFastFood) {
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);
|
||||
|
||||
@@ -94,11 +147,26 @@ public class TamingCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
goreChance = "100";
|
||||
goreChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
goreChance = String.valueOf(skillValue / 10);
|
||||
goreChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canBeastLore = permInstance.beastLore(player);
|
||||
canCallWild = permInstance.callOfTheWild(player);
|
||||
canEnvironmentallyAware = permInstance.environmentallyAware(player);
|
||||
canFastFood = permInstance.fastFoodService(player);
|
||||
canGore = permInstance.gore(player);
|
||||
canSharpenedClaws = permInstance.sharpenedClaws(player);
|
||||
canShockProof = permInstance.shockProof(player);
|
||||
canThickFur = permInstance.thickFur(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -10,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class UnarmedCommand implements CommandExecutor {
|
||||
@@ -19,6 +22,11 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
private String disarmChance;
|
||||
private String ironArmBonus;
|
||||
|
||||
private boolean canBerserk;
|
||||
private boolean canDisarm;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canDeflect;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -34,22 +42,51 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
||||
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||
}
|
||||
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
|
||||
|
||||
@@ -57,22 +94,33 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
disarmChance = "33.3";
|
||||
deflectChance = "50";
|
||||
disarmChance = "33.33%";
|
||||
deflectChance = "50.00%";
|
||||
ironArmBonus = "8";
|
||||
}
|
||||
else if (skillValue >= 250) {
|
||||
disarmChance = String.valueOf(skillValue / 30);
|
||||
deflectChance = String.valueOf(skillValue / 20);
|
||||
disarmChance = percent.format(skillValue / 3000);
|
||||
deflectChance = percent.format(skillValue / 2000);
|
||||
ironArmBonus = "8";
|
||||
}
|
||||
else {
|
||||
disarmChance = String.valueOf(skillValue / 30);
|
||||
deflectChance = String.valueOf(skillValue / 20);
|
||||
disarmChance = percent.format(skillValue / 3000);
|
||||
deflectChance = percent.format(skillValue / 2000);
|
||||
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canBerserk = permInstance.berserk(player);
|
||||
canBonusDamage = permInstance.unarmedBonus(player);
|
||||
canDeflect = permInstance.deflect(player);
|
||||
canDisarm = permInstance.disarm(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class WoodcuttingCommand implements CommandExecutor {
|
||||
@@ -17,6 +21,11 @@ public class WoodcuttingCommand implements CommandExecutor {
|
||||
private String treeFellerLength;
|
||||
private String doubleDropChance;
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -32,41 +41,75 @@ public class WoodcuttingCommand implements CommandExecutor {
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("WoodCutting.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Woodcutting.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
if ((canDoubleDrop && !doubleDropsDisabled ) || canLeafBlow || canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canLeafBlow) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||
}
|
||||
|
||||
if ((canDoubleDrop && !doubleDropsDisabled ) || canLeafBlow || canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
//TODO: Remove? Basically duplicates the above.
|
||||
if (canLeafBlow) {
|
||||
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
doubleDropChance = "100";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canTreeFell = permInstance.treeFeller(player);
|
||||
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
|
||||
canLeafBlow = permInstance.leafBlower(player);
|
||||
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class XplockCommand implements CommandExecutor {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
|
||||
@@ -10,6 +15,7 @@ public class Config extends ConfigLoader {
|
||||
public static Config getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Config(mcMMO.p);
|
||||
instance.load();
|
||||
}
|
||||
|
||||
return instance;
|
||||
@@ -33,7 +39,8 @@ public class Config extends ConfigLoader {
|
||||
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
|
||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||
public String getMySQLUserPassword() {
|
||||
|
||||
public String getMySQLUserPassword() {
|
||||
if (config.getString("MySQL.Database.User_Password", null) != null) {
|
||||
return config.getString("MySQL.Database.User_Password", null);
|
||||
}
|
||||
@@ -42,6 +49,17 @@ public class Config extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5); }
|
||||
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
|
||||
|
||||
/* SMP Mods */
|
||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||
|
||||
/* Commands */
|
||||
public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); }
|
||||
public boolean getCommandXPRateEnabled() { return config.getBoolean("Commands.xprate.Enabled", true); }
|
||||
@@ -95,6 +113,16 @@ public class Config extends ConfigLoader {
|
||||
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); }
|
||||
|
||||
@@ -130,12 +158,43 @@ public class Config extends ConfigLoader {
|
||||
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 boolean getHerbalismHungerBonusEnabled() { return config.getBoolean("Skills.Herbalism.Hunger_Bonus", true); }
|
||||
public boolean getHerbalismWheatRegrowth() { return config.getBoolean("Skills.Herbalism.Instant_Wheat_Regrowth", true); }
|
||||
|
||||
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", 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 herbalismDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Herbalism");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Herbalism." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* Mining */
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
|
||||
@@ -150,29 +209,46 @@ public class Config extends ConfigLoader {
|
||||
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 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 miningDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Mining");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Mining." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
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 int getRepairGoldMaterial() { return config.getInt("Skills.Repair.Gold.ID", 266); }
|
||||
public int getRepairStoneMaterial() { return config.getInt("Skills.Repair.Stone.ID", 4); }
|
||||
public int getRepairWoodMaterial() { return config.getInt("Skills.Repair.Wood.ID", 5); }
|
||||
public int getRepairDiamondMaterial() { return config.getInt("Skills.Repair.Diamond.ID", 264); }
|
||||
public int getRepairIronMaterial() { return config.getInt("Skills.Repair.Iron.ID", 265); }
|
||||
public int getRepairStringMaterial() { return config.getInt("Skills.Repair.String.ID", 287); }
|
||||
public int getRepairLeatherMaterial() { return config.getInt("Skills.Repair.Leather.ID", 334); }
|
||||
|
||||
public boolean getRepairArmorAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Armor", true); }
|
||||
public boolean getRepairToolsAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Tools", true); }
|
||||
public int getRepairDiamondLevelRequirement() { return config.getInt("Skills.Repair.Diamond.Level_Required", 50); }
|
||||
public int getRepairIronLevelRequirement() { return config.getInt("Skills.Repair.Iron.Level_Required", 0); }
|
||||
public int getRepairGoldLevelRequirement() { return config.getInt("Skills.Repair.Gold.Level_Required", 0); }
|
||||
public int getRepairStoneLevelRequirement() { return config.getInt("Skills.Repair.Stone.Level_Required", 0); }
|
||||
public int getRepairStringLevelRequirement() { return config.getInt("Skills.Repair.String.Level_Required", 0); }
|
||||
|
||||
/* 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); }
|
||||
@@ -185,6 +261,30 @@ public class Config extends ConfigLoader {
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
|
||||
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() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Woodcutting");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Woodcutting." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); }
|
||||
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
|
||||
@@ -216,6 +316,20 @@ public class Config extends ConfigLoader {
|
||||
public int getLevelCapWoodcutting() { return config.getInt("Skills.Woodcutting.Level_Cap", 0); }
|
||||
public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); }
|
||||
|
||||
/* 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
|
||||
*/
|
||||
@@ -245,6 +359,7 @@ public class Config extends ConfigLoader {
|
||||
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.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); }
|
||||
@@ -328,12 +443,10 @@ public class Config extends ConfigLoader {
|
||||
super(plugin, "config.yml");
|
||||
config = plugin.getConfig();
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
// If it doesn't exist, copy it from the .jar
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveDefaultConfig();
|
||||
@@ -359,4 +472,4 @@ public class Config extends ConfigLoader {
|
||||
if(defaulthud == null)
|
||||
defaulthud = HUDType.STANDARD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ public abstract class ConfigLoader {
|
||||
* Add the defaults to this config file.
|
||||
*/
|
||||
protected void addDefaults() {
|
||||
|
||||
// Load from included config.yml
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
|
||||
44
src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Normal file
44
src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class HiddenConfig extends ConfigLoader {
|
||||
private static String fileName;
|
||||
private static HiddenConfig instance;
|
||||
private static YamlConfiguration config;
|
||||
|
||||
private static boolean chunkletsEnabled;
|
||||
|
||||
public HiddenConfig(mcMMO plugin, String fileName) {
|
||||
super(plugin, fileName);
|
||||
HiddenConfig.fileName = fileName;
|
||||
}
|
||||
|
||||
|
||||
public static HiddenConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new HiddenConfig(mcMMO.p, "hidden.yml");
|
||||
instance.load();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
if(plugin.isInJar(fileName)) loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
config = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
||||
|
||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||
}
|
||||
|
||||
public boolean getChunkletsEnabled() {
|
||||
return chunkletsEnabled;
|
||||
}
|
||||
}
|
||||
111
src/main/java/com/gmail/nossr50/config/RepairConfig.java
Normal file
111
src/main/java/com/gmail/nossr50/config/RepairConfig.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private final String fileName;
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(mcMMO plugin, String fileName) {
|
||||
super(plugin, fileName);
|
||||
this.fileName = fileName;
|
||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
ConfigurationSection section = config.getConfigurationSection("Repairables");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for(String key : keys) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
if(!config.contains("Repairables." + key + ".ItemId")) {
|
||||
reason.add(key + " is missing ItemId");
|
||||
}
|
||||
|
||||
if(!config.contains("Repairables." + key + ".RepairMaterialId")) {
|
||||
reason.add(key + " is missing RepairMaterialId");
|
||||
}
|
||||
|
||||
if(!config.contains("Repairables." + key + ".MaximumDurability")) {
|
||||
reason.add(key + " is missing MaximumDurability");
|
||||
}
|
||||
|
||||
int itemId = config.getInt("Repairables." + key + ".ItemId", 0);
|
||||
int repairMaterialId = config.getInt("Repairables." + key + ".RepairMaterialId", 0);
|
||||
int maximumDurability = config.getInt("Repairables." + key + ".MaximumDurability", 0);
|
||||
|
||||
int repairMetadata = config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
|
||||
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel", 0);
|
||||
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
|
||||
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
|
||||
|
||||
RepairItemType repairItemType = RepairItemType.OTHER;
|
||||
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
|
||||
|
||||
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
|
||||
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
|
||||
|
||||
if(minimumLevel < 0) {
|
||||
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
}
|
||||
|
||||
if(minimumQuantity < 0) {
|
||||
reason.add(key + " has an invalid MinimumQuantity of " + minimumQuantity);
|
||||
}
|
||||
|
||||
try {
|
||||
repairItemType = RepairItemType.valueOf(repairItemTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
}
|
||||
|
||||
try {
|
||||
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
}
|
||||
|
||||
if(noErrorsInRepairable(reason)) {
|
||||
Repairable repairable = RepairableFactory.getRepairable(itemId, repairMaterialId, (byte) repairMetadata, minimumLevel, minimumQuantity, (short) maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||
repairables.add(repairable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
|
||||
private boolean noErrorsInRepairable(List<String> issues) {
|
||||
if (issues.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfigManager(mcMMO plugin) {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
|
||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||
if(!vanilla.exists()) {
|
||||
plugin.saveResource("repair.vanilla.yml", false);
|
||||
}
|
||||
|
||||
for(String location : dataFolder.list()) {
|
||||
if(!pattern.matcher(location).matches()) continue;
|
||||
|
||||
plugin.getLogger().info("Loading " + location + " repair config file...");
|
||||
|
||||
File file = new File(dataFolder, location);
|
||||
if(file.isDirectory()) continue;
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(plugin, location);
|
||||
rConfig.load();
|
||||
|
||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
||||
if(rConfigRepairables != null) {
|
||||
repairables.addAll(rConfigRepairables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,13 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class LoadTreasures extends ConfigLoader{
|
||||
private static LoadTreasures instance;
|
||||
public class TreasuresConfig extends ConfigLoader{
|
||||
private static TreasuresConfig instance;
|
||||
|
||||
public static LoadTreasures getInstance() {
|
||||
public static TreasuresConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoadTreasures(mcMMO.p);
|
||||
instance = new TreasuresConfig(mcMMO.p);
|
||||
instance.load();
|
||||
}
|
||||
|
||||
return instance;
|
||||
@@ -40,16 +41,13 @@ public class LoadTreasures extends ConfigLoader{
|
||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
|
||||
private LoadTreasures(mcMMO plugin) {
|
||||
private TreasuresConfig(mcMMO plugin) {
|
||||
super(plugin, "treasures.yml");
|
||||
config = plugin.getTreasuresConfig();
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
|
||||
// If it doesn't exist, copy it from the .jar
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveTreasuresConfig();
|
||||
@@ -95,7 +93,7 @@ public class LoadTreasures extends ConfigLoader{
|
||||
int data = config.getInt("Treasures." + treasureName + ".Data");
|
||||
|
||||
if (Material.getMaterial(id) == null) {
|
||||
reason.add("Invlid id: " + id);
|
||||
reason.add("Invalid id: " + id);
|
||||
}
|
||||
|
||||
if (amount < 1) {
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ModConfigLoader{
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomArmorConfig(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
|
||||
public CustomArmorConfig(mcMMO plugin) {
|
||||
super(plugin, "armor.yml");
|
||||
config = plugin.getArmorConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveArmorConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO armor.yml File...");
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBootIDs);
|
||||
loadArmor("Chestplates", customChestplateIDs);
|
||||
loadArmor("Helmets", customHelmetIDs);
|
||||
loadArmor("Leggings", customLeggingIDs);
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
Iterator<String> iterator = armorConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String armorName = iterator.next();
|
||||
|
||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomItem armor;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
}
|
||||
|
||||
armor = new CustomItem(id);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customArmorList.add(armor);
|
||||
customArmor.put(id, armor);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
|
||||
public class CustomBlocksConfig extends ModConfigLoader{
|
||||
private static CustomBlocksConfig instance;
|
||||
|
||||
public static CustomBlocksConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomBlocksConfig(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||
|
||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||
|
||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||
|
||||
public CustomBlocksConfig(mcMMO plugin) {
|
||||
super(plugin, "blocks.yml");
|
||||
config = plugin.getBlocksConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveBlocksConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO blocks.yml File...");
|
||||
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
Iterator<String> iterator = skillConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String blockName = iterator.next();
|
||||
|
||||
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
|
||||
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
||||
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1);
|
||||
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
|
||||
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
|
||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
|
||||
int dropAmount = config.getInt(skillType + "." + blockName + ".Drop_Item_Amount", 1);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dropItem && dropID == 0) {
|
||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
|
||||
dropItem = false;
|
||||
}
|
||||
|
||||
CustomBlock block;
|
||||
ItemStack itemDrop;
|
||||
ItemStack blockItem;
|
||||
|
||||
if (dropItem) {
|
||||
itemDrop = new ItemStack(dropID, dropAmount, (short) 0, dropData);
|
||||
}
|
||||
else {
|
||||
itemDrop = new ItemStack(id, dropAmount, (short) 0, data);
|
||||
}
|
||||
|
||||
block = new CustomBlock(itemDrop, tier, xp, data, id);
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockItem);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockItem);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockItem);
|
||||
block.setXpGain(0); //Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
blockList.add(blockItem);
|
||||
customItems.add(blockItem);
|
||||
customBlocks.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomToolsConfig extends ModConfigLoader {
|
||||
private static CustomToolsConfig instance;
|
||||
|
||||
public static CustomToolsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomToolsConfig(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
||||
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||
|
||||
private CustomToolsConfig(mcMMO plugin) {
|
||||
super(plugin, "tools.yml");
|
||||
config = plugin.getToolsConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveToolsConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO tools.yml File...");
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxeIDs);
|
||||
loadTool("Bows", customBowIDs);
|
||||
loadTool("Hoes", customHoeIDs);
|
||||
loadTool("Pickaxes", customPickaxeIDs);
|
||||
loadTool("Shovels", customShovelIDs);
|
||||
loadTool("Swords", customSwordIDs);
|
||||
}
|
||||
|
||||
private void loadTool(String toolType, List<Integer> idList) {
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
Iterator<String> iterator = toolConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String toolName = iterator.next();
|
||||
|
||||
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
|
||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
|
||||
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
|
||||
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomTool tool;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
}
|
||||
|
||||
tool = new CustomTool(tier, abilityEnabled, multiplier, id);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customToolList.add(tool);
|
||||
customTools.put(id, tool);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
|
||||
public abstract class ModConfigLoader extends ConfigLoader{
|
||||
|
||||
public ModConfigLoader(mcMMO plugin, String fileName) {
|
||||
super(plugin, "ModConfigs" + File.separator + fileName);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(
|
||||
Config.getInstance().getAbilityCooldownBerserk(),
|
||||
Config.getInstance().getAbilityMaxTicksBerserk(),
|
||||
"Unarmed.Skills.Berserk.On",
|
||||
"Unarmed.Skills.Berserk.Off",
|
||||
"Unarmed.Skills.Berserk.Other.On",
|
||||
@@ -21,6 +21,7 @@ public enum AbilityType {
|
||||
|
||||
SUPER_BREAKER(
|
||||
Config.getInstance().getAbilityCooldownSuperBreaker(),
|
||||
Config.getInstance().getAbilityMaxTicksSuperBreaker(),
|
||||
"Mining.Skills.SuperBreaker.On",
|
||||
"Mining.Skills.SuperBreaker.Off",
|
||||
"Mining.Skills.SuperBreaker.Other.On",
|
||||
@@ -29,6 +30,7 @@ public enum AbilityType {
|
||||
|
||||
GIGA_DRILL_BREAKER(
|
||||
Config.getInstance().getAbilityCooldownGigaDrillBreaker(),
|
||||
Config.getInstance().getAbilityMaxTicksGigaDrillBreaker(),
|
||||
"Excavation.Skills.GigaDrillBreaker.On",
|
||||
"Excavation.Skills.GigaDrillBreaker.Off",
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.On",
|
||||
@@ -37,6 +39,7 @@ public enum AbilityType {
|
||||
|
||||
GREEN_TERRA(
|
||||
Config.getInstance().getAbilityCooldownGreenTerra(),
|
||||
Config.getInstance().getAbilityMaxTicksGreenTerra(),
|
||||
"Herbalism.Skills.GTe.On",
|
||||
"Herbalism.Skills.GTe.Off",
|
||||
"Herbalism.Skills.GTe.Other.On",
|
||||
@@ -45,6 +48,7 @@ public enum AbilityType {
|
||||
|
||||
SKULL_SPLIITER(
|
||||
Config.getInstance().getAbilityCooldownSkullSplitter(),
|
||||
Config.getInstance().getAbilityMaxTicksSkullSplitter(),
|
||||
"Axes.Skills.SS.On",
|
||||
"Axes.Skills.SS.Off",
|
||||
"Axes.Skills.SS.Other.On",
|
||||
@@ -53,6 +57,7 @@ public enum AbilityType {
|
||||
|
||||
TREE_FELLER(
|
||||
Config.getInstance().getAbilityCooldownTreeFeller(),
|
||||
Config.getInstance().getAbilityMaxTicksTreeFeller(),
|
||||
"Woodcutting.Skills.TreeFeller.On",
|
||||
"Woodcutting.Skills.TreeFeller.Off",
|
||||
"Woodcutting.Skills.TreeFeller.Other.On",
|
||||
@@ -61,6 +66,7 @@ public enum AbilityType {
|
||||
|
||||
SERRATED_STRIKES(
|
||||
Config.getInstance().getAbilityCooldownSerratedStrikes(),
|
||||
Config.getInstance().getAbilityMaxTicksSerratedStrikes(),
|
||||
"Swords.Skills.SS.On",
|
||||
"Swords.Skills.SS.Off",
|
||||
"Swords.Skills.SS.Other.On",
|
||||
@@ -69,6 +75,7 @@ public enum AbilityType {
|
||||
|
||||
BLAST_MINING(
|
||||
Config.getInstance().getAbilityCooldownBlastMining(),
|
||||
Config.getInstance().getAbilityMaxTicksBlastMining(),
|
||||
null,
|
||||
null,
|
||||
"Mining.Blast.Other.On",
|
||||
@@ -76,6 +83,7 @@ public enum AbilityType {
|
||||
null),
|
||||
|
||||
LEAF_BLOWER(
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
@@ -84,14 +92,16 @@ public enum AbilityType {
|
||||
null);
|
||||
|
||||
private int cooldown;
|
||||
private int maxTicks;
|
||||
private String abilityOn;
|
||||
private String abilityOff;
|
||||
private String abilityPlayer;
|
||||
private String abilityRefresh;
|
||||
private String abilityPlayerOff;
|
||||
|
||||
private AbilityType(int cooldown, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
private AbilityType(int cooldown, int maxTicks, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.cooldown = cooldown;
|
||||
this.maxTicks = maxTicks;
|
||||
this.abilityOn = abilityOn;
|
||||
this.abilityOff = abilityOff;
|
||||
this.abilityPlayer = abilityPlayer;
|
||||
@@ -123,6 +133,10 @@ public enum AbilityType {
|
||||
return LocaleLoader.getString(this.abilityRefresh);
|
||||
}
|
||||
|
||||
public int getMaxTicks() {
|
||||
return this.maxTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions for this ability.
|
||||
*
|
||||
@@ -130,33 +144,35 @@ public enum AbilityType {
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return Permissions.getInstance().berserk(player);
|
||||
return permInstance.berserk(player);
|
||||
|
||||
case BLAST_MINING:
|
||||
return Permissions.getInstance().blastMining(player);
|
||||
return permInstance.blastMining(player);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Permissions.getInstance().gigaDrillBreaker(player);
|
||||
return permInstance.gigaDrillBreaker(player);
|
||||
|
||||
case GREEN_TERRA:
|
||||
return Permissions.getInstance().greenTerra(player);
|
||||
return permInstance.greenTerra(player);
|
||||
|
||||
case LEAF_BLOWER:
|
||||
return Permissions.getInstance().leafBlower(player);
|
||||
return permInstance.leafBlower(player);
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return Permissions.getInstance().serratedStrikes(player);
|
||||
return permInstance.serratedStrikes(player);
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
return Permissions.getInstance().skullSplitter(player);
|
||||
return permInstance.skullSplitter(player);
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return Permissions.getInstance().superBreaker(player);
|
||||
return permInstance.superBreaker(player);
|
||||
|
||||
case TREE_FELLER:
|
||||
return Permissions.getInstance().treeFeller(player);
|
||||
return permInstance.treeFeller(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
@@ -166,28 +182,28 @@ public enum AbilityType {
|
||||
/**
|
||||
* Check if a block is affected by this ability.
|
||||
*
|
||||
* @param material The block type to check
|
||||
* @param Block the block to check
|
||||
* @return true if the block is affected by this ability, false otherwise
|
||||
*/
|
||||
public boolean blockCheck(Material material) {
|
||||
public boolean blockCheck(Block block) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return (Excavation.canBeGigaDrillBroken(material) || material.equals(Material.SNOW));
|
||||
return (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Excavation.canBeGigaDrillBroken(material);
|
||||
return BlockChecks.canBeGigaDrillBroken(block);
|
||||
|
||||
case GREEN_TERRA:
|
||||
return Herbalism.makeMossy(material);
|
||||
return BlockChecks.makeMossy(block);
|
||||
|
||||
case LEAF_BLOWER:
|
||||
return material.equals(Material.LEAVES);
|
||||
return block.getType() == Material.LEAVES;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return Mining.canBeSuperBroken(material);
|
||||
return BlockChecks.canBeSuperBroken(block);
|
||||
|
||||
case TREE_FELLER:
|
||||
return material.equals(Material.LOG);
|
||||
return block.getType() == Material.LOG;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -9,11 +9,14 @@ import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
@@ -57,7 +60,7 @@ public class PlayerProfile {
|
||||
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private String playerName;
|
||||
private String location = mcMMO.usersFile;
|
||||
private final String location = mcMMO.p.usersFile;
|
||||
|
||||
public PlayerProfile(String name, boolean addNew) {
|
||||
hud = Config.getInstance().defaulthud;
|
||||
@@ -1000,13 +1003,11 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
* @param player The player to add XP to
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
Player player = mcMMO.p.getServer().getPlayer(playerName);
|
||||
|
||||
public void addXP(Player player, SkillType skillType, int newValue) {
|
||||
if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
@@ -1029,6 +1030,15 @@ public class PlayerProfile {
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
lastgained = skillType;
|
||||
@@ -1112,7 +1122,7 @@ public class PlayerProfile {
|
||||
* @return the XP remaining until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return (int) (1020 + (skills.get(skillType) * 20)); //Do we REALLY need to cast to int here?
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); //Do we REALLY need to cast to int here?
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ public enum ToolType {
|
||||
return ItemChecks.isHoe(is);
|
||||
|
||||
case PICKAXE:
|
||||
return ItemChecks.isMiningPick(is);
|
||||
return ItemChecks.isPickaxe(is);
|
||||
|
||||
case SHOVEL:
|
||||
return ItemChecks.isShovel(is);
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CustomBlock {
|
||||
private int itemID;
|
||||
private byte dataValue;
|
||||
private int xpGain;
|
||||
private int tier;
|
||||
private ItemStack itemDrop;
|
||||
|
||||
public CustomBlock(ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
this.itemID = itemID;
|
||||
this.dataValue = dataValue;
|
||||
this.xpGain = xpGain;
|
||||
this.tier = tier;
|
||||
this.itemDrop = itemDrop;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public byte getDataValue() {
|
||||
return dataValue;
|
||||
}
|
||||
|
||||
public void setDataValue(byte dataValue) {
|
||||
this.dataValue = dataValue;
|
||||
}
|
||||
|
||||
public int getXpGain() {
|
||||
return xpGain;
|
||||
}
|
||||
|
||||
public void setXpGain(int xpGain) {
|
||||
this.xpGain = xpGain;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public ItemStack getItemDrop() {
|
||||
return itemDrop;
|
||||
}
|
||||
|
||||
public void setItemDrop(ItemStack itemDrop) {
|
||||
this.itemDrop = itemDrop;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
public class CustomItem {
|
||||
protected int itemID;
|
||||
|
||||
public CustomItem(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
public class CustomTool extends CustomItem {
|
||||
private double xpMultiplier;
|
||||
private boolean abilityEnabled;
|
||||
private int tier;
|
||||
|
||||
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, int itemID) {
|
||||
super(itemID);
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
this.abilityEnabled = abilityEnabled;
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public double getXpMultiplier() {
|
||||
return xpMultiplier;
|
||||
}
|
||||
|
||||
public void setXpMultiplier(Double xpMultiplier) {
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
public boolean isAbilityEnabled() {
|
||||
return abilityEnabled;
|
||||
}
|
||||
|
||||
public void setAbilityEnabled(boolean abilityEnabled) {
|
||||
this.abilityEnabled = abilityEnabled;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,10 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
|
||||
public class PopupMMO extends GenericPopup {
|
||||
|
||||
private ButtonHUDStyle HUDButton = null;
|
||||
private ButtonPartyToggle PartyButton = null;
|
||||
private ButtonEscape EscapeButton = null;
|
||||
private GenericLabel mcMMO_label = new GenericLabel();
|
||||
private GenericLabel tip_escape = new GenericLabel();
|
||||
@@ -53,7 +51,7 @@ public class PopupMMO extends GenericPopup {
|
||||
|
||||
public void updateButtons(PlayerProfile PP) {
|
||||
HUDButton.updateText(PP);
|
||||
PartyButton.updateText(PP);
|
||||
//PartyButton.updateText(PP);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class Treasure {
|
||||
private int xp;
|
||||
private Double dropChance;
|
||||
private double dropChance;
|
||||
private int dropLevel;
|
||||
private ItemStack drop;
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class Treasure {
|
||||
this.xp = xp;
|
||||
}
|
||||
|
||||
public Double getDropChance() {
|
||||
public double getDropChance() {
|
||||
return dropChance;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,21 +8,21 @@ import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.WoodCutting;
|
||||
import com.gmail.nossr50.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.gathering.Mining;
|
||||
import com.gmail.nossr50.skills.gathering.WoodCutting;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -36,7 +36,6 @@ 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 org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
@@ -58,16 +57,16 @@ public class BlockListener implements Listener {
|
||||
BlockFace direction = event.getDirection();
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
b.getRelative(direction).setMetadata("mcmmoNeedsTracking", new FixedMetadataValue(plugin, true));
|
||||
b.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
}
|
||||
if (mcMMO.placeStore.isTrue(b)) {
|
||||
mcMMO.placeStore.setTrue(b.getRelative(direction));
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
}
|
||||
}
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.getRelative(direction).hasMetadata("mcmmoNeedsTracking")) {
|
||||
b.getRelative(direction).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
b.getRelative(direction).removeMetadata("mcmmoNeedsTracking", plugin);
|
||||
if (mcMMO.placeStore.isTrue(b.getRelative(direction))) {
|
||||
mcMMO.placeStore.setTrue(b.getRelative(direction));
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,9 +80,9 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getRetractLocation().getBlock();
|
||||
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
event.getBlock().getRelative(event.getDirection()).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
if (event.isSticky() && mcMMO.placeStore.isTrue(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
mcMMO.placeStore.setTrue(event.getBlock().getRelative(event.getDirection()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +93,8 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
int id = block.getTypeId();
|
||||
@@ -107,18 +108,18 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
else {
|
||||
Block newLocation = block.getRelative(0, y + 1, 0);
|
||||
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
mcMMO.placeStore.setTrue(newLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(mat)) {
|
||||
block.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
|
||||
if (id == Config.getInstance().getRepairAnvilId() && Config.getInstance().getRepairAnvilMessagesEnabled()) {
|
||||
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
|
||||
Repair.placedAnvilCheck(player, id);
|
||||
}
|
||||
}
|
||||
@@ -133,77 +134,82 @@ public class BlockListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Block block = event.getBlock();
|
||||
Material mat = block.getType();
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
|
||||
/* Green Terra */
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* Triple drops */
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
/*
|
||||
* MINING
|
||||
*/
|
||||
|
||||
if (Permissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
|
||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
/* HERBALISM */
|
||||
if (BlockChecks.canBeGreenTerra(block)) {
|
||||
/* Green Terra */
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
||||
|
||||
/* Triple drops */
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
if (permInstance.herbalism(player)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockChecks.canBeSuperBroken(block) && permInstance.mining(player)) {
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WOOD CUTTING
|
||||
*/
|
||||
|
||||
if (Permissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockChecks.isLog(block) && permInstance.woodcutting(player)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
else if (!Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
|
||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* EXCAVATION
|
||||
*/
|
||||
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && Permissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
/* EXCAVATION */
|
||||
else if (BlockChecks.canBeGigaDrillBroken(block) && permInstance.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
||||
else {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (block.hasMetadata("mcmmoPlacedBlock") && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,83 +224,113 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
Material mat = block.getType();
|
||||
Material material = block.getType();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if (BlockChecks.abilityBlockCheck(mat)) {
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
|
||||
else if (PP.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && Mining.canBeSuperBroken(mat)) {
|
||||
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && Excavation.canBeGigaDrillBroken(mat)) {
|
||||
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.FISTS) && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
|
||||
else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/* TREE FELLER SOUNDS */
|
||||
if (Config.getInstance().spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
if (configInstance.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*/
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inhand.getType().equals(Material.AIR)) {
|
||||
if (inHand.getType().equals(Material.AIR)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
event.setInstaBreak(true);
|
||||
}
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
if (configInstance.spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && mat.equals(Material.LEAVES)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!Config.getInstance().getWoodcuttingRequiresTool() && !inhand.getType().equals(Material.SHEARS)) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
}
|
||||
}
|
||||
else if (!inHand.getType().equals(Material.SHEARS)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -30,14 +32,14 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Archery;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.combat.Archery;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.misc.Acrobatics;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
@@ -58,14 +60,22 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (attacker instanceof Player && defender instanceof Player) {
|
||||
if (!defender.getWorld().getPVP()) {
|
||||
return;
|
||||
}
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
}
|
||||
else if (attacker instanceof Tameable) {
|
||||
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||
|
||||
if (animalTamer instanceof Player) {
|
||||
attacker = (Player) animalTamer;
|
||||
}
|
||||
}
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (attacker instanceof Player && defender instanceof Player) {
|
||||
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -94,12 +104,15 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
EntityType type = entity.getType();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
switch(type) {
|
||||
case PLAYER:
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity lEntity = (LivingEntity) entity;
|
||||
|
||||
if (lEntity instanceof Player) {
|
||||
/* Check for invincibility */
|
||||
Player player = (Player) entity;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
@@ -110,7 +123,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (!Misc.isInvincible(player, event)) {
|
||||
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player)) {
|
||||
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player) && !player.isInsideVehicle() && !player.getItemInHand().getType().equals(Material.ENDER_PEARL)) {
|
||||
Acrobatics.acrobaticsCheck(player, event);
|
||||
}
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
|
||||
@@ -121,18 +134,12 @@ public class EntityListener implements Listener {
|
||||
PP.setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (lEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) lEntity;
|
||||
|
||||
case WOLF:
|
||||
Wolf wolf = (Wolf) entity;
|
||||
|
||||
if ((!Misc.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
|
||||
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (pet.getOwner() instanceof Player)) {
|
||||
Taming.preventDamage(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +151,10 @@ public class EntityListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
entity.setFireTicks(0);
|
||||
|
||||
/* Remove bleed track */
|
||||
BleedTimer.remove(entity);
|
||||
|
||||
Archery.arrowRetrievalCheck(entity, plugin);
|
||||
Archery.arrowRetrievalCheck(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,65 +220,67 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (Config.getInstance().getHerbalismHungerBonusEnabled()) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
|
||||
/*
|
||||
* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
if (!Permissions.getInstance().farmersDiet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
/*
|
||||
* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
|
||||
switch (food) {
|
||||
case BREAD:
|
||||
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
switch (food) {
|
||||
case BREAD:
|
||||
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 200; i <= 1000; i += rankChange) {
|
||||
if (herbLevel >= i) {
|
||||
foodChange++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 200; i <= 1000; i += rankChange) {
|
||||
if (herbLevel >= i) {
|
||||
foodChange++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we don't go over the max value */
|
||||
newFoodLevel = currentFoodLevel + foodChange;
|
||||
if (newFoodLevel > 20) {
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
event.setFoodLevel(newFoodLevel);
|
||||
}
|
||||
/* Make sure we don't go over the max value */
|
||||
newFoodLevel = currentFoodLevel + foodChange;
|
||||
if (newFoodLevel > 20) {
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
event.setFoodLevel(newFoodLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,7 +313,7 @@ public class EntityListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.TAMING, xp);
|
||||
PP.addXP(player, SkillType.TAMING, xp);
|
||||
Skills.XpCheckSkill(SkillType.TAMING, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Hardcore;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreListener implements Listener {
|
||||
|
||||
@EventHandler()
|
||||
public void PlayerDeathEvent(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
|
||||
if(!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||
if(player.getKiller() instanceof Player) {
|
||||
if(Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(((Player)player.getKiller()), player);
|
||||
}
|
||||
}
|
||||
Hardcore.invokeStatPenalty(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,16 +37,14 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@@ -163,16 +161,33 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Permissions.getInstance().motd(player) && Config.getInstance().getMOTDEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.Wiki"));
|
||||
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
|
||||
String prefix = ChatColor.GOLD+"[mcMMO] ";
|
||||
|
||||
player.sendMessage(prefix+ChatColor.YELLOW+"Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
|
||||
|
||||
if(Config.getInstance().getHardcoreEnabled()) {
|
||||
if(Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore & Vampirism enabled.");
|
||||
player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"% "+ChatColor.DARK_AQUA+"Vampirism Stat Leech: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreVampirismStatLeechPercentage()+"%");
|
||||
} else {
|
||||
player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore enabled.");
|
||||
player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"%");
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GREEN+ "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
|
||||
}
|
||||
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if (XprateCommand.xpevent) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,33 +198,34 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack is = player.getItemInHand();
|
||||
Material mat;
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Material material;
|
||||
|
||||
/* Fix for NPE on interacting with air */
|
||||
if (block == null) {
|
||||
mat = Material.AIR;
|
||||
material = Material.AIR;
|
||||
}
|
||||
else {
|
||||
mat = block.getType();
|
||||
material = block.getType();
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId() && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
|
||||
Repair.repairCheck(player, is);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
||||
if (mcMMO.repairManager.isRepairable(inHand)) {
|
||||
mcMMO.repairManager.handleRepair(player, inHand);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(mat)) {
|
||||
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
|
||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
||||
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@@ -222,17 +238,17 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
if (Permissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
|
||||
Herbalism.greenThumbBlocks(is, player, block);
|
||||
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.getInstance().greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(inHand, player, block);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
if (BlockChecks.abilityBlockCheck(mat)) {
|
||||
Item.itemchecks(player);
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
Item.itemChecks(player);
|
||||
}
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||
BlastMining.detonate(event, player, plugin);
|
||||
}
|
||||
|
||||
@@ -252,10 +268,10 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
Item.itemchecks(player);
|
||||
Item.itemChecks(player);
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||
BlastMining.detonate(event, player, plugin);
|
||||
}
|
||||
|
||||
@@ -266,10 +282,10 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* CALL OF THE WILD CHECKS */
|
||||
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
|
||||
if (is.getType().equals(Material.RAW_FISH)) {
|
||||
if (inHand.getType().equals(Material.RAW_FISH)) {
|
||||
Taming.animalSummon(EntityType.OCELOT, player, plugin);
|
||||
}
|
||||
else if (is.getType().equals(Material.BONE)) {
|
||||
else if (inHand.getType().equals(Material.BONE)) {
|
||||
Taming.animalSummon(EntityType.WOLF, player, plugin);
|
||||
}
|
||||
}
|
||||
@@ -286,66 +302,62 @@ public class PlayerListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
boolean partyChat = PP.getPartyChatMode();
|
||||
boolean adminChat = PP.getAdminChatMode();
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
|
||||
Set<Player> intendedRecipients = new HashSet<Player>();
|
||||
ChatColor color = null;
|
||||
if (PP.getPartyChatMode()) {
|
||||
if (!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
|
||||
if (partyChat || adminChat) {
|
||||
if (partyChat) {
|
||||
if (!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
color = ChatColor.GREEN;
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
Set<Player> intendedRecipients = new HashSet<Player>();
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
for (Player x : Party.getInstance().getOnlineMembers(player)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
|
||||
for (Player x : Party.getInstance().getOnlineMembers(player)) {
|
||||
ChatColor bracketColor = ChatColor.GREEN;
|
||||
|
||||
event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s");
|
||||
event.getRecipients().retainAll(intendedRecipients);
|
||||
}
|
||||
else if (PP.getAdminChatMode()) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
Set<Player> intendedRecipients = new HashSet<Player>();
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
|
||||
event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s");
|
||||
}
|
||||
|
||||
if (adminChat) {
|
||||
color = ChatColor.AQUA;
|
||||
ChatColor bracketColor = ChatColor.AQUA;
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
}
|
||||
|
||||
event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s");
|
||||
}
|
||||
|
||||
recipients.retainAll(intendedRecipients);
|
||||
event.setFormat(bracketColor + "{" + ChatColor.WHITE + "%1$s" + bracketColor + "} %2$s");
|
||||
event.getRecipients().retainAll(intendedRecipients);
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamically aliasing commands need to be re-done.
|
||||
// For now, using a command with an alias will send both the original command, and the mcMMO command
|
||||
|
||||
/**
|
||||
* Monitor PlayerCommandPreprocess events.
|
||||
*
|
||||
@@ -354,18 +366,16 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String message = event.getMessage();
|
||||
|
||||
if (!message.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
String lowerCaseCommand = command.toLowerCase();
|
||||
|
||||
if (plugin.aliasMap.containsKey(command)) {
|
||||
if (command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
|
||||
if (plugin.aliasMap.containsKey(lowerCaseCommand)) {
|
||||
//We should find a better way to avoid string replacement where the alias is equals to the command
|
||||
if (command.equals(plugin.aliasMap.get(lowerCaseCommand))) {
|
||||
return;
|
||||
}
|
||||
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
|
||||
|
||||
event.setMessage(message.replace(command, plugin.aliasMap.get(lowerCaseCommand)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
src/main/java/com/gmail/nossr50/listeners/WorldListener.java
Normal file
43
src/main/java/com/gmail/nossr50/listeners/WorldListener.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
|
||||
if(!dataDir.exists()) {
|
||||
dataDir.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
mcMMO.placeStore.unloadWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
mcMMO.placeStore.saveWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
mcMMO.placeStore.chunkLoaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,39 @@ import com.gmail.nossr50.commands.spout.*;
|
||||
import com.gmail.nossr50.commands.mc.*;
|
||||
import com.gmail.nossr50.commands.party.*;
|
||||
import com.gmail.nossr50.commands.general.*;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.runnables.*;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Metrics.Graph;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.HardcoreListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
@@ -29,7 +47,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
@@ -37,37 +54,60 @@ public class mcMMO extends JavaPlugin {
|
||||
private final PlayerListener playerListener = new PlayerListener(this);
|
||||
private final BlockListener blockListener = new BlockListener(this);
|
||||
private final EntityListener entityListener = new EntityListener(this);
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
||||
|
||||
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
||||
|
||||
public static File versionFile;
|
||||
public static Database database;
|
||||
public static mcMMO p;
|
||||
|
||||
//Jar stuff
|
||||
public static File mcmmo;
|
||||
public static ChunkletManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
|
||||
/* Jar Stuff */
|
||||
public File mcmmo;
|
||||
|
||||
//File Paths
|
||||
public static String mainDirectory;
|
||||
public static String flatFileDirectory;
|
||||
public static String usersFile;
|
||||
public static String leaderboardDirectory;
|
||||
public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory;
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
public void onEnable() {
|
||||
p = this;
|
||||
mcmmo = getFile();
|
||||
setupFilePaths();
|
||||
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
//Force the loading of config files
|
||||
Config configInstance = Config.getInstance();
|
||||
TreasuresConfig.getInstance();
|
||||
HiddenConfig.getInstance();
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
if (configInstance.getToolModsEnabled()) {
|
||||
CustomToolsConfig.getInstance().load();
|
||||
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getArmorModsEnabled()) {
|
||||
CustomArmorConfig.getInstance().load();
|
||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getBlockModsEnabled()) {
|
||||
CustomBlocksConfig.getInstance().load();
|
||||
}
|
||||
|
||||
//Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||
repairManager.registerRepairables(repairables);
|
||||
|
||||
if (!configInstance.getUseMySQL()) {
|
||||
Users.loadUsers();
|
||||
}
|
||||
|
||||
@@ -77,11 +117,16 @@ public class mcMMO extends JavaPlugin {
|
||||
pm.registerEvents(playerListener, this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
if (configInstance.getHardcoreEnabled()) {
|
||||
pm.registerEvents(hardcoreListener, this);
|
||||
}
|
||||
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
|
||||
//Setup the leaderboards
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
if (configInstance.getUseMySQL()) {
|
||||
database = new Database(this);
|
||||
database.createStructure();
|
||||
}
|
||||
@@ -100,7 +145,7 @@ public class mcMMO extends JavaPlugin {
|
||||
//Schedule Spout Activation 1 second after start-up
|
||||
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
||||
//Periodic save timer (Saves every 10 minutes)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, Config.getInstance().getSaveInterval() * 1200);
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
||||
//Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
||||
//Bleed timer (Runs every two seconds)
|
||||
@@ -108,17 +153,50 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
registerCommands();
|
||||
|
||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
||||
if (configInstance.getStatsTrackingEnabled()) {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
Graph graph = metrics.createGraph("Percentage of servers using timings");
|
||||
|
||||
if(pm.useTimings()) {
|
||||
graph.addPlotter(new Metrics.Plotter("Enabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
graph.addPlotter(new Metrics.Plotter("Disabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
metrics.start();
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.println("Failed to submit stats.");
|
||||
}
|
||||
}
|
||||
|
||||
// Get our ChunkletManager
|
||||
placeStore = ChunkletManagerFactory.getChunkletManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
public void setupFilePaths() {
|
||||
mcmmo = getFile();
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player.
|
||||
@@ -160,13 +238,27 @@ public class mcMMO extends JavaPlugin {
|
||||
* Things to be run when the plugin is disabled.
|
||||
*/
|
||||
public void onDisable() {
|
||||
|
||||
//Make sure to save player information if the server shuts down
|
||||
for (PlayerProfile x : Users.getProfiles().values()) {
|
||||
x.save();
|
||||
}
|
||||
|
||||
this.getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
|
||||
//Save our metadata
|
||||
placeStore.saveAll();
|
||||
|
||||
//Cleanup empty metadata stores
|
||||
placeStore.cleanUp();
|
||||
|
||||
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMObackup();
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
|
||||
System.out.println("mcMMO was disabled."); //How informative!
|
||||
}
|
||||
|
||||
@@ -174,7 +266,6 @@ public class mcMMO extends JavaPlugin {
|
||||
* Register the commands.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
|
||||
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
|
||||
//Skills commands
|
||||
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
|
||||
@@ -188,7 +279,7 @@ public class mcMMO extends JavaPlugin {
|
||||
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
||||
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
||||
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
||||
aliasMap.put(LocaleLoader.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting");
|
||||
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").toLowerCase(), "woodcutting");
|
||||
|
||||
//Register commands
|
||||
//Skills commands
|
||||
@@ -205,89 +296,91 @@ public class mcMMO extends JavaPlugin {
|
||||
getCommand("unarmed").setExecutor(new UnarmedCommand());
|
||||
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
//mc* commands
|
||||
if (Config.getInstance().getCommandMCRemoveEnabled()) {
|
||||
if (configInstance.getCommandMCRemoveEnabled()) {
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCAbilityEnabled()) {
|
||||
if (configInstance.getCommandMCAbilityEnabled()) {
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCCEnabled()) {
|
||||
if (configInstance.getCommandMCCEnabled()) {
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCGodEnabled()) {
|
||||
if (configInstance.getCommandMCGodEnabled()) {
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandmcMMOEnabled()) {
|
||||
if (configInstance.getCommandmcMMOEnabled()) {
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCRefreshEnabled()) {
|
||||
if (configInstance.getCommandMCRefreshEnabled()) {
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCTopEnabled()) {
|
||||
if (configInstance.getCommandMCTopEnabled()) {
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCStatsEnabled()) {
|
||||
if (configInstance.getCommandMCStatsEnabled()) {
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
//Party commands
|
||||
if (Config.getInstance().getCommandAcceptEnabled()) {
|
||||
if (configInstance.getCommandAcceptEnabled()) {
|
||||
getCommand("accept").setExecutor(new AcceptCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandAdminChatAEnabled()) {
|
||||
if (configInstance.getCommandAdminChatAEnabled()) {
|
||||
getCommand("a").setExecutor(new ACommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandInviteEnabled()) {
|
||||
if (configInstance.getCommandInviteEnabled()) {
|
||||
getCommand("invite").setExecutor(new InviteCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandPartyEnabled()) {
|
||||
if (configInstance.getCommandPartyEnabled()) {
|
||||
getCommand("party").setExecutor(new PartyCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandPartyChatPEnabled()) {
|
||||
if (configInstance.getCommandPartyChatPEnabled()) {
|
||||
getCommand("p").setExecutor(new PCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandPTPEnabled()) {
|
||||
if (configInstance.getCommandPTPEnabled()) {
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
}
|
||||
|
||||
//Other commands
|
||||
if (Config.getInstance().getCommandAddXPEnabled()) {
|
||||
if (configInstance.getCommandAddXPEnabled()) {
|
||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandAddLevelsEnabled()) {
|
||||
if (configInstance.getCommandAddLevelsEnabled()) {
|
||||
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMmoeditEnabled()) {
|
||||
if (configInstance.getCommandMmoeditEnabled()) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandInspectEnabled()) {
|
||||
if (configInstance.getCommandInspectEnabled()) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandXPRateEnabled()) {
|
||||
if (configInstance.getCommandXPRateEnabled()) {
|
||||
getCommand("xprate").setExecutor(new XprateCommand(this));
|
||||
}
|
||||
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
|
||||
|
||||
//Spout commands
|
||||
if (Config.getInstance().getCommandXPLockEnabled()) {
|
||||
if (configInstance.getCommandXPLockEnabled()) {
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
}
|
||||
|
||||
@@ -295,7 +388,7 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff
|
||||
* Boilerplate Custom Config Stuff (Treasures)
|
||||
*/
|
||||
|
||||
private FileConfiguration treasuresConfig = null;
|
||||
@@ -310,9 +403,9 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
|
||||
InputStream defConfigStream = getResource("treasures.yml"); // Look for defaults in the jar
|
||||
|
||||
if (defConfigStream != null) {
|
||||
if (isInJar("treasures.yml")) {
|
||||
InputStream defConfigStream = getResource("treasures.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
treasuresConfig.setDefaults(defConfig);
|
||||
}
|
||||
@@ -343,7 +436,171 @@ public class mcMMO extends JavaPlugin {
|
||||
treasuresConfig.save(treasuresConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
this.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
|
||||
getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Tools)
|
||||
*/
|
||||
|
||||
private FileConfiguration toolsConfig = null;
|
||||
private File toolsConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Tools.yml file.
|
||||
*/
|
||||
public void reloadToolsConfig() {
|
||||
if (toolsConfigFile == null) {
|
||||
toolsConfigFile = new File(modDirectory, "tools.yml");
|
||||
}
|
||||
|
||||
toolsConfig = YamlConfiguration.loadConfiguration(toolsConfigFile);
|
||||
|
||||
if (isInJar("tools.yml")) {
|
||||
InputStream defConfigStream = getResource("tools.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
toolsConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Tools config information.
|
||||
*
|
||||
* @return the configuration object for tools.yml
|
||||
*/
|
||||
public FileConfiguration getToolsConfig() {
|
||||
if (toolsConfig == null) {
|
||||
reloadToolsConfig();
|
||||
}
|
||||
|
||||
return toolsConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Tools config informtion.
|
||||
*/
|
||||
public void saveToolsConfig() {
|
||||
if (toolsConfig == null || toolsConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
toolsConfig.save(toolsConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + toolsConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Armor)
|
||||
*/
|
||||
|
||||
private FileConfiguration armorConfig = null;
|
||||
private File armorConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Armor.yml file.
|
||||
*/
|
||||
public void reloadArmorConfig() {
|
||||
if (armorConfigFile == null) {
|
||||
armorConfigFile = new File(modDirectory, "armor.yml");
|
||||
}
|
||||
|
||||
armorConfig = YamlConfiguration.loadConfiguration(armorConfigFile);
|
||||
|
||||
if (isInJar("armor.yml")) {
|
||||
InputStream defConfigStream = getResource("armor.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
armorConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Armor config information.
|
||||
*
|
||||
* @return the configuration object for armor.yml
|
||||
*/
|
||||
public FileConfiguration getArmorConfig() {
|
||||
if (armorConfig == null) {
|
||||
reloadArmorConfig();
|
||||
}
|
||||
|
||||
return armorConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Armor config informtion.
|
||||
*/
|
||||
public void saveArmorConfig() {
|
||||
if (armorConfig == null || armorConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
armorConfig.save(armorConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + armorConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Blocks)
|
||||
*/
|
||||
|
||||
private FileConfiguration blocksConfig = null;
|
||||
private File blocksConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Blocks.yml file.
|
||||
*/
|
||||
public void reloadBlocksConfig() {
|
||||
if (blocksConfigFile == null) {
|
||||
blocksConfigFile = new File(modDirectory, "blocks.yml");
|
||||
}
|
||||
|
||||
blocksConfig = YamlConfiguration.loadConfiguration(blocksConfigFile);
|
||||
|
||||
if (isInJar("blocks.yml")) {
|
||||
InputStream defConfigStream = getResource("blocks.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
blocksConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Blocks config information.
|
||||
*
|
||||
* @return the configuration object for blocks.yml
|
||||
*/
|
||||
public FileConfiguration getBlocksConfig() {
|
||||
if (blocksConfig == null) {
|
||||
reloadBlocksConfig();
|
||||
}
|
||||
|
||||
return blocksConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Blocks config informtion.
|
||||
*/
|
||||
public void saveBlocksConfig() {
|
||||
if (blocksConfig == null || blocksConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
blocksConfig.save(blocksConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + blocksConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInJar(String resource) {
|
||||
InputStream iStream = getResource(resource);
|
||||
return iStream != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,9 +152,10 @@ public class Party {
|
||||
|
||||
if (player != null) {
|
||||
for (String name : profiles.keySet()) {
|
||||
Player p = profiles.get(name).getPlayer();
|
||||
if (inSameParty(p, player)) {
|
||||
players.add(p);
|
||||
Player otherPlayer = profiles.get(name).getPlayer();
|
||||
|
||||
if (otherPlayer != null && inSameParty(otherPlayer, player)) {
|
||||
players.add(otherPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +170,7 @@ public class Party {
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public ArrayList<String> getParties() {
|
||||
String location = mcMMO.usersFile;
|
||||
String location = plugin.usersFile;
|
||||
ArrayList<String> parties = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
@@ -193,7 +194,7 @@ public class Party {
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
return parties;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.gmail.nossr50.util.Combat;
|
||||
|
||||
public class BleedTimer implements Runnable {
|
||||
private final static int MAX_BLEED_TICKS = 10;
|
||||
|
||||
|
||||
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
||||
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
|
||||
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
|
||||
@@ -48,13 +48,8 @@ public class BleedTimer implements Runnable {
|
||||
}
|
||||
|
||||
//Never kill with Bleeding
|
||||
if (player.getHealth() - 2 < 0) {
|
||||
if (player.getHealth() - 1 > 0) {
|
||||
Combat.dealDamage(player, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Combat.dealDamage(player, 2);
|
||||
if (player.getHealth() - 1 > 0) {
|
||||
Combat.dealDamage(player, 1);
|
||||
}
|
||||
|
||||
entry.setValue(entry.getValue() - 1);
|
||||
@@ -121,6 +116,7 @@ public class BleedTimer implements Runnable {
|
||||
* Add a LivingEntity to the bleedList if it is not in it.
|
||||
*
|
||||
* @param entity LivingEntity to add
|
||||
* @param ticks Number of bleeding ticks
|
||||
*/
|
||||
public static void add(LivingEntity entity, int ticks) {
|
||||
int newTicks = ticks;
|
||||
@@ -128,7 +124,7 @@ public class BleedTimer implements Runnable {
|
||||
if (lock) {
|
||||
if (bleedAddList.containsKey(entity)) {
|
||||
newTicks += bleedAddList.get(entity);
|
||||
|
||||
|
||||
if (newTicks > MAX_BLEED_TICKS) {
|
||||
newTicks = MAX_BLEED_TICKS;
|
||||
}
|
||||
@@ -146,7 +142,7 @@ public class BleedTimer implements Runnable {
|
||||
else {
|
||||
if (bleedList.containsKey(entity)) {
|
||||
newTicks += bleedList.get(entity);
|
||||
|
||||
|
||||
if (newTicks > MAX_BLEED_TICKS) {
|
||||
newTicks = MAX_BLEED_TICKS;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
@@ -39,7 +39,7 @@ public class GainXp implements Runnable {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
PP.addXP(skillType, (int) (damage * baseXp));
|
||||
PP.addXP(player, skillType, (int) (damage * baseXp));
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ProfileSaveTask implements Runnable {
|
||||
Player player = null;
|
||||
|
||||
public ProfileSaveTask(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player != null) {
|
||||
Users.getProfileByName(player.getName()).save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class SQLConversionTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String location = mcMMO.usersFile;
|
||||
String location = plugin.usersFile;
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class SQLReconnect implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Database.isConnected()) {
|
||||
if (!Database.isConnected()) {
|
||||
Database.connect();
|
||||
if (Database.isConnected()) {
|
||||
for (PlayerProfile x : Users.players.values()) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SaveTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
@@ -15,8 +14,11 @@ public class SaveTimer implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
//All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.getProfile(player).save();
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new ProfileSaveTask(player), count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillMonitor implements Runnable {
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Archery {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Track arrows fired for later retrieval.
|
||||
*
|
||||
* @param plugin mcMMO plugin instance
|
||||
* @param entity Entity damaged by the arrow
|
||||
* @param PPa PlayerProfile of the player firing the arrow
|
||||
*/
|
||||
public static void trackArrows(mcMMO plugin, Entity entity, PlayerProfile PPa) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||
|
||||
if (!plugin.arrowTracker.containsKey(entity)) {
|
||||
plugin.arrowTracker.put(entity, 0);
|
||||
}
|
||||
|
||||
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
|
||||
plugin.arrowTracker.put(entity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Daze.
|
||||
*
|
||||
* @param defender Defending player
|
||||
* @param attacker Attacking player
|
||||
*/
|
||||
public static void dazeCheck(Player defender, Player attacker) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||
Location loc = defender.getLocation();
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(10) > 5) {
|
||||
loc.setPitch(90);
|
||||
}
|
||||
else {
|
||||
loc.setPitch(-90);
|
||||
}
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().daze(attacker)) {
|
||||
defender.teleport(loc);
|
||||
Combat.dealDamage(defender, 4);
|
||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for arrow retrieval.
|
||||
*
|
||||
* @param entity The entity hit by the arrows
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin) {
|
||||
if (plugin.arrowTracker.containsKey(entity)) {
|
||||
Misc.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.arrowTracker.get(entity));
|
||||
}
|
||||
|
||||
plugin.arrowTracker.remove(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
public class Mining {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Drop items from Mining & Blast Mining skills.
|
||||
*
|
||||
* @param block The block to process drops for
|
||||
*/
|
||||
public static void miningDrops(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
Material type = block.getType();
|
||||
ItemStack item = new ItemStack(type);
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
|
||||
Misc.mcDropItem(loc, item);
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
item = new ItemStack(Material.DIAMOND);
|
||||
Misc.mcDropItem(loc, item);
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
item = new ItemStack(Material.REDSTONE);
|
||||
Misc.mcDropItems(loc, item, 4);
|
||||
Misc.mcRandomDropItem(loc, item, 50);
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
item = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
Misc.mcDropItems(loc, item, 2);
|
||||
Misc.mcRandomDropItems(loc, item, 50, 2);
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
|
||||
Misc.mcDropItems(loc, item, 4);
|
||||
Misc.mcRandomDropItems(loc, item, 50, 4);
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
item = new ItemStack(Material.COBBLESTONE);
|
||||
Misc.mcDropItem(loc, item);
|
||||
break;
|
||||
|
||||
default:
|
||||
Misc.mcDropItem(loc, item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Award XP for Mining blocks.
|
||||
*
|
||||
* @param player The player to award XP to
|
||||
* @param block The block to award XP for
|
||||
*/
|
||||
public static void miningXP(Player player, Block block) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Material type = block.getType();
|
||||
int xp = 0;
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
xp += Config.getInstance().getMiningXPCoalOre();
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
xp += Config.getInstance().getMiningXPDiamondOre();
|
||||
break;
|
||||
|
||||
case ENDER_STONE:
|
||||
xp += Config.getInstance().getMiningXPEndStone();
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
xp += Config.getInstance().getMiningXPRedstoneOre();
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
xp += Config.getInstance().getMiningXPGlowstone();
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
xp += Config.getInstance().getMiningXPGoldOre();
|
||||
break;
|
||||
|
||||
case IRON_ORE:
|
||||
xp += Config.getInstance().getMiningXPIronOre();
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
xp += Config.getInstance().getMiningXPLapisOre();
|
||||
break;
|
||||
|
||||
case MOSSY_COBBLESTONE:
|
||||
xp += Config.getInstance().getMiningXPMossyStone();
|
||||
break;
|
||||
|
||||
case NETHERRACK:
|
||||
xp += Config.getInstance().getMiningXPNetherrack();
|
||||
break;
|
||||
|
||||
case OBSIDIAN:
|
||||
xp += Config.getInstance().getMiningXPObsidian();
|
||||
break;
|
||||
|
||||
case SANDSTONE:
|
||||
xp += Config.getInstance().getMiningXPSandstone();
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
xp += Config.getInstance().getMiningXPStone();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.MINING, xp);
|
||||
Skills.XpCheckSkill(SkillType.MINING, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Mining block drops.
|
||||
*
|
||||
* @param player The player mining the block
|
||||
* @param block The block being broken
|
||||
*/
|
||||
public static void miningBlockCheck(Player player, Block block) {
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
miningXP(player, block);
|
||||
|
||||
if (canBeSuperBroken(block.getType())) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
|
||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().miningDoubleDrops(player)) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
Misc.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
|
||||
}
|
||||
else {
|
||||
miningDrops(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a block is broken by Super Breaker.
|
||||
*
|
||||
* @param type The type of Block to check
|
||||
* @return true if the block would be broken by Super Breaker, false otherwise
|
||||
*/
|
||||
public static Boolean canBeSuperBroken(Material type) {
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case ENDER_STONE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GLOWSTONE:
|
||||
case GOLD_ORE:
|
||||
case IRON_ORE:
|
||||
case LAPIS_ORE:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case OBSIDIAN:
|
||||
case REDSTONE_ORE:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Super Breaker ability.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param block The block being affected
|
||||
*/
|
||||
public static void SuperBreakerBlockCheck(Player player, Block block) {
|
||||
Material type = block.getType();
|
||||
int tier = Misc.getTier(player.getItemInHand());
|
||||
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
|
||||
switch (type) {
|
||||
case OBSIDIAN:
|
||||
if (tier < 4) {
|
||||
return;
|
||||
}
|
||||
durabilityLoss = durabilityLoss * 5; //Obsidian needs to do more damage than normal
|
||||
/* FALL THROUGH */
|
||||
|
||||
case DIAMOND_ORE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GOLD_ORE:
|
||||
case LAPIS_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (tier < 3) {
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
|
||||
case IRON_ORE:
|
||||
if (tier < 2) {
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
|
||||
case COAL_ORE:
|
||||
case ENDER_STONE:
|
||||
case GLOWSTONE:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
|
||||
|
||||
miningBlockCheck(player, block);
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,492 +0,0 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class Repair {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Handle all the item repair checks.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param is The item being repaired
|
||||
*/
|
||||
public static void repairCheck(Player player, ItemStack is) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
short durabilityBefore = is.getDurability();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (durabilityBefore > 0 && is.getAmount() == 1) {
|
||||
|
||||
/*
|
||||
* REPAIR ARMOR
|
||||
*/
|
||||
if (ItemChecks.isArmor(is) && Config.getInstance().getRepairArmorAllowed() && Permissions.getInstance().armorRepair(player)) {
|
||||
if (ItemChecks.isDiamondArmor(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 6, true);
|
||||
}
|
||||
else if (ItemChecks.isIronArmor(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && Permissions.getInstance().ironRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairIronMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, true);
|
||||
}
|
||||
else if (ItemChecks.isGoldArmor(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && Permissions.getInstance().goldRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 4, true);
|
||||
}
|
||||
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(Config.getInstance().getRepairLeatherMaterial()) && Permissions.getInstance().leatherRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairLeatherMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 1, true);
|
||||
}
|
||||
else {
|
||||
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* REPAIR TOOLS
|
||||
*/
|
||||
else if (ItemChecks.isTool(is) && Config.getInstance().getRepairToolsAllowed() && Permissions.getInstance().toolRepair(player)) {
|
||||
if (ItemChecks.isStoneTool(is) && inventory.contains(Config.getInstance().getRepairStoneMaterial()) && skillLevel >= Config.getInstance().getRepairStoneLevelRequirement() && Permissions.getInstance().stoneRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStoneMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, false);
|
||||
}
|
||||
else if (ItemChecks.isWoodTool(is) && inventory.contains(Config.getInstance().getRepairWoodMaterial()) && Permissions.getInstance().woodRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairWoodMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, false);
|
||||
}
|
||||
else if (ItemChecks.isIronTool(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && Permissions.getInstance().ironRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairIronMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 1, true);
|
||||
}
|
||||
else if (ItemChecks.isDiamondTool(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 1, true);
|
||||
}
|
||||
else if (ItemChecks.isGoldTool(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && Permissions.getInstance().goldRepair(player)) {
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 8, true);
|
||||
}
|
||||
else if (ItemChecks.isStringTool(is) && inventory.contains(Config.getInstance().getRepairStringMaterial()) && skillLevel >= Config.getInstance().getRepairStringLevelRequirement() && Permissions.getInstance().stringRepair(player)){
|
||||
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStringMaterial()));
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, false);
|
||||
}
|
||||
else {
|
||||
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the XP gain for repair events.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param PP PlayerProfile of the repairing player
|
||||
* @param is Item being repaired
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
* @param boost True if the modifier is a boost, false if the modifier is a reduction
|
||||
*/
|
||||
private static void xpHandler(Player player, PlayerProfile PP, ItemStack is, short durabilityBefore, int modify, boolean boost) {
|
||||
short durabilityAfter = is.getDurability();
|
||||
short dif = (short) (durabilityBefore - durabilityAfter);
|
||||
|
||||
if (boost) {
|
||||
dif = (short) (dif * modify);
|
||||
}
|
||||
else{
|
||||
dif = (short) (dif / modify);
|
||||
}
|
||||
|
||||
if (ItemChecks.isShovel(is)) {
|
||||
dif = (short) (dif / 3);
|
||||
}
|
||||
else if(ItemChecks.isSword(is)) {
|
||||
dif = (short) (dif / 2);
|
||||
}
|
||||
else if(ItemChecks.isHoe(is)) {
|
||||
dif = (short) (dif / 2);
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.REPAIR, dif * 10);
|
||||
Skills.XpCheckSkill(SkillType.REPAIR, player);
|
||||
|
||||
//CLANG CLANG
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playRepairNoise(player, mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Arcane Forging rank.
|
||||
*
|
||||
* @param skillLevel The skill level of the player whose rank is being checked
|
||||
* @return The player's current Arcane Forging rank
|
||||
*/
|
||||
public static int getArcaneForgingRank(PlayerProfile PP) {
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels4()) {
|
||||
return 4;
|
||||
}
|
||||
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels3()) {
|
||||
return 3;
|
||||
}
|
||||
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels2()) {
|
||||
return 2;
|
||||
}
|
||||
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels1()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles removing & downgrading enchants.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param is Item being repaired
|
||||
*/
|
||||
private static void addEnchants(Player player, ItemStack is) {
|
||||
Map<Enchantment, Integer> enchants = is.getEnchantments();
|
||||
|
||||
if (enchants.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int rank = getArcaneForgingRank(Users.getProfile(player));
|
||||
|
||||
if (rank == 0 || !Permissions.getInstance().arcaneForging(player)) {
|
||||
for (Enchantment x : enchants.keySet()) {
|
||||
is.removeEnchantment(x);
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean downgraded = false;
|
||||
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
if (random.nextInt(100) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (Config.getInstance().getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
|
||||
if (random.nextInt(100) <= getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, enchantLevel--);
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
is.removeEnchantment(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> newEnchants = is.getEnchantments();
|
||||
|
||||
if (newEnchants.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail"));
|
||||
}
|
||||
else if (downgraded || newEnchants.size() < enchants.size()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets chance of keeping enchantment during repair.
|
||||
*
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of keeping the enchantment
|
||||
*/
|
||||
public static int getEnchantChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank4();
|
||||
|
||||
case 3:
|
||||
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank3();
|
||||
|
||||
case 2:
|
||||
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank2();
|
||||
|
||||
case 1:
|
||||
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank1();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets chance of enchantment being downgraded during repair.
|
||||
*
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of the enchantment being downgraded
|
||||
*/
|
||||
public static int getDowngradeChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return Config.getInstance().getArcaneForgingDowngradeChanceRank4();
|
||||
|
||||
case 3:
|
||||
return Config.getInstance().getArcaneForgingDowngradeChanceRank3();
|
||||
|
||||
case 2:
|
||||
return Config.getInstance().getArcaneForgingDowngradeChanceRank2();
|
||||
|
||||
case 1:
|
||||
return Config.getInstance().getArcaneForgingDowngradeChanceRank1();
|
||||
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param ramt The base amount of durability repaired to the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
private static short repairCalculate(Player player, short durability, int ramt) {
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
float bonus = (float) skillLevel / 500;
|
||||
|
||||
bonus = (ramt * bonus);
|
||||
ramt += bonus;
|
||||
|
||||
if (checkPlayerProcRepair(player)) {
|
||||
ramt = (short) (ramt * 2);
|
||||
}
|
||||
|
||||
durability -= ramt;
|
||||
|
||||
if (durability < 0) {
|
||||
durability = 0;
|
||||
}
|
||||
return durability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base durability amount to repair an item.
|
||||
*
|
||||
* @param is The item being repaired
|
||||
* @param player The player repairing the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
private static short getRepairAmount(ItemStack is, Player player){
|
||||
short maxDurability = is.getType().getMaxDurability();
|
||||
int ramt = 0;
|
||||
|
||||
if (ItemChecks.isShovel(is)) {
|
||||
ramt = maxDurability;
|
||||
}
|
||||
else if (ItemChecks.isHoe(is) || ItemChecks.isSword(is) || is.getType().equals(Material.SHEARS)) {
|
||||
ramt = maxDurability / 2;
|
||||
}
|
||||
else if (ItemChecks.isAxe(is) || ItemChecks.isMiningPick(is) || ItemChecks.isStringTool(is)) {
|
||||
ramt = maxDurability / 3;
|
||||
}
|
||||
else if (ItemChecks.isBoots(is)) {
|
||||
ramt = maxDurability / 4;
|
||||
}
|
||||
else if (ItemChecks.isHelmet(is)) {
|
||||
ramt = maxDurability / 5;
|
||||
}
|
||||
else if (ItemChecks.isPants(is)) {
|
||||
ramt = maxDurability / 7;
|
||||
}
|
||||
else if (ItemChecks.isChestplate(is)) {
|
||||
ramt = maxDurability / 8;
|
||||
}
|
||||
|
||||
return repairCalculate(player, is.getDurability(), ramt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs a player that the repair has failed.
|
||||
*
|
||||
* @param is The item being repaired
|
||||
* @param player The player repairing the item
|
||||
*/
|
||||
private static void needMoreVespeneGas(ItemStack is, Player player) {
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (is.getAmount() != 1) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
|
||||
}
|
||||
else {
|
||||
if (ItemChecks.isDiamondTool(is) || ItemChecks.isDiamondArmor(is)) {
|
||||
if (skillLevel < Config.getInstance().getRepairDiamondLevelRequirement()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptDiamond"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.BLUE + Misc.prettyItemString(Config.getInstance().getRepairDiamondMaterial()));
|
||||
}
|
||||
}
|
||||
else if (ItemChecks.isIronTool(is) || ItemChecks.isIronArmor(is)) {
|
||||
if (skillLevel < Config.getInstance().getRepairIronLevelRequirement()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptIron"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairIronMaterial()));
|
||||
}
|
||||
}
|
||||
else if (ItemChecks.isGoldTool(is) || ItemChecks.isGoldArmor(is)) {
|
||||
if (skillLevel < Config.getInstance().getRepairGoldLevelRequirement()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptGold"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GOLD + Misc.prettyItemString(Config.getInstance().getRepairGoldMaterial()));
|
||||
}
|
||||
}
|
||||
else if (ItemChecks.isStoneTool(is)) {
|
||||
if (skillLevel < Config.getInstance().getRepairStoneLevelRequirement()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptStone"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairStoneMaterial()));
|
||||
}
|
||||
}
|
||||
else if (ItemChecks.isWoodTool(is)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.DARK_GREEN + Misc.prettyItemString(Config.getInstance().getRepairWoodMaterial()));
|
||||
}
|
||||
else if (ItemChecks.isLeatherArmor(is)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairLeatherMaterial()));
|
||||
}
|
||||
else if (ItemChecks.isStringTool(is)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairStringMaterial()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Super Repair bonus.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @return true if bonus granted, false otherwise
|
||||
*/
|
||||
public static boolean checkPlayerProcRepair(Player player) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().repairBonus(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repairs an item.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @param item The item being repaired
|
||||
* @param repairMaterial The repair reagent
|
||||
*/
|
||||
public static void repairItem(Player player, ItemStack item, ItemStack repairMaterial) {
|
||||
short initialDurability = item.getDurability();
|
||||
short newDurability = getRepairAmount(item, player);
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (initialDurability - newDurability), repairMaterial, item);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (repairMaterial.getType().equals(Material.WOOD)) {
|
||||
removeWood(inventory);
|
||||
}
|
||||
else {
|
||||
inventory.removeItem(repairMaterial);
|
||||
}
|
||||
|
||||
/* Handle the enchants */
|
||||
if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.getInstance().arcaneBypass(player)) {
|
||||
addEnchants(player, item);
|
||||
}
|
||||
|
||||
item.setDurability(newDurability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
* @param player The player placing the anvil
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!PP.getPlacedAnvil()) {
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
|
||||
}
|
||||
|
||||
PP.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes wood from a player's inventory on repair. Needed due to wood having multiple possible data values.
|
||||
*
|
||||
* @param inventory The inventory to remove wood from
|
||||
*/
|
||||
private static void removeWood(PlayerInventory inventory) {
|
||||
//TODO: Make this less hackish once there's a better way to do it...
|
||||
int slot = inventory.first(Material.WOOD);
|
||||
ItemStack item = inventory.getItem(slot);
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
inventory.setItem(slot, item);
|
||||
}
|
||||
}
|
||||
95
src/main/java/com/gmail/nossr50/skills/combat/Archery.java
Normal file
95
src/main/java/com/gmail/nossr50/skills/combat/Archery.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Archery {
|
||||
private static Random random = new Random();
|
||||
public static Map<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
|
||||
/**
|
||||
* Track arrows fired for later retrieval.
|
||||
*
|
||||
* @param entity Entity damaged by the arrow
|
||||
* @param PPa PlayerProfile of the player firing the arrow
|
||||
*/
|
||||
public static void trackArrows(Entity entity, PlayerProfile PPa) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(1000) <= skillCheck) {
|
||||
for (Entry<Entity, Integer> entry : arrowTracker.entrySet()) {
|
||||
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
||||
entry.setValue(entry.getValue() + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
arrowTracker.put(entity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Daze.
|
||||
*
|
||||
* @param defender Defending player
|
||||
* @param attacker Attacking player
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void dazeCheck(Player defender, Player attacker, EntityDamageByEntityEvent event) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||
Location location = defender.getLocation();
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(10) > 5) {
|
||||
location.setPitch(90);
|
||||
}
|
||||
else {
|
||||
location.setPitch(-90);
|
||||
}
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck) {
|
||||
defender.teleport(location);
|
||||
event.setDamage(event.getDamage() + 4);
|
||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for arrow retrieval.
|
||||
*
|
||||
* @param entity The entity hit by the arrows
|
||||
*/
|
||||
public static void arrowRetrievalCheck(Entity entity) {
|
||||
for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
|
||||
Entry<Entity, Integer> entry = it.next();
|
||||
|
||||
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
||||
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Axes {
|
||||
@@ -50,11 +51,11 @@ public class Axes {
|
||||
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) entity;
|
||||
if (entity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) entity;
|
||||
|
||||
if (wolf.isTamed()) {
|
||||
AnimalTamer tamer = wolf.getOwner();
|
||||
if (pet.isTamed()) {
|
||||
AnimalTamer tamer = pet.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
@@ -79,8 +80,7 @@ public class Axes {
|
||||
|
||||
if (entity instanceof Player){
|
||||
event.setDamage((int) (damage * PVP_MODIFIER));
|
||||
Player player = (Player) entity;
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
}
|
||||
else {
|
||||
event.setDamage(damage * PVE_MODIFIER);
|
||||
@@ -110,7 +110,7 @@ public class Axes {
|
||||
durabilityDamage += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/30;
|
||||
|
||||
if (!hasArmor(targetPlayer)) {
|
||||
applyImpact(attacker, target, event);
|
||||
applyGreaterImpact(attacker, target, event);
|
||||
}
|
||||
else {
|
||||
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
|
||||
@@ -120,21 +120,25 @@ public class Axes {
|
||||
}
|
||||
}
|
||||
else {
|
||||
applyImpact(attacker, target, event); //Since mobs are technically unarmored, this will always trigger
|
||||
applyGreaterImpact(attacker, target, event); //Since mobs are technically unarmored, this will always trigger
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply impact ability.
|
||||
* Apply Greater Impact ability.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param event The event to modify
|
||||
*/
|
||||
private static void applyImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||
final int GREATER_IMPACT_CHANCE = 25;
|
||||
final double GREATER_IMPACT_MULTIPLIER = 1.5;
|
||||
|
||||
if (!Permissions.getInstance().greaterImpact(attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) {
|
||||
event.setDamage(event.getDamage() + 2);
|
||||
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -6,10 +6,8 @@ import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.entity.Tameable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -22,23 +20,21 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Swords {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Check for Bleed effect.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param entity The defending entity
|
||||
* @param plugin mcMMO plugin instance
|
||||
* @param defender The defending entity
|
||||
*/
|
||||
public static void bleedCheck(Player attacker, LivingEntity entity, mcMMO plugin) {
|
||||
public static void bleedCheck(Player attacker, LivingEntity defender) {
|
||||
|
||||
if (entity instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) entity;
|
||||
if (defender instanceof Tameable) {
|
||||
Tameable pet = (Tameable) defender;
|
||||
|
||||
if (wolf.isTamed()) {
|
||||
AnimalTamer tamer = wolf.getOwner();
|
||||
if (pet.isTamed()) {
|
||||
AnimalTamer tamer = pet.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
@@ -56,7 +52,7 @@ public class Swords {
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(1000) <= skillCheck && !entity.isDead()) {
|
||||
if (random.nextInt(1000) <= skillCheck && !defender.isDead()) {
|
||||
int bleedTicks = 0;
|
||||
|
||||
if (skillLevel >= 750) {
|
||||
@@ -66,7 +62,7 @@ public class Swords {
|
||||
bleedTicks = 2;
|
||||
}
|
||||
|
||||
BleedTimer.add(entity, bleedTicks);
|
||||
BleedTimer.add(defender, bleedTicks);
|
||||
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||
}
|
||||
}
|
||||
@@ -74,35 +70,30 @@ public class Swords {
|
||||
/**
|
||||
* Counter-attack entities.
|
||||
*
|
||||
* @param event The event to modify
|
||||
* @param attacker The attacking entity
|
||||
* @param defender The defending player
|
||||
* @param damage The amount of damage being countered
|
||||
*/
|
||||
public static void counterAttackChecks(EntityDamageByEntityEvent event) {
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
public static void counterAttackChecks(Entity attacker, Player defender, int damage) {
|
||||
if (!(attacker instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity target = event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
|
||||
final int MAX_BONUS_LEVEL = 600;
|
||||
final int COUNTER_ATTACK_MODIFIER = 2;
|
||||
|
||||
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
|
||||
final int MAX_BONUS_LEVEL = 600;
|
||||
final int COUNTER_ATTACK_MODIFIER = 2;
|
||||
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
if (random.nextInt(2000) <= skillCheck) {
|
||||
Combat.dealDamage((LivingEntity) attacker, damage / COUNTER_ATTACK_MODIFIER);
|
||||
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck) {
|
||||
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
|
||||
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
|
||||
}
|
||||
if (attacker instanceof Player) {
|
||||
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Taming {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
@@ -37,15 +36,14 @@ public class Taming {
|
||||
*
|
||||
* @param PPo The PlayerProfile of the wolf's owner
|
||||
* @param theWolf The wolf using the ability
|
||||
* @param event The event to modify
|
||||
* @param damage The damage being absorbed by the wolf
|
||||
*/
|
||||
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, EntityDamageEvent event) {
|
||||
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) {
|
||||
final int SKILL_ACTIVATION_LEVEL = 50;
|
||||
final int ACTIVATION_CHANCE = 50;
|
||||
|
||||
int health = theWolf.getHealth();
|
||||
int maxHealth = theWolf.getMaxHealth();
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
|
||||
if (health < maxHealth) {
|
||||
@@ -82,9 +80,8 @@ public class Taming {
|
||||
* @param PPo The PlayerProfile of the wolf's owner
|
||||
* @param event The event to modify
|
||||
* @param master The wolf's master
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO plugin) {
|
||||
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master) {
|
||||
final int GORE_MULTIPLIER = 2;
|
||||
|
||||
if (random.nextInt(1000) <= PPo.getSkillLevel(SkillType.TAMING)) {
|
||||
@@ -111,8 +108,7 @@ public class Taming {
|
||||
AnimalTamer tamer = beast.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
return owner.getName();
|
||||
return ((Player) tamer).getName();
|
||||
}
|
||||
else {
|
||||
return "Offline Master";
|
||||
@@ -132,6 +128,10 @@ public class Taming {
|
||||
final int THICK_FUR_MODIFIER = 2;
|
||||
final int SHOCK_PROOF_MODIFIER = 6;
|
||||
|
||||
if (!(event.getEntity() instanceof Wolf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DamageCause cause = event.getCause();
|
||||
Wolf wolf = (Wolf) event.getEntity();
|
||||
Player master = (Player) wolf.getOwner();
|
||||
@@ -257,7 +257,7 @@ public class Taming {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(summonItem.getId()));
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(summonItem.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Unarmed {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
@@ -54,10 +53,10 @@ public class Unarmed {
|
||||
ItemStack inHand = defender.getItemInHand();
|
||||
|
||||
if (!inHand.getType().equals(Material.AIR)) {
|
||||
if (random.nextInt(3000) <= skillCheck && ironGrip(defender, attacker)) {
|
||||
if (random.nextInt(3000) <= skillCheck && !ironGrip(defender, attacker)) {
|
||||
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
||||
|
||||
Misc.mcDropItem(defender.getLocation(), inHand);
|
||||
Misc.dropItem(defender.getLocation(), inHand);
|
||||
defender.setItemInHand(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
@@ -81,7 +80,14 @@ public class Unarmed {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ironGrip(Player defender, Player attacker) {
|
||||
/**
|
||||
* Check Iron Grip ability success
|
||||
*
|
||||
* @param defender The defending player
|
||||
* @param attacker The attacking player
|
||||
* @return true if the defender was not disarmed, false otherwise
|
||||
*/
|
||||
private static boolean ironGrip(Player defender, Player attacker) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -23,6 +23,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlastMining {
|
||||
@@ -51,7 +52,7 @@ public class BlastMining {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
|
||||
if (!temp.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(temp)) {
|
||||
for (int i = 1 ; i < extraDrops ; i++) {
|
||||
blocksDropped.add(temp);
|
||||
Mining.miningDrops(temp);
|
||||
@@ -102,7 +103,7 @@ public class BlastMining {
|
||||
while (iterator.hasNext()) {
|
||||
Block temp = iterator.next();
|
||||
|
||||
if (BlockChecks.isOre(temp.getType())) {
|
||||
if (BlockChecks.isOre(temp)) {
|
||||
ores.add(temp);
|
||||
}
|
||||
else {
|
||||
@@ -158,7 +159,7 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
for (Block block : xp) {
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
Mining.miningXP(player, block);
|
||||
}
|
||||
}
|
||||
@@ -236,6 +237,7 @@ public class BlastMining {
|
||||
/**
|
||||
* Detonate TNT for Blast Mining
|
||||
*
|
||||
* @param event The PlayerInteractEvent
|
||||
* @param player Player detonating the TNT
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
@@ -284,8 +286,8 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
/* Send message to nearby players */
|
||||
for(Player y : player.getWorld().getPlayers()) {
|
||||
if(y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
for (Player y : player.getWorld().getPlayers()) {
|
||||
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
y.sendMessage(ability.getAbilityPlayer(player));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -12,11 +12,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
@@ -28,28 +31,6 @@ public class Excavation {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Check to see if a block can be broken by Giga Drill Breaker.
|
||||
*
|
||||
* @param material The type of block to check
|
||||
* @return
|
||||
*/
|
||||
public static boolean canBeGigaDrillBroken(Material type) {
|
||||
switch (type) {
|
||||
case CLAY:
|
||||
case DIRT:
|
||||
case GRASS:
|
||||
case GRAVEL:
|
||||
case MYCEL:
|
||||
case SAND:
|
||||
case SOUL_SAND:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if treasures were found.
|
||||
*
|
||||
@@ -66,36 +47,43 @@ public class Excavation {
|
||||
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
int xp = Config.getInstance().getExcavationBaseXP();
|
||||
int xp;
|
||||
|
||||
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
xp = ModChecks.getCustomBlock(block).getXpGain();
|
||||
}
|
||||
else {
|
||||
xp = Config.getInstance().getExcavationBaseXP();
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().excavationTreasures(player)) {
|
||||
switch (type) {
|
||||
case DIRT:
|
||||
treasures = LoadTreasures.getInstance().excavationFromDirt;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromDirt;
|
||||
break;
|
||||
|
||||
case GRASS:
|
||||
treasures = LoadTreasures.getInstance().excavationFromGrass;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromGrass;
|
||||
break;
|
||||
|
||||
case SAND:
|
||||
treasures = LoadTreasures.getInstance().excavationFromSand;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromSand;
|
||||
break;
|
||||
|
||||
case GRAVEL:
|
||||
treasures = LoadTreasures.getInstance().excavationFromGravel;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromGravel;
|
||||
break;
|
||||
|
||||
case CLAY:
|
||||
treasures = LoadTreasures.getInstance().excavationFromClay;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromClay;
|
||||
break;
|
||||
|
||||
case MYCEL:
|
||||
treasures = LoadTreasures.getInstance().excavationFromMycel;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromMycel;
|
||||
break;
|
||||
|
||||
case SOUL_SAND:
|
||||
treasures = LoadTreasures.getInstance().excavationFromSoulSand;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromSoulSand;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -114,13 +102,13 @@ public class Excavation {
|
||||
//Drop items
|
||||
for (ItemStack x : is) {
|
||||
if (x != null) {
|
||||
Misc.mcDropItem(loc, x);
|
||||
Misc.dropItem(loc, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Handle XP related tasks
|
||||
PP.addXP(SkillType.EXCAVATION, xp);
|
||||
PP.addXP(player, SkillType.EXCAVATION, xp);
|
||||
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
|
||||
}
|
||||
|
||||
@@ -133,7 +121,7 @@ public class Excavation {
|
||||
public static void gigaDrillBreaker(Player player, Block block) {
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
@@ -26,6 +26,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Fishing {
|
||||
@@ -74,34 +76,34 @@ public class Fishing {
|
||||
|
||||
switch (getFishingLootTier(PP)) {
|
||||
case 1:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier1;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier2;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier2;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier3;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier3;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier4;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier4;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier5;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier5;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0) {
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
|
||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
|
||||
Users.getProfile(player).addXP(player, SkillType.FISHING, treasure.getXp());
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
}
|
||||
}
|
||||
@@ -115,7 +117,7 @@ public class Fishing {
|
||||
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||
PP.addXP(player, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||
Skills.XpCheckSkill(SkillType.FISHING, player);
|
||||
}
|
||||
|
||||
@@ -129,7 +131,7 @@ public class Fishing {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
getFishingResults(player, event);
|
||||
Item theCatch = (Item)event.getCaught();
|
||||
Item theCatch = (Item) event.getCaught();
|
||||
|
||||
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
|
||||
final int ENCHANTMENT_CHANCE = 10;
|
||||
@@ -138,7 +140,7 @@ public class Fishing {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
||||
if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
|
||||
if (random.nextInt(100) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
||||
@@ -185,91 +187,91 @@ public class Fishing {
|
||||
|
||||
switch (type) {
|
||||
case BLAZE:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD));
|
||||
Misc.dropItem(loc, new ItemStack(Material.BLAZE_ROD));
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
Misc.dropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.STRING));
|
||||
Misc.dropItem(loc, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
if (DROP_NUMBER > 66) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.FEATHER));
|
||||
Misc.dropItem(loc, new ItemStack(Material.FEATHER));
|
||||
}
|
||||
else if (DROP_NUMBER > 33) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN));
|
||||
Misc.dropItem(loc, new ItemStack(Material.RAW_CHICKEN));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.EGG));
|
||||
Misc.dropItem(loc, new ItemStack(Material.EGG));
|
||||
}
|
||||
break;
|
||||
|
||||
case COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
Misc.dropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
}
|
||||
else if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.LEATHER));
|
||||
Misc.dropItem(loc, new ItemStack(Material.LEATHER));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
Misc.dropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
Misc.dropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL));
|
||||
Misc.dropItem(loc, new ItemStack(Material.ENDER_PEARL));
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
Misc.dropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR));
|
||||
Misc.dropItem(loc, new ItemStack(Material.GHAST_TEAR));
|
||||
}
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM));
|
||||
Misc.dropItem(loc, new ItemStack(Material.MAGMA_CREAM));
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
Misc.dropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
}
|
||||
else if (DROP_NUMBER > 98) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
|
||||
Misc.dropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
|
||||
}
|
||||
else if (DROP_NUMBER > 66) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.LEATHER));
|
||||
Misc.dropItem(loc, new ItemStack(Material.LEATHER));
|
||||
}
|
||||
else if (DROP_NUMBER > 33) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
Misc.dropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
|
||||
Misc.dropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.PORK));
|
||||
Misc.dropItem(loc, new ItemStack(Material.PORK));
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
Misc.dropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET));
|
||||
Misc.dropItem(loc, new ItemStack(Material.GOLD_NUGGET));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -283,48 +285,48 @@ public class Fishing {
|
||||
ItemStack theWool = wool.toItemStack();
|
||||
theWool.setAmount(1 + random.nextInt(6));
|
||||
|
||||
Misc.mcDropItem(loc, theWool);
|
||||
Misc.dropItem(loc, theWool);
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.BONE));
|
||||
Misc.dropItem(loc, new ItemStack(Material.BONE));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItems(loc, new ItemStack(Material.ARROW), 3);
|
||||
Misc.dropItems(loc, new ItemStack(Material.ARROW), 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SLIME_BALL));
|
||||
Misc.dropItem(loc, new ItemStack(Material.SLIME_BALL));
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.PUMPKIN));
|
||||
Misc.dropItem(loc, new ItemStack(Material.PUMPKIN));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
|
||||
Misc.dropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
Misc.dropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.STRING));
|
||||
Misc.dropItem(loc, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
|
||||
Misc.dropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
Misc.dropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -13,13 +13,16 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Herbalism {
|
||||
@@ -41,9 +44,8 @@ public class Herbalism {
|
||||
}
|
||||
else if (hasSeeds && !block.getType().equals(Material.WHEAT)) {
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS));
|
||||
player.updateInventory();
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
greenTerraConvert(player, block);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,64 +53,18 @@ public class Herbalism {
|
||||
Material type = block.getType();
|
||||
|
||||
if (Misc.blockBreakSimulate(block, player, false)) {
|
||||
if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type.equals(Material.SMOOTH_BRICK)) {
|
||||
block.setData((byte) 0x1); //Set type of the brick to mossy
|
||||
if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type == Material.SMOOTH_BRICK && block.getData() == 0) {
|
||||
block.setTypeIdAndData(block.getTypeId(), (byte) 1, false); //Set type of the brick to mossy, force the client update
|
||||
}
|
||||
else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type.equals(Material.DIRT)) {
|
||||
else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type == Material.DIRT) {
|
||||
block.setType(Material.GRASS);
|
||||
}
|
||||
else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type.equals(Material.COBBLESTONE)) {
|
||||
else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type == Material.COBBLESTONE) {
|
||||
block.setType(Material.MOSSY_COBBLESTONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block can be made mossy.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @return true if the block can be made mossy, false otherwise
|
||||
*/
|
||||
public static Boolean makeMossy(Material type) {
|
||||
switch (type) {
|
||||
case COBBLESTONE:
|
||||
case DIRT:
|
||||
case SMOOTH_BRICK:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is affected by Herbalism abilities.
|
||||
*
|
||||
* @param type The type of Block to check
|
||||
* @return true if the block is affected, false otherwise
|
||||
*/
|
||||
public static Boolean canBeGreenTerra(Material type){
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
case CACTUS:
|
||||
case CROPS:
|
||||
case JACK_O_LANTERN:
|
||||
case MELON_BLOCK:
|
||||
case NETHER_WARTS:
|
||||
case PUMPKIN:
|
||||
case RED_MUSHROOM:
|
||||
case RED_ROSE:
|
||||
case SUGAR_CANE_BLOCK:
|
||||
case VINE:
|
||||
case WATER_LILY:
|
||||
case YELLOW_FLOWER:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for extra Herbalism drops.
|
||||
*
|
||||
@@ -128,14 +84,17 @@ public class Herbalism {
|
||||
Byte data = block.getData();
|
||||
Location loc = block.getLocation();
|
||||
Material mat = null;
|
||||
|
||||
int xp = 0;
|
||||
int catciDrops = 0;
|
||||
int caneDrops = 0;
|
||||
|
||||
boolean customPlant = false;
|
||||
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
case RED_MUSHROOM:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = Config.getInstance().getHerbalismXPMushrooms();
|
||||
}
|
||||
@@ -146,7 +105,7 @@ public class Herbalism {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
catciDrops++;
|
||||
}
|
||||
@@ -161,14 +120,14 @@ public class Herbalism {
|
||||
mat = Material.WHEAT;
|
||||
xp = Config.getInstance().getHerbalismXPWheat();
|
||||
|
||||
if (Config.getInstance().getHerbalismWheatRegrowth() && Permissions.getInstance().greenThumbWheat(player)) {
|
||||
if (Permissions.getInstance().greenThumbWheat(player)) {
|
||||
greenThumbWheat(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
mat = Material.MELON;
|
||||
xp = Config.getInstance().getHerbalismXPMelon();
|
||||
}
|
||||
@@ -183,7 +142,7 @@ public class Herbalism {
|
||||
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = Config.getInstance().getHerbalismXPPumpkin();
|
||||
}
|
||||
@@ -191,7 +150,7 @@ public class Herbalism {
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
mat = Material.getMaterial(id);
|
||||
xp = Config.getInstance().getHerbalismXPFlowers();
|
||||
}
|
||||
@@ -202,7 +161,7 @@ public class Herbalism {
|
||||
Block b = block.getRelative(0, y, 0);
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
caneDrops++;
|
||||
}
|
||||
@@ -213,50 +172,123 @@ public class Herbalism {
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
mat = type;
|
||||
xp = Config.getInstance().getHerbalismXPVines();
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
mat = type;
|
||||
xp = Config.getInstance().getHerbalismXPLilyPads();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
customPlant = true;
|
||||
xp = ModChecks.getCustomBlock(block).getXpGain();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (mat == null) {
|
||||
if (mat == null && !customPlant) {
|
||||
return;
|
||||
} else if (Permissions.getInstance().herbalismDoubleDrops(player)) {
|
||||
ItemStack is = new ItemStack(mat);
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().herbalismDoubleDrops(player)) {
|
||||
ItemStack is = null;
|
||||
|
||||
if (customPlant) {
|
||||
is = new ItemStack(ModChecks.getCustomBlock(block).getItemDrop());
|
||||
}
|
||||
else {
|
||||
is = new ItemStack(mat);
|
||||
}
|
||||
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
if (type.equals(Material.CACTUS)) {
|
||||
Misc.mcDropItems(loc, is, catciDrops);
|
||||
}
|
||||
else if (type.equals(Material.MELON_BLOCK)) {
|
||||
Misc.mcDropItems(loc, is, 3);
|
||||
Misc.mcRandomDropItems(loc, is, 50, 4);
|
||||
}
|
||||
else if (type.equals(Material.NETHER_WARTS)) {
|
||||
Misc.mcDropItems(loc, is, 2);
|
||||
Misc.mcRandomDropItems(loc, is, 50, 3);
|
||||
}
|
||||
else if (type.equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
Misc.mcDropItems(loc, is, caneDrops);
|
||||
}
|
||||
else {
|
||||
Misc.mcDropItem(loc, is);
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
if (configInstance.getBrownMushroomsDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case CACTUS:
|
||||
if (configInstance.getCactiDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, catciDrops);
|
||||
}
|
||||
break;
|
||||
|
||||
case CROPS:
|
||||
if (configInstance.getWheatDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (configInstance.getMelonsDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, 3);
|
||||
Misc.randomDropItems(loc, is, 50, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (configInstance.getNetherWartsDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, 2);
|
||||
Misc.randomDropItems(loc, is, 50, 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case PUMPKIN:
|
||||
if (configInstance.getPumpkinsDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case RED_MUSHROOM:
|
||||
if (configInstance.getRedMushroomsDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case SUGAR_CANE_BLOCK:
|
||||
if (configInstance.getSugarCaneDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, caneDrops);
|
||||
}
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (configInstance.getVinesDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (configInstance.getWaterLiliesDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case YELLOW_FLOWER:
|
||||
if (configInstance.getYellowFlowersDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (customPlant) {
|
||||
Misc.dropItem(loc, is);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.HERBALISM, xp);
|
||||
|
||||
PP.addXP(player, SkillType.HERBALISM, xp);
|
||||
Skills.XpCheckSkill(SkillType.HERBALISM, player);
|
||||
}
|
||||
|
||||
@@ -280,13 +312,13 @@ public class Herbalism {
|
||||
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Misc.mcDropItem(loc, new ItemStack(Material.WHEAT));
|
||||
Misc.mcRandomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
|
||||
Misc.dropItem(loc, new ItemStack(Material.WHEAT));
|
||||
Misc.randomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1);
|
||||
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS));
|
||||
player.updateInventory();
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +342,7 @@ public class Herbalism {
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcPlayerListener.GreenThumbFail"));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
386
src/main/java/com/gmail/nossr50/skills/gathering/Mining.java
Normal file
386
src/main/java/com/gmail/nossr50/skills/gathering/Mining.java
Normal file
@@ -0,0 +1,386 @@
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
public class Mining {
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Handle double drops when using Silk Touch.
|
||||
*
|
||||
* @param block The block to process drops for
|
||||
*/
|
||||
private static void silkTouchDrops(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
Material type = block.getType();
|
||||
ItemStack item = new ItemStack(type);
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
case ENDER_STONE:
|
||||
case GOLD_ORE:
|
||||
case IRON_ORE:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case OBSIDIAN:
|
||||
case SANDSTONE:
|
||||
miningDrops(block);
|
||||
break;
|
||||
|
||||
case COAL_ORE:
|
||||
if (configInstance.getCoalDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
if (configInstance.getDiamondDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (configInstance.getRedstoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
if (configInstance.getLapisDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
if (configInstance.getStoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop items from Mining & Blast Mining skills.
|
||||
*
|
||||
* @param block The block to process drops for
|
||||
*/
|
||||
public static void miningDrops(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
Material type = block.getType();
|
||||
ItemStack item = new ItemStack(type);
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
if (configInstance.getCoalDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
if (configInstance.getDiamondDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.DIAMOND);
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case ENDER_STONE:
|
||||
if (configInstance.getEndStoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (configInstance.getRedstoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.REDSTONE);
|
||||
Misc.dropItems(loc, item, 4);
|
||||
Misc.randomDropItem(loc, item, 50);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
Misc.dropItems(loc, item, 2);
|
||||
Misc.randomDropItems(loc, item, 50, 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
if (configInstance.getGoldDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case IRON_ORE:
|
||||
if (configInstance.getIronDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
if (configInstance.getLapisDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
|
||||
Misc.dropItems(loc, item, 4);
|
||||
Misc.randomDropItems(loc, item, 50, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case MOSSY_COBBLESTONE:
|
||||
if (configInstance.getMossyCobblestoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHERRACK:
|
||||
if (configInstance.getNetherrackDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case OBSIDIAN:
|
||||
if (configInstance.getObsidianDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case SANDSTONE:
|
||||
if (configInstance.getSandstoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
if (configInstance.getStoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.COBBLESTONE);
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||
Misc.dropItem(loc, item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Award XP for Mining blocks.
|
||||
*
|
||||
* @param player The player to award XP to
|
||||
* @param block The block to award XP for
|
||||
*/
|
||||
public static void miningXP(Player player, Block block) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Material type = block.getType();
|
||||
int xp = 0;
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
xp += Config.getInstance().getMiningXPCoalOre();
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
xp += Config.getInstance().getMiningXPDiamondOre();
|
||||
break;
|
||||
|
||||
case ENDER_STONE:
|
||||
xp += Config.getInstance().getMiningXPEndStone();
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
xp += Config.getInstance().getMiningXPRedstoneOre();
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
xp += Config.getInstance().getMiningXPGlowstone();
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
xp += Config.getInstance().getMiningXPGoldOre();
|
||||
break;
|
||||
|
||||
case IRON_ORE:
|
||||
xp += Config.getInstance().getMiningXPIronOre();
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
xp += Config.getInstance().getMiningXPLapisOre();
|
||||
break;
|
||||
|
||||
case MOSSY_COBBLESTONE:
|
||||
xp += Config.getInstance().getMiningXPMossyStone();
|
||||
break;
|
||||
|
||||
case NETHERRACK:
|
||||
xp += Config.getInstance().getMiningXPNetherrack();
|
||||
break;
|
||||
|
||||
case OBSIDIAN:
|
||||
xp += Config.getInstance().getMiningXPObsidian();
|
||||
break;
|
||||
|
||||
case SANDSTONE:
|
||||
xp += Config.getInstance().getMiningXPSandstone();
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
xp += Config.getInstance().getMiningXPStone();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
xp += ModChecks.getCustomBlock(block).getXpGain();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(player, SkillType.MINING, xp);
|
||||
Skills.XpCheckSkill(SkillType.MINING, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Mining block drops.
|
||||
*
|
||||
* @param player The player mining the block
|
||||
* @param block The block being broken
|
||||
*/
|
||||
public static void miningBlockCheck(Player player, Block block) {
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
miningXP(player, block);
|
||||
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(1000) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
silkTouchDrops(block);
|
||||
}
|
||||
else {
|
||||
miningDrops(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Super Breaker ability.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param block The block being affected
|
||||
*/
|
||||
public static void superBreakerBlockCheck(Player player, Block block) {
|
||||
Material type = block.getType();
|
||||
int tier = Misc.getTier(player.getItemInHand());
|
||||
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
if (ModChecks.getCustomBlock(block).getTier() < tier) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
|
||||
|
||||
miningBlockCheck(player, block);
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (type) {
|
||||
case OBSIDIAN:
|
||||
if (tier < 4) {
|
||||
return;
|
||||
}
|
||||
durabilityLoss = durabilityLoss * 5; //Obsidian needs to do more damage than normal
|
||||
/* FALL THROUGH */
|
||||
|
||||
case DIAMOND_ORE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GOLD_ORE:
|
||||
case LAPIS_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (tier < 3) {
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
|
||||
case IRON_ORE:
|
||||
if (tier < 2) {
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
|
||||
case COAL_ORE:
|
||||
case ENDER_STONE:
|
||||
case GLOWSTONE:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
|
||||
|
||||
miningBlockCheck(player, block);
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -15,12 +16,16 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
@@ -86,7 +91,33 @@ public class WoodCutting {
|
||||
|
||||
for (Block x : toBeFelled) {
|
||||
if (Misc.blockBreakSimulate(x, player, true)) {
|
||||
if (x.getType() == Material.LOG) {
|
||||
if (Config.getInstance().getBlockModsEnabled()) {
|
||||
CustomBlock block = ModChecks.getCustomBlock(x);
|
||||
item = block.getItemDrop();
|
||||
|
||||
if (ModChecks.isCustomLogBlock(x)) {
|
||||
if (!mcMMO.placeStore.isTrue(x)) {
|
||||
WoodCutting.woodCuttingProcCheck(player, x);
|
||||
xp = block.getXpGain();
|
||||
}
|
||||
|
||||
/* Remove the block */
|
||||
x.setData((byte) 0x0);
|
||||
x.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(x.getLocation(), item);
|
||||
}
|
||||
else if (ModChecks.isCustomLeafBlock(x)) {
|
||||
final int SAPLING_DROP_CHANCE = 10;
|
||||
|
||||
/* Remove the block */
|
||||
x.setData((byte) 0x0);
|
||||
x.setType(Material.AIR);
|
||||
|
||||
Misc.randomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
|
||||
}
|
||||
}
|
||||
else if (x.getType() == Material.LOG) {
|
||||
Tree tree = (Tree) x.getState().getData();
|
||||
TreeSpecies species = tree.getSpecies();
|
||||
|
||||
@@ -111,7 +142,7 @@ public class WoodCutting {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!x.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!mcMMO.placeStore.isTrue(x)) {
|
||||
WoodCutting.woodCuttingProcCheck(player, x);
|
||||
|
||||
switch (species) {
|
||||
@@ -141,13 +172,13 @@ public class WoodCutting {
|
||||
x.setType(Material.AIR);
|
||||
|
||||
/* Drop the block */
|
||||
Misc.mcDropItem(x.getLocation(), item);
|
||||
Misc.dropItem(x.getLocation(), item);
|
||||
}
|
||||
else if (x.getType() == Material.LEAVES) {
|
||||
final int SAPLING_DROP_CHANCE = 10;
|
||||
|
||||
item = new ItemStack(Material.SAPLING, 1, (short) 0, (byte) (x.getData() & 3)); //Drop the right type of sapling
|
||||
Misc.mcRandomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
|
||||
Misc.randomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
|
||||
|
||||
//Remove the block
|
||||
x.setData((byte) 0);
|
||||
@@ -156,25 +187,9 @@ public class WoodCutting {
|
||||
}
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
|
||||
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the block is affected by Tree Feller.
|
||||
*
|
||||
* @param block Block to check
|
||||
* @return true if the block is affected by Tree Feller, false otherwise
|
||||
*/
|
||||
private static boolean treeFellerCompatible(Block block) {
|
||||
switch (block.getType()) {
|
||||
case LOG:
|
||||
case LEAVES:
|
||||
case AIR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (Permissions.getInstance().woodcutting(player)) {
|
||||
PP.addXP(player, SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
|
||||
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,13 +202,16 @@ public class WoodCutting {
|
||||
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) {
|
||||
Material type = currentBlock.getType();
|
||||
|
||||
if(toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
|
||||
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.equals(Material.LOG) || type.equals(Material.LEAVES)) {
|
||||
toBeFelled.add(currentBlock);
|
||||
}
|
||||
else if (Config.getInstance().getBlockModsEnabled() && (ModChecks.isCustomLogBlock(currentBlock) || ModChecks.isCustomLeafBlock(currentBlock))) {
|
||||
toBeFelled.add(currentBlock);
|
||||
}
|
||||
|
||||
Block xPositive = currentBlock.getRelative(1, 0, 0);
|
||||
Block xNegative = currentBlock.getRelative(-1, 0, 0);
|
||||
@@ -201,26 +219,26 @@ public class WoodCutting {
|
||||
Block zNegative = currentBlock.getRelative(0, 0, -1);
|
||||
Block yPositive = currentBlock.getRelative(0, 1, 0);
|
||||
|
||||
if (!currentBlock.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (!isTooAggressive(currentBlock, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) {
|
||||
if (!mcMMO.placeStore.isTrue(currentBlock)) {
|
||||
if (!isTooAggressive(currentBlock, xPositive) && BlockChecks.treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) {
|
||||
processTreeFelling(xPositive, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) {
|
||||
if (!isTooAggressive(currentBlock, xNegative) && BlockChecks.treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) {
|
||||
processTreeFelling(xNegative, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) {
|
||||
if (!isTooAggressive(currentBlock, zPositive) && BlockChecks.treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) {
|
||||
processTreeFelling(zPositive, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) {
|
||||
if (!isTooAggressive(currentBlock, zNegative) && BlockChecks.treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) {
|
||||
processTreeFelling(zNegative, toBeFelled);
|
||||
}
|
||||
}
|
||||
|
||||
if (treeFellerCompatible(yPositive)) {
|
||||
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") && !toBeFelled.contains(yPositive)) {
|
||||
if (BlockChecks.treeFellerCompatible(yPositive)) {
|
||||
if(!mcMMO.placeStore.isTrue(currentBlock) && !toBeFelled.contains(yPositive)) {
|
||||
processTreeFelling(yPositive, toBeFelled);
|
||||
}
|
||||
}
|
||||
@@ -235,9 +253,9 @@ public class WoodCutting {
|
||||
*/
|
||||
private static boolean isTooAggressive(Block currentBlock, Block newBlock) {
|
||||
Material currentType = currentBlock.getType();
|
||||
Material newType = currentBlock.getType();
|
||||
Material newType = newBlock.getType();
|
||||
|
||||
if ((currentType.equals(Material.LEAVES) || currentType.equals(Material.AIR)) && (newType.equals(Material.LEAVES) || newType.equals(Material.AIR))) {
|
||||
if ((currentType.equals(Material.LEAVES) || currentType.equals(Material.AIR) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(currentBlock))) && (newType.equals(Material.LEAVES) || newType.equals(Material.AIR) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(currentBlock)))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -258,9 +276,54 @@ public class WoodCutting {
|
||||
byte type = block.getData();
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
||||
Tree tree = (Tree) block.getState().getData();
|
||||
TreeSpecies species = tree.getSpecies();
|
||||
|
||||
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
|
||||
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
|
||||
Misc.mcDropItem(block.getLocation(), item);
|
||||
Config configInstance = Config.getInstance();
|
||||
ItemStack item;
|
||||
Location location;
|
||||
|
||||
if (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
|
||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||
location = block.getLocation();
|
||||
Misc.dropItem(location, item);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
item = new ItemStack(mat, 1, (short) 0, type);
|
||||
location = block.getLocation();
|
||||
}
|
||||
|
||||
/* Drop the block */
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
if (configInstance.getOakDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
if (configInstance.getSpruceDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
if (configInstance.getBirchDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
if (configInstance.getJungleDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,33 +338,38 @@ public class WoodCutting {
|
||||
int xp = 0;
|
||||
TreeSpecies species = TreeSpecies.getByData(block.getData());
|
||||
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
xp += Config.getInstance().getWoodcuttingXPOak();
|
||||
break;
|
||||
if (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
|
||||
xp = ModChecks.getCustomBlock(block).getXpGain();
|
||||
}
|
||||
else {
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
xp += Config.getInstance().getWoodcuttingXPOak();
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
xp += Config.getInstance().getWoodcuttingXPSpruce();
|
||||
break;
|
||||
case REDWOOD:
|
||||
xp += Config.getInstance().getWoodcuttingXPSpruce();
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
xp += Config.getInstance().getWoodcuttingXPBirch();
|
||||
break;
|
||||
case BIRCH:
|
||||
xp += Config.getInstance().getWoodcuttingXPBirch();
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
xp += Config.getInstance().getWoodcuttingXPJungle();
|
||||
break;
|
||||
case JUNGLE:
|
||||
xp += Config.getInstance().getWoodcuttingXPJungle();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
PP.addXP(SkillType.WOODCUTTING, xp);
|
||||
PP.addXP(player, SkillType.WOODCUTTING, xp);
|
||||
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
|
||||
}
|
||||
|
||||
@@ -327,7 +395,7 @@ public class WoodCutting {
|
||||
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled) {
|
||||
int durabilityLoss = 0;
|
||||
for (Block x : toBeFelled) {
|
||||
if (x.getType().equals(Material.LOG)) {
|
||||
if (x.getType().equals(Material.LOG) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(x))) {
|
||||
durabilityLoss++;
|
||||
durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.misc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -12,10 +12,10 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Acrobatics {
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ public class Acrobatics {
|
||||
|
||||
/* Check for death */
|
||||
if (health - damage >= 1) {
|
||||
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER);
|
||||
PP.addXP(player, SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||
|
||||
event.setDamage(newDamage);
|
||||
@@ -76,7 +76,7 @@ public class Acrobatics {
|
||||
}
|
||||
}
|
||||
else if (health - damage >= 1) {
|
||||
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER);
|
||||
PP.addXP(player, SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class Acrobatics {
|
||||
defender.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
||||
|
||||
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
|
||||
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER);
|
||||
PPd.addXP(defender, SkillType.ACROBATICS, damage * DODGE_MODIFIER);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
|
||||
}
|
||||
|
||||
259
src/main/java/com/gmail/nossr50/skills/repair/Repair.java
Normal file
259
src/main/java/com/gmail/nossr50/skills/repair/Repair.java
Normal file
@@ -0,0 +1,259 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class Repair {
|
||||
|
||||
private static Random random = new Random();
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
/**
|
||||
* Handle the XP gain for repair events.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param PP PlayerProfile of the repairing player
|
||||
* @param is Item being repaired
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
* @param boost True if the modifier is a boost, false if the modifier is a reduction
|
||||
*/
|
||||
protected static void xpHandler(Player player, PlayerProfile PP, short durabilityBefore, short durabilityAfter, double modify) {
|
||||
short dif = (short) (durabilityBefore - durabilityAfter);
|
||||
|
||||
dif = (short) (dif * modify);
|
||||
|
||||
PP.addXP(player, SkillType.REPAIR, dif * 10);
|
||||
Skills.XpCheckSkill(SkillType.REPAIR, player);
|
||||
|
||||
//CLANG CLANG
|
||||
if (configInstance.spoutEnabled) {
|
||||
SpoutSounds.playRepairNoise(player, mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Arcane Forging rank.
|
||||
*
|
||||
* @param skillLevel The skill level of the player whose rank is being checked
|
||||
* @return The player's current Arcane Forging rank
|
||||
*/
|
||||
public static int getArcaneForgingRank(PlayerProfile PP) {
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel >= configInstance.getArcaneForgingRankLevels4()) {
|
||||
return 4;
|
||||
}
|
||||
else if (skillLevel >= configInstance.getArcaneForgingRankLevels3()) {
|
||||
return 3;
|
||||
}
|
||||
else if (skillLevel >= configInstance.getArcaneForgingRankLevels2()) {
|
||||
return 2;
|
||||
}
|
||||
else if (skillLevel >= configInstance.getArcaneForgingRankLevels1()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles removing & downgrading enchants.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param is Item being repaired
|
||||
*/
|
||||
protected static void addEnchants(Player player, ItemStack is) {
|
||||
Map<Enchantment, Integer> enchants = is.getEnchantments();
|
||||
|
||||
if (enchants.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int rank = getArcaneForgingRank(Users.getProfile(player));
|
||||
|
||||
if (rank == 0 || !permInstance.arcaneForging(player)) {
|
||||
for (Enchantment x : enchants.keySet()) {
|
||||
is.removeEnchantment(x);
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean downgraded = false;
|
||||
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
if (random.nextInt(100) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
|
||||
if (random.nextInt(100) <= getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, enchantLevel--);
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
is.removeEnchantment(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> newEnchants = is.getEnchantments();
|
||||
|
||||
if (newEnchants.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail"));
|
||||
}
|
||||
else if (downgraded || newEnchants.size() < enchants.size()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets chance of keeping enchantment during repair.
|
||||
*
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of keeping the enchantment
|
||||
*/
|
||||
public static int getEnchantChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return configInstance.getArcaneForgingKeepEnchantsChanceRank4();
|
||||
|
||||
case 3:
|
||||
return configInstance.getArcaneForgingKeepEnchantsChanceRank3();
|
||||
|
||||
case 2:
|
||||
return configInstance.getArcaneForgingKeepEnchantsChanceRank2();
|
||||
|
||||
case 1:
|
||||
return configInstance.getArcaneForgingKeepEnchantsChanceRank1();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets chance of enchantment being downgraded during repair.
|
||||
*
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of the enchantment being downgraded
|
||||
*/
|
||||
public static int getDowngradeChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return configInstance.getArcaneForgingDowngradeChanceRank4();
|
||||
|
||||
case 3:
|
||||
return configInstance.getArcaneForgingDowngradeChanceRank3();
|
||||
|
||||
case 2:
|
||||
return configInstance.getArcaneForgingDowngradeChanceRank2();
|
||||
|
||||
case 1:
|
||||
return configInstance.getArcaneForgingDowngradeChanceRank1();
|
||||
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @param skillLevel the skillLevel of the player in Repair
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
|
||||
float bonus = (float) skillLevel / 500;
|
||||
|
||||
if (permInstance.repairMastery(player)) {
|
||||
bonus = (repairAmount * bonus);
|
||||
repairAmount += bonus;
|
||||
}
|
||||
|
||||
if (checkPlayerProcRepair(player)) {
|
||||
repairAmount = (short) (repairAmount * 2);
|
||||
}
|
||||
|
||||
durability -= repairAmount;
|
||||
|
||||
if (durability < 0) {
|
||||
durability = 0;
|
||||
}
|
||||
|
||||
return durability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Super Repair bonus.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @return true if bonus granted, false otherwise
|
||||
*/
|
||||
public static boolean checkPlayerProcRepair(Player player) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && permInstance.repairBonus(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
* @param player The player placing the anvil
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!PP.getPlacedAnvil()) {
|
||||
if (configInstance.spoutEnabled) {
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
|
||||
}
|
||||
|
||||
PP.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public enum RepairItemType {
|
||||
ARMOR,
|
||||
TOOL,
|
||||
OTHER;
|
||||
|
||||
/**
|
||||
* Get the base permissions associated with this RepairItemType.
|
||||
*
|
||||
* @param player The player to check the permissions for
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case ARMOR:
|
||||
return Permissions.getInstance().armorRepair(player);
|
||||
case TOOL:
|
||||
return Permissions.getInstance().toolRepair(player);
|
||||
case OTHER:
|
||||
return Permissions.getInstance().otherRepair(player);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface RepairManager {
|
||||
/**
|
||||
* Register a repairable with the RepairManager
|
||||
*
|
||||
* @param repairable Repairable to register
|
||||
*/
|
||||
public void registerRepairable(Repairable repairable);
|
||||
|
||||
/**
|
||||
* Register a list of repairables with the RepairManager
|
||||
*
|
||||
* @param repairable List<Repairable> to register
|
||||
*/
|
||||
public void registerRepairables(List<Repairable> repairables);
|
||||
|
||||
/**
|
||||
* Checks if an item is repairable
|
||||
*
|
||||
* @param itemId id to check if repairable
|
||||
* @return true if repairable, false if not
|
||||
*/
|
||||
public boolean isRepairable(int itemId);
|
||||
|
||||
/**
|
||||
* Checks if an item is repairable
|
||||
*
|
||||
* @param itemStack Item to check if repairable
|
||||
* @return true if repairable, false if not
|
||||
*/
|
||||
public boolean isRepairable(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Gets the repairable with this id
|
||||
*
|
||||
* @param id Id of the repairable to look for
|
||||
* @return the repairable, can be null
|
||||
*/
|
||||
public Repairable getRepairable(int id);
|
||||
|
||||
/**
|
||||
* Handle the repairing of this object
|
||||
*
|
||||
* @param player Player that is repairing an item
|
||||
* @param item ItemStack that is being repaired
|
||||
*/
|
||||
public void handleRepair(Player player, ItemStack item);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public class RepairManagerFactory {
|
||||
public static RepairManager getRepairManager() {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairManager();
|
||||
}
|
||||
|
||||
public static RepairManager getRepairManager(int repairablesSize) {
|
||||
// TODO: Add in loading from config what type of manager we want.
|
||||
return new SimpleRepairManager(repairablesSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public enum RepairMaterialType {
|
||||
STRING,
|
||||
LEATHER,
|
||||
WOOD,
|
||||
STONE,
|
||||
IRON,
|
||||
GOLD,
|
||||
DIAMOND,
|
||||
OTHER;
|
||||
|
||||
/**
|
||||
* Get the base permissions associated with this RepairMaterialType.
|
||||
*
|
||||
* @param player The player to check the permissions for
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case STRING:
|
||||
return Permissions.getInstance().stringRepair(player);
|
||||
case LEATHER:
|
||||
return Permissions.getInstance().leatherRepair(player);
|
||||
case WOOD:
|
||||
return Permissions.getInstance().woodRepair(player);
|
||||
case STONE:
|
||||
return Permissions.getInstance().stoneRepair(player);
|
||||
case IRON:
|
||||
return Permissions.getInstance().ironRepair(player);
|
||||
case GOLD:
|
||||
return Permissions.getInstance().goldRepair(player);
|
||||
case DIAMOND:
|
||||
return Permissions.getInstance().diamondRepair(player);
|
||||
case OTHER:
|
||||
return Permissions.getInstance().otherMaterialRepair(player);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public interface Repairable {
|
||||
/**
|
||||
* Gets the item id of this repairable item
|
||||
*
|
||||
* @return the id of this repairable
|
||||
*/
|
||||
public int getItemId();
|
||||
|
||||
/**
|
||||
* Gets the id of the material used to repair this item
|
||||
*
|
||||
* @return the id of the repair material
|
||||
*/
|
||||
public int getRepairMaterialId();
|
||||
|
||||
/**
|
||||
* Gets the metadata byte value of the material used to repair this item
|
||||
*
|
||||
* @return the byte metadata of the repair material
|
||||
*/
|
||||
public byte getRepairMaterialMetadata();
|
||||
|
||||
/**
|
||||
* Gets the RepairItemType value for this repairable item
|
||||
*
|
||||
* @return the RepairItemType for this repairable
|
||||
*/
|
||||
public RepairItemType getRepairItemType();
|
||||
|
||||
/**
|
||||
* Gets the RepairMaterialType value for this repairable item
|
||||
*
|
||||
* @return the RepairMaterialType for this repairable
|
||||
*/
|
||||
public RepairMaterialType getRepairMaterialType();
|
||||
|
||||
/**
|
||||
* Gets the minimum quantity of repair materials ignoring all other repair bonuses
|
||||
*
|
||||
* This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords
|
||||
*
|
||||
* @return the minimum number of items
|
||||
*/
|
||||
public int getMinimumQuantity();
|
||||
|
||||
/**
|
||||
* Gets the maximum durability of this item before it breaks
|
||||
*
|
||||
* @return the maximum durability
|
||||
*/
|
||||
public short getMaximumDurability();
|
||||
|
||||
/**
|
||||
* Gets the base repair durability on which to calcuate bonuses.
|
||||
*
|
||||
* This is actually the maximum durability divided by the minimum quantity
|
||||
*
|
||||
* @return the base repair durability
|
||||
*/
|
||||
public short getBaseRepairDurability();
|
||||
|
||||
/**
|
||||
* Gets the minimum repair level needed to repair this item
|
||||
*
|
||||
* @return the minimum level to repair this item, or 0 for no minimum
|
||||
*/
|
||||
public int getMinimumLevel();
|
||||
|
||||
/**
|
||||
* Gets the xpMultiplier for this repairable
|
||||
*
|
||||
* @return the xpMultiplier of this repairable
|
||||
*/
|
||||
public double getXpMultiplier();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public class RepairableFactory {
|
||||
public static Repairable getRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumQuantity, short maximumDurability) {
|
||||
return getRepairable(itemId, repairMaterialId, repairMetadata, 0, minimumQuantity, maximumDurability, RepairItemType.OTHER, RepairMaterialType.OTHER, 1);
|
||||
}
|
||||
|
||||
public static Repairable getRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
|
||||
// TODO: Add in loading from config what type of repairable we want.
|
||||
return new SimpleRepairable(itemId, repairMaterialId, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SimpleRepairManager implements RepairManager {
|
||||
private HashMap<Integer, Repairable> repairables;
|
||||
|
||||
protected SimpleRepairManager() {
|
||||
this(55);
|
||||
}
|
||||
|
||||
protected SimpleRepairManager(int repairablesSize) {
|
||||
this.repairables = new HashMap<Integer, Repairable>(repairablesSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRepairable(Repairable repairable) {
|
||||
Integer itemId = repairable.getItemId();
|
||||
repairables.put(itemId, repairable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRepairables(List<Repairable> repairables) {
|
||||
for(Repairable repairable : repairables) {
|
||||
registerRepairable(repairable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(int itemId) {
|
||||
return repairables.containsKey(itemId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable(ItemStack itemStack) {
|
||||
return isRepairable(itemStack.getTypeId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repairable getRepairable(int id) {
|
||||
return repairables.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRepair(Player player, ItemStack item) {
|
||||
// Load some variables for use
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
short startDurability = item.getDurability();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
Repairable repairable = repairables.get(item.getTypeId());
|
||||
|
||||
// Permissions checks on material and item types
|
||||
if(!repairable.getRepairItemType().getPermissions(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!repairable.getRepairMaterialType().getPermissions(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Level check
|
||||
if(skillLevel < repairable.getMinimumLevel()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", new Object[] { String.valueOf(repairable.getMinimumLevel()), Misc.prettyItemString(item.getTypeId()) } ));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if they have the proper material to repair with
|
||||
if(!inventory.contains(repairable.getRepairMaterialId())) {
|
||||
String message = LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(repairable.getRepairMaterialId());
|
||||
if(repairable.getRepairMaterialMetadata() != (byte) -1) {
|
||||
// TODO: Do something nicer than append the metadata as a :# ?
|
||||
if(findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) {
|
||||
message += ":" + repairable.getRepairMaterialMetadata();
|
||||
}
|
||||
}
|
||||
player.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not repair if at full durability
|
||||
if(startDurability <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not repair stacked items
|
||||
if(item.getAmount() != 1) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Lets get down to business,
|
||||
// To defeat, the huns.
|
||||
int baseRepairAmount = repairable.getBaseRepairDurability();
|
||||
short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount);
|
||||
|
||||
// We're going to hold onto our repair item location
|
||||
int repairItemLocation;
|
||||
if(repairable.getRepairMaterialMetadata() == (byte) -1) {
|
||||
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId());
|
||||
} else {
|
||||
// Special case for when the repairable has metadata that must be addressed
|
||||
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata());
|
||||
}
|
||||
|
||||
// This should never happen, but if it does we need to complain loudly about it.
|
||||
if(repairItemLocation == -1) {
|
||||
player.sendMessage("mcMMO encountered an error attempting to repair this item!"); // TODO: Locale ?
|
||||
return;
|
||||
}
|
||||
|
||||
// Call event
|
||||
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle the enchants
|
||||
if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.getInstance().arcaneBypass(player)) {
|
||||
// Generalize away enchantment work
|
||||
Repair.addEnchants(player, item);
|
||||
}
|
||||
|
||||
// Remove the item
|
||||
removeOneFrom(inventory, repairItemLocation);
|
||||
|
||||
// Give out XP like candy
|
||||
Repair.xpHandler(player, PP, startDurability, newDurability, repairable.getXpMultiplier());
|
||||
|
||||
// Repair the item!
|
||||
item.setDurability(newDurability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the amount of items in this slot by one
|
||||
*
|
||||
* @param inventory PlayerInventory to work in
|
||||
* @param index Item index to decrement
|
||||
*/
|
||||
private void removeOneFrom(PlayerInventory inventory, int index) {
|
||||
ItemStack item = inventory.getItem(index);
|
||||
if(item.getAmount() > 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
} else {
|
||||
item = new ItemStack(0);
|
||||
}
|
||||
|
||||
// I suspect this may not be needed, but I don't think it hurts
|
||||
inventory.setItem(index, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the inventory for an item and return the index.
|
||||
*
|
||||
* @param inventory PlayerInventory to scan
|
||||
* @param itemId Item id to look for
|
||||
* @return index location where the item was found, or -1 if not found
|
||||
*/
|
||||
private int findInInventory(PlayerInventory inventory, int itemId) {
|
||||
int location = inventory.first(itemId);
|
||||
// VALIDATE
|
||||
if(inventory.getItem(location).getTypeId() == itemId) {
|
||||
return location;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the inventory for an item and return the index.
|
||||
*
|
||||
* @param inventory PlayerInventory to scan
|
||||
* @param itemId Item id to look for
|
||||
* @param metadata Metadata to look for
|
||||
* @return index location where the item was found, or -1 if not found
|
||||
*/
|
||||
private int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
|
||||
int location = -1;
|
||||
|
||||
ItemStack[] contents = inventory.getContents();
|
||||
for(int i = 0; i < contents.length; i++) {
|
||||
ItemStack item = contents[i];
|
||||
if(item.getTypeId() == itemId) {
|
||||
if(item.getData().getData() == metadata) {
|
||||
location = i;
|
||||
}
|
||||
}
|
||||
if(location != -1) break;
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
public class SimpleRepairable implements Repairable {
|
||||
private final int itemId, repairMaterialId, minimumQuantity, minimumLevel;
|
||||
private final short maximumDurability, baseRepairDurability;
|
||||
private final byte repairMetadata;
|
||||
private final RepairItemType repairItemType;
|
||||
private final RepairMaterialType repairMaterialType;
|
||||
private final double xpMultiplier;
|
||||
|
||||
protected SimpleRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
|
||||
this.itemId = itemId;
|
||||
this.repairMaterialId = repairMaterialId;
|
||||
this.repairMetadata = repairMetadata;
|
||||
this.repairItemType = repairItemType;
|
||||
this.repairMaterialType = repairMaterialType;
|
||||
this.minimumLevel = minimumLevel;
|
||||
this.minimumQuantity = minimumQuantity;
|
||||
this.maximumDurability = maximumDurability;
|
||||
this.baseRepairDurability = (short) (maximumDurability / minimumQuantity);
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRepairMaterialId() {
|
||||
return repairMaterialId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRepairMaterialMetadata() {
|
||||
return repairMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepairItemType getRepairItemType() {
|
||||
return repairItemType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepairMaterialType getRepairMaterialType() {
|
||||
return repairMaterialType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumQuantity() {
|
||||
return minimumQuantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getMaximumDurability() {
|
||||
return maximumDurability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getBaseRepairDurability() {
|
||||
return baseRepairDurability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumLevel() {
|
||||
return minimumLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getXpMultiplier() {
|
||||
return xpMultiplier;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import com.gmail.nossr50.util.Users;
|
||||
public class SpoutStuff {
|
||||
private static mcMMO plugin = mcMMO.p;
|
||||
|
||||
public final static String spoutDirectory = mcMMO.mainDirectory + "Resources" + File.separator;
|
||||
public final static String spoutDirectory = plugin.mainDirectory + "Resources" + File.separator;
|
||||
public final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
|
||||
public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
|
||||
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
||||
@@ -59,7 +59,7 @@ public class SpoutStuff {
|
||||
try {
|
||||
File currentFile = new File(theFilePath + theFileName);
|
||||
|
||||
JarFile jar = new JarFile(mcMMO.mcmmo);
|
||||
JarFile jar = new JarFile(plugin.mcmmo);
|
||||
JarEntry entry = jar.getJarEntry("resources/" + theFileName);
|
||||
InputStream is = jar.getInputStream(entry);
|
||||
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
|
||||
public class BlockChecks {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||
|
||||
/**
|
||||
* Checks to see if a block type awards XP.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @param block Block to check
|
||||
* @return true if the block type awards XP, false otherwise
|
||||
*/
|
||||
public static boolean shouldBeWatched(Material material) {
|
||||
switch (material) {
|
||||
public static boolean shouldBeWatched(Block block) {
|
||||
switch (block.getType()) {
|
||||
case BROWN_MUSHROOM:
|
||||
case CACTUS:
|
||||
case CLAY:
|
||||
@@ -27,7 +33,6 @@ public class BlockChecks {
|
||||
case GRASS:
|
||||
case GRAVEL:
|
||||
case IRON_ORE:
|
||||
case JACK_O_LANTERN:
|
||||
case LAPIS_ORE:
|
||||
case LOG:
|
||||
case MELON_BLOCK:
|
||||
@@ -50,18 +55,23 @@ public class BlockChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customItems.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block should allow for the activation of abilities.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @param block Block to check
|
||||
* @return true if the block should allow ability activation, false otherwise
|
||||
*/
|
||||
public static boolean abilityBlockCheck(Material material) {
|
||||
switch (material) {
|
||||
public static boolean abilityBlockCheck(Block block) {
|
||||
switch (block.getType()) {
|
||||
case BED_BLOCK:
|
||||
case BREWING_STAND:
|
||||
case BOOKSHELF:
|
||||
@@ -82,12 +92,9 @@ public class BlockChecks {
|
||||
case WOODEN_DOOR:
|
||||
case WORKBENCH:
|
||||
return false;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (Material.getMaterial(Config.getInstance().getRepairAnvilId()).equals(material)) {
|
||||
if (block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
@@ -98,11 +105,11 @@ public class BlockChecks {
|
||||
/**
|
||||
* Check if a block type is an ore.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @param block Block to check
|
||||
* @return true if the Block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(Material material) {
|
||||
switch (material) {
|
||||
public static boolean isOre(Block block) {
|
||||
switch (block.getType()) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
@@ -113,6 +120,164 @@ public class BlockChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customBlocksEnabled && ModChecks.isCustomOreBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block can be made mossy.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block can be made mossy, false otherwise
|
||||
*/
|
||||
public static boolean makeMossy(Block block) {
|
||||
switch (block.getType()) {
|
||||
case COBBLESTONE:
|
||||
case DIRT:
|
||||
return true;
|
||||
case SMOOTH_BRICK:
|
||||
if (block.getData() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is affected by Herbalism abilities.
|
||||
*
|
||||
* @param block Block to check
|
||||
* @return true if the block is affected, false otherwise
|
||||
*/
|
||||
public static boolean canBeGreenTerra(Block block){
|
||||
switch (block.getType()) {
|
||||
case BROWN_MUSHROOM:
|
||||
case CACTUS:
|
||||
case MELON_BLOCK:
|
||||
case NETHER_WARTS:
|
||||
case PUMPKIN:
|
||||
case RED_MUSHROOM:
|
||||
case RED_ROSE:
|
||||
case SUGAR_CANE_BLOCK:
|
||||
case VINE:
|
||||
case WATER_LILY:
|
||||
case YELLOW_FLOWER:
|
||||
return true;
|
||||
|
||||
case CROPS:
|
||||
if (block.getData() == CropState.RIPE.getData()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
default:
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a block is broken by Super Breaker.
|
||||
*
|
||||
* @param block Block to check
|
||||
* @return true if the block would be broken by Super Breaker, false otherwise
|
||||
*/
|
||||
public static Boolean canBeSuperBroken(Block block) {
|
||||
switch (block.getType()) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case ENDER_STONE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GLOWSTONE:
|
||||
case GOLD_ORE:
|
||||
case IRON_ORE:
|
||||
case LAPIS_ORE:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case NETHERRACK:
|
||||
case OBSIDIAN:
|
||||
case REDSTONE_ORE:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a block can be broken by Giga Drill Breaker.
|
||||
*
|
||||
* @param block Block to check
|
||||
* @return true if the block can be broken by Giga Drill Breaker, false otherwise
|
||||
*/
|
||||
public static boolean canBeGigaDrillBroken(Block block) {
|
||||
switch (block.getType()) {
|
||||
case CLAY:
|
||||
case DIRT:
|
||||
case GRASS:
|
||||
case GRAVEL:
|
||||
case MYCEL:
|
||||
case SAND:
|
||||
case SOUL_SAND:
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the block is affected by Tree Feller.
|
||||
*
|
||||
* @param block Block to check
|
||||
* @return true if the block is affected by Tree Feller, false otherwise
|
||||
*/
|
||||
public static boolean treeFellerCompatible(Block block) {
|
||||
switch (block.getType()) {
|
||||
case LOG:
|
||||
case LEAVES:
|
||||
case AIR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLog (Block block){
|
||||
if (block.getType().equals(Material.LOG) || (customBlocksEnabled && ModChecks.isCustomLogBlock(block))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ package com.gmail.nossr50.util;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@@ -27,15 +28,16 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.GainXp;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Archery;
|
||||
import com.gmail.nossr50.skills.Axes;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Swords;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.Unarmed;
|
||||
import com.gmail.nossr50.skills.combat.Archery;
|
||||
import com.gmail.nossr50.skills.combat.Axes;
|
||||
import com.gmail.nossr50.skills.combat.Swords;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.combat.Unarmed;
|
||||
import com.gmail.nossr50.skills.misc.Acrobatics;
|
||||
|
||||
public class Combat {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
/**
|
||||
* Apply combat modifiers and process and XP gain.
|
||||
@@ -50,101 +52,171 @@ public class Combat {
|
||||
|
||||
Entity damager = event.getDamager();
|
||||
LivingEntity target = (LivingEntity) event.getEntity();
|
||||
EntityType damagerType = damager.getType();
|
||||
EntityType targetType = target.getType();
|
||||
|
||||
switch (damagerType) {
|
||||
case PLAYER:
|
||||
boolean targetIsPlayer = target instanceof Player;
|
||||
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
|
||||
|
||||
if (damager instanceof Player) {
|
||||
Player attacker = (Player) event.getDamager();
|
||||
ItemStack itemInHand = attacker.getItemInHand();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
combatAbilityChecks(attacker);
|
||||
|
||||
if (ItemChecks.isSword(itemInHand) && Permissions.getInstance().swords(attacker)) {
|
||||
if (Permissions.getInstance().swordsBleed(attacker)) {
|
||||
Swords.bleedCheck(attacker, target, plugin);
|
||||
if (ItemChecks.isSword(itemInHand) && permInstance.swords(attacker)) {
|
||||
if (!configInstance.getSwordsPVP()) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.getInstance().serratedStrikes(attacker)) {
|
||||
if (!configInstance.getSwordsPVE()) {
|
||||
if (!targetIsPlayer || !targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (permInstance.swordsBleed(attacker)) {
|
||||
Swords.bleedCheck(attacker, target);
|
||||
}
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && permInstance.serratedStrikes(attacker)) {
|
||||
applyAbilityAoE(attacker, target, event.getDamage() / 4, plugin, SkillType.SWORDS);
|
||||
BleedTimer.add(target, 5);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
|
||||
}
|
||||
else if (ItemChecks.isAxe(itemInHand) && Permissions.getInstance().axes(attacker)) {
|
||||
if (Permissions.getInstance().axeBonus(attacker)) {
|
||||
else if (ItemChecks.isAxe(itemInHand) && permInstance.axes(attacker)) {
|
||||
if (!configInstance.getAxesPVP()) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!configInstance.getAxesPVE()) {
|
||||
if (!targetIsPlayer || !targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (permInstance.axeBonus(attacker)) {
|
||||
Axes.axesBonus(attacker, event);
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().criticalHit(attacker)) {
|
||||
if (permInstance.criticalHit(attacker)) {
|
||||
Axes.axeCriticalCheck(attacker, event);
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().impact(attacker)) {
|
||||
if (permInstance.impact(attacker)) {
|
||||
Axes.impact(attacker, target, event);
|
||||
}
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.getInstance().skullSplitter(attacker)) {
|
||||
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
|
||||
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
|
||||
}
|
||||
else if (itemInHand.getType().equals(Material.AIR) && Permissions.getInstance().unarmed(attacker)) {
|
||||
if (Permissions.getInstance().unarmedBonus(attacker)) {
|
||||
else if (itemInHand.getType().equals(Material.AIR) && permInstance.unarmed(attacker)) {
|
||||
if (!configInstance.getUnarmedPVP()) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!configInstance.getUnarmedPVE()) {
|
||||
if (!targetIsPlayer || !targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (permInstance.unarmedBonus(attacker)) {
|
||||
Unarmed.unarmedBonus(PPa, event);
|
||||
}
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.BERSERK) && Permissions.getInstance().berserk(attacker)) {
|
||||
if (PPa.getAbilityMode(AbilityType.BERSERK) && permInstance.berserk(attacker)) {
|
||||
event.setDamage((int) (event.getDamage() * 1.5));
|
||||
}
|
||||
|
||||
if (targetType.equals(EntityType.PLAYER) && Permissions.getInstance().disarm(attacker)) {
|
||||
if (targetIsPlayer && permInstance.disarm(attacker)) {
|
||||
Unarmed.disarmProcCheck(attacker, (Player) target);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
|
||||
}
|
||||
else if (itemInHand.getType().equals(Material.BONE) && Permissions.getInstance().beastLore(attacker)) {
|
||||
else if (itemInHand.getType().equals(Material.BONE) && permInstance.beastLore(attacker)) {
|
||||
Taming.beastLore(event, target, attacker);
|
||||
}
|
||||
break;
|
||||
|
||||
case WOLF:
|
||||
}
|
||||
else if (damager instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) damager;
|
||||
|
||||
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
||||
Player master = (Player) wolf.getOwner();
|
||||
PlayerProfile PPo = Users.getProfile(master);
|
||||
|
||||
if (Permissions.getInstance().taming(master)) {
|
||||
if (Permissions.getInstance().fastFoodService(master)) {
|
||||
Taming.fastFoodService(PPo, wolf, event);
|
||||
if (!configInstance.getTamingPVP()) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().sharpenedclaws(master)) {
|
||||
Taming.sharpenedClaws(PPo, event);
|
||||
if (!configInstance.getTamingPVE()) {
|
||||
if (!targetIsPlayer || !targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().gore(master)) {
|
||||
Taming.gore(PPo, event, master, plugin);
|
||||
}
|
||||
if (permInstance.fastFoodService(master)) {
|
||||
Taming.fastFoodService(PPo, wolf, event.getDamage());
|
||||
}
|
||||
|
||||
if (permInstance.sharpenedClaws(master)) {
|
||||
Taming.sharpenedClaws(PPo, event);
|
||||
}
|
||||
|
||||
if (permInstance.gore(master)) {
|
||||
Taming.gore(PPo, event, master);
|
||||
}
|
||||
|
||||
if (permInstance.taming(master)) {
|
||||
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (damager instanceof Projectile) {
|
||||
if (!configInstance.getArcheryPVP() && ((Projectile) damager).getShooter().getType().equals(EntityType.PLAYER)) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
case ARROW:
|
||||
archeryCheck((EntityDamageByEntityEvent) event, plugin);
|
||||
break;
|
||||
if (!configInstance.getArcheryPVE() && !((Projectile) damager).getShooter().getType().equals(EntityType.PLAYER)) {
|
||||
if (!targetIsPlayer || !targetIsTamedPet) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
archeryCheck(event, plugin);
|
||||
}
|
||||
|
||||
if (targetType.equals(EntityType.PLAYER)) {
|
||||
Swords.counterAttackChecks(event);
|
||||
Acrobatics.dodgeChecks(event);
|
||||
if (target instanceof Player) {
|
||||
if (configInstance.getSwordsPVP() && damager instanceof Player) {
|
||||
Swords.counterAttackChecks(damager, (Player) target, event.getDamage());
|
||||
}
|
||||
|
||||
if (configInstance.getSwordsPVE() && !(damager instanceof Player)) {
|
||||
Swords.counterAttackChecks(damager, (Player) target, event.getDamage());
|
||||
}
|
||||
|
||||
if (configInstance.getAcrobaticsPVP() && damager instanceof Player) {
|
||||
Acrobatics.dodgeChecks(event);
|
||||
}
|
||||
|
||||
if (configInstance.getAcrobaticsPVE() && !(damager instanceof Player)) {
|
||||
Acrobatics.dodgeChecks(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,55 +246,53 @@ public class Combat {
|
||||
* @param pluginx mcMMO plugin instance
|
||||
*/
|
||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) {
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
Projectile arrow = (Projectile) event.getDamager();
|
||||
LivingEntity shooter = arrow.getShooter();
|
||||
LivingEntity target = (LivingEntity) event.getEntity();
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (Permissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) {
|
||||
Unarmed.deflectCheck(defender, event);
|
||||
if (defender.getItemInHand().getType().equals(Material.AIR)) {
|
||||
if (configInstance.getUnarmedPVP()) {
|
||||
Unarmed.deflectCheck(defender, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shooter instanceof Player) {
|
||||
Player attacker = (Player) shooter;
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (Permissions.getInstance().archery(attacker) && damage > 0) {
|
||||
if (permInstance.archery(attacker)) {
|
||||
if (permInstance.archeryBonus(attacker)) {
|
||||
/*Archery needs a damage bonus to be viable in PVP*/
|
||||
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
||||
|
||||
/*Archery needs a damage bonus to be viable in PVP*/
|
||||
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
||||
|
||||
/* Cap maximum bonus at 200% */
|
||||
if(dmgBonusPercent > 2)
|
||||
dmgBonusPercent = 2;
|
||||
|
||||
/* Every 100 skill levels Archery gains 20% damage bonus, set that here */
|
||||
//TODO: Work in progress for balancing out Archery, will work on it more later...
|
||||
//TODO: Right now this is calculating a 10% bonus every 50 levels, not 20% every 100. Is this intended?
|
||||
int archeryBonus = (int)(event.getDamage() * dmgBonusPercent);
|
||||
event.setDamage(event.getDamage() + archeryBonus);
|
||||
|
||||
if (Permissions.getInstance().trackArrows(attacker)) {
|
||||
Archery.trackArrows(pluginx, target, PPa);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
/* Cap maximum bonus at 200% */
|
||||
if (dmgBonusPercent > 2) {
|
||||
dmgBonusPercent = 2;
|
||||
}
|
||||
|
||||
Archery.dazeCheck(defender, attacker);
|
||||
/* Every 50 skill levels Archery gains 10% damage bonus, set that here */
|
||||
//TODO: Work in progress for balancing out Archery, will work on it more later...
|
||||
int damage = event.getDamage();
|
||||
int archeryBonus = (int) (damage * dmgBonusPercent);
|
||||
|
||||
event.setDamage(damage + archeryBonus);
|
||||
}
|
||||
|
||||
if (target instanceof Player && permInstance.daze(attacker)) {
|
||||
Archery.dazeCheck((Player) target, attacker, event);
|
||||
}
|
||||
|
||||
if (permInstance.trackArrows(attacker)) {
|
||||
Archery.trackArrows(target, PPa);
|
||||
}
|
||||
|
||||
if (target != attacker) {
|
||||
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,7 +316,7 @@ public class Combat {
|
||||
* @param cause DamageCause to pass to damage event
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
||||
if (Config.getInstance().getEventCallbackEnabled()) {
|
||||
if (configInstance.getEventCallbackEnabled()) {
|
||||
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||
|
||||
@@ -269,7 +339,7 @@ public class Combat {
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
||||
if (Config.getInstance().getEventCallbackEnabled()) {
|
||||
if (configInstance.getEventCallbackEnabled()) {
|
||||
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||
|
||||
@@ -294,6 +364,12 @@ public class Combat {
|
||||
* @param type The type of skill being used
|
||||
*/
|
||||
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
||||
ItemStack inHand = attacker.getItemInHand();
|
||||
|
||||
if (ModChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
||||
int damageAmount = damage;
|
||||
|
||||
@@ -305,64 +381,62 @@ public class Combat {
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (numberOfTargets <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (entity.getType()) {
|
||||
case WOLF:
|
||||
AnimalTamer tamer = ((Wolf) entity).getOwner();
|
||||
|
||||
if (entity instanceof Player) {
|
||||
Player defender = (Player) entity;
|
||||
|
||||
if (!target.getWorld().getPVP()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (defender.getName().equals(attacker.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Party.getInstance().inSameParty(attacker, defender)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = Users.getProfile((Player) entity);
|
||||
|
||||
if (playerProfile.getGodMode()) {
|
||||
continue;
|
||||
}
|
||||
} else if (entity instanceof Tameable) {
|
||||
AnimalTamer tamer = ((Tameable) entity).getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
if (tamer.equals(attacker) || Party.getInstance().inSameParty(attacker, (Player) tamer)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case PLAYER:
|
||||
Player defender = (Player) entity;
|
||||
|
||||
if (!target.getWorld().getPVP()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (defender.getName().equals(attacker.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Party.getInstance().inSameParty(attacker, defender)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = Users.getProfile((Player) entity);
|
||||
|
||||
if (playerProfile.getGodMode()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (type) {
|
||||
case SWORDS:
|
||||
if (entity instanceof Player) {
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
|
||||
}
|
||||
|
||||
|
||||
BleedTimer.add((LivingEntity) entity, 5);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case AXES:
|
||||
if (entity instanceof Player) {
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
dealDamage((LivingEntity) entity, damageAmount, attacker);
|
||||
numberOfTargets--;
|
||||
}
|
||||
@@ -381,7 +455,7 @@ public class Combat {
|
||||
double baseXP = 0;
|
||||
|
||||
if (target instanceof Player) {
|
||||
if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
|
||||
if (!configInstance.getExperienceGainsPlayerVersusPlayerEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -389,72 +463,72 @@ public class Combat {
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) {
|
||||
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
|
||||
baseXP = 20 * configInstance.getPlayerVersusPlayerXP();
|
||||
}
|
||||
}
|
||||
else if (!target.hasMetadata("mcmmoFromMobSpawner")) {
|
||||
if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) {
|
||||
baseXP = Config.getInstance().getAnimalsXP();
|
||||
baseXP = configInstance.getAnimalsXP();
|
||||
}
|
||||
else {
|
||||
EntityType type = target.getType();
|
||||
|
||||
switch (type) {
|
||||
case BLAZE:
|
||||
baseXP = Config.getInstance().getBlazeXP();
|
||||
baseXP = configInstance.getBlazeXP();
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
baseXP = Config.getInstance().getCaveSpiderXP();
|
||||
baseXP = configInstance.getCaveSpiderXP();
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
baseXP = Config.getInstance().getCreeperXP();
|
||||
baseXP = configInstance.getCreeperXP();
|
||||
break;
|
||||
|
||||
case ENDER_DRAGON:
|
||||
baseXP = Config.getInstance().getEnderDragonXP();
|
||||
baseXP = configInstance.getEnderDragonXP();
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
baseXP = Config.getInstance().getEndermanXP();
|
||||
baseXP = configInstance.getEndermanXP();
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
baseXP = Config.getInstance().getGhastXP();
|
||||
baseXP = configInstance.getGhastXP();
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
baseXP = Config.getInstance().getMagmaCubeXP();
|
||||
baseXP = configInstance.getMagmaCubeXP();
|
||||
break;
|
||||
|
||||
case IRON_GOLEM:
|
||||
if (!((IronGolem) target).isPlayerCreated())
|
||||
baseXP = Config.getInstance().getIronGolemXP();
|
||||
baseXP = configInstance.getIronGolemXP();
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
baseXP = Config.getInstance().getPigZombieXP();
|
||||
baseXP = configInstance.getPigZombieXP();
|
||||
break;
|
||||
|
||||
case SILVERFISH:
|
||||
baseXP = Config.getInstance().getSilverfishXP();
|
||||
baseXP = configInstance.getSilverfishXP();
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
baseXP = Config.getInstance().getSkeletonXP();
|
||||
baseXP = configInstance.getSkeletonXP();
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
baseXP = Config.getInstance().getSlimeXP();
|
||||
baseXP = configInstance.getSlimeXP();
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
baseXP = Config.getInstance().getSpiderXP();
|
||||
baseXP = configInstance.getSpiderXP();
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
baseXP = Config.getInstance().getZombieXP();
|
||||
baseXP = configInstance.getZombieXP();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.sql.PreparedStatement;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
||||
@@ -64,7 +63,7 @@ public class Database {
|
||||
*/
|
||||
public void createStructure() {
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT '',"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
|
||||
72
src/main/java/com/gmail/nossr50/util/Hardcore.java
Normal file
72
src/main/java/com/gmail/nossr50/util/Hardcore.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class Hardcore {
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0)
|
||||
return;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
for(SkillType st : SkillType.values()) {
|
||||
|
||||
if(st.equals(SkillType.ALL))
|
||||
continue;
|
||||
|
||||
int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D)));
|
||||
|
||||
if(newValue < 0)
|
||||
newValue = 0;
|
||||
|
||||
totalCount+=PP.getSkillLevel(st)-newValue;
|
||||
|
||||
PP.modifySkill(st, newValue);
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death.");
|
||||
}
|
||||
|
||||
public static void invokeVampirism(Player killer, Player defender) {
|
||||
if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0)
|
||||
return;
|
||||
|
||||
PlayerProfile PPk = Users.getProfile(killer);
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
for(SkillType st : SkillType.values()) {
|
||||
if(st.equals(SkillType.ALL))
|
||||
continue;
|
||||
|
||||
if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2))
|
||||
continue;
|
||||
|
||||
int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D));
|
||||
|
||||
if(newValue <= 0)
|
||||
newValue = 1;
|
||||
|
||||
totalCount+=1;
|
||||
|
||||
PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
|
||||
PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue);
|
||||
}
|
||||
|
||||
if(totalCount >= 1) {
|
||||
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player.");
|
||||
defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!");
|
||||
} else {
|
||||
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GRAY+"That player was too unskilled to grant you any knowledge.");
|
||||
defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.GRAY+" was unable to steal knowledge from you!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
@@ -18,25 +17,25 @@ public class Item {
|
||||
*
|
||||
* @param player Player whose item usage to check
|
||||
*/
|
||||
public static void itemchecks(Player player) {
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
public static void itemChecks(Player player) {
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (Config.getInstance().getChimaeraEnabled() && inhand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||
chimaerawing(player);
|
||||
if (Config.getInstance().getChimaeraEnabled() && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||
chimaeraWing(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void chimaerawing(Player player) {
|
||||
private static void chimaeraWing(Player player) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack is = player.getItemInHand();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Block block = player.getLocation().getBlock();
|
||||
int amount = is.getAmount();
|
||||
int amount = inHand.getAmount();
|
||||
|
||||
if (Permissions.getInstance().chimaeraWing(player) && is.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||
if (Permissions.getInstance().chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||
if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
|
||||
|
||||
for (int y = 0; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
||||
for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
||||
if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
||||
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
|
||||
@@ -53,10 +52,10 @@ public class Item {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
||||
}
|
||||
else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= Config.getInstance().getChimaeraCost()) {
|
||||
else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)}));
|
||||
}
|
||||
else if (is.getAmount() <= Config.getInstance().getChimaeraCost()) {
|
||||
else if (amount <= Config.getInstance().getChimaeraCost()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getChimaeraItemId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,14 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
|
||||
public class ItemChecks {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
||||
|
||||
/**
|
||||
* Checks if the item is a sword.
|
||||
@@ -20,7 +27,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customSwordIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +52,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +66,7 @@ public class ItemChecks {
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a shovel, false otherwise
|
||||
*/
|
||||
*/
|
||||
public static boolean isShovel(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_SPADE:
|
||||
@@ -60,7 +77,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +102,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +117,7 @@ public class ItemChecks {
|
||||
* @param is Item to check
|
||||
* @return true if the item is a pickaxe, false otherwise
|
||||
*/
|
||||
public static boolean isMiningPick(ItemStack is) {
|
||||
public static boolean isPickaxe(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_PICKAXE:
|
||||
case GOLD_PICKAXE:
|
||||
@@ -100,7 +127,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +151,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +175,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +199,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +223,12 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,4 +447,3 @@ public class ItemChecks {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.Tree;
|
||||
|
||||
public class Leaderboard {
|
||||
private static String leaderboardsDirectory = mcMMO.leaderboardDirectory;
|
||||
private static String location = mcMMO.usersFile;
|
||||
private static mcMMO plugin = mcMMO.p;
|
||||
private static String leaderboardsDirectory = plugin.leaderboardDirectory;
|
||||
private static String location = plugin.usersFile;
|
||||
|
||||
/**
|
||||
* Create the leaderboards.
|
||||
|
||||
@@ -94,7 +94,7 @@ public class Misc {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
@@ -140,11 +140,15 @@ public class Misc {
|
||||
else if (ItemChecks.isIronTool(inHand)) {
|
||||
tier = 3;
|
||||
}
|
||||
else if(ItemChecks.isGoldTool(inHand)) {
|
||||
else if (ItemChecks.isGoldTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if(ItemChecks.isDiamondTool(inHand))
|
||||
else if (ItemChecks.isDiamondTool(inHand)) {
|
||||
tier = 4;
|
||||
}
|
||||
else if (ModChecks.isCustomTool(inHand)) {
|
||||
tier = ModChecks.getToolFromItemStack(inHand).getTier();
|
||||
}
|
||||
|
||||
return tier;
|
||||
}
|
||||
@@ -193,9 +197,9 @@ public class Misc {
|
||||
* @param is The items to drop
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void mcDropItems(Location location, ItemStack is, int quantity) {
|
||||
public static void dropItems(Location location, ItemStack is, int quantity) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
mcDropItem(location, is);
|
||||
dropItem(location, is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,9 +210,9 @@ public class Misc {
|
||||
* @param is The item to drop
|
||||
* @param chance The percentage chance for the item to drop
|
||||
*/
|
||||
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
|
||||
public static void randomDropItem(Location location, ItemStack is, double chance) {
|
||||
if (random.nextInt(100) < chance) {
|
||||
mcDropItem(location, is);
|
||||
dropItem(location, is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,9 +224,9 @@ public class Misc {
|
||||
* @param chance The percentage chance for the item to drop
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void mcRandomDropItems(Location location, ItemStack is, int chance, int quantity) {
|
||||
public static void randomDropItems(Location location, ItemStack is, int chance, int quantity) {
|
||||
for(int i = 0; i < quantity; i++) {
|
||||
mcRandomDropItem(location, is, chance);
|
||||
randomDropItem(location, is, chance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +236,7 @@ public class Misc {
|
||||
* @param location The location to drop the item at
|
||||
* @param itemStack The item to drop
|
||||
*/
|
||||
public static void mcDropItem(Location location, ItemStack itemStack) {
|
||||
public static void dropItem(Location location, ItemStack itemStack) {
|
||||
|
||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
|
||||
@@ -262,8 +266,10 @@ public class Misc {
|
||||
}
|
||||
|
||||
public static int getPowerLevelCap() {
|
||||
if (Config.getInstance().getPowerLevelCap() > 0) {
|
||||
return Config.getInstance().getPowerLevelCap();
|
||||
int levelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (levelCap > 0) {
|
||||
return levelCap;
|
||||
}
|
||||
else {
|
||||
return Integer.MAX_VALUE;
|
||||
|
||||
153
src/main/java/com/gmail/nossr50/util/ModChecks.java
Normal file
153
src/main/java/com/gmail/nossr50/util/ModChecks.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
public class ModChecks {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||
|
||||
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
||||
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
||||
|
||||
/**
|
||||
* Get the custom armor associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the armor if it exists, null otherwise
|
||||
*/
|
||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
||||
return armorInstance.customArmor.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
return toolInstance.customTools.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom block associated with an block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return the armor if it exists, null otherwise
|
||||
*/
|
||||
public static CustomBlock getCustomBlock(Block block) {
|
||||
if (!blocksInstance.customItems.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CustomBlock b : blocksInstance.customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a custom block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block is custom, false otherwise
|
||||
*/
|
||||
public static boolean isCustomMiningBlock(Block block) {
|
||||
if (customBlocksEnabled && blocksInstance.customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a leaf block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents leaves, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLeafBlock(Block block) {
|
||||
if (blocksInstance.customLeaves.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a log block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents a log, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLogBlock(Block block) {
|
||||
if (blocksInstance.customLogs.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an ore block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents an ore, false otherwise
|
||||
*/
|
||||
public static boolean isCustomOreBlock(Block block) {
|
||||
if (blocksInstance.customOres.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomTool(ItemStack item) {
|
||||
if (customToolsEnabled && toolInstance.customTools.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is custom armor.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is custom armor, false otherwise
|
||||
*/
|
||||
public static boolean isCustomArmor(ItemStack item) {
|
||||
if (customArmorEnabled && armorInstance.customArmor.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,10 @@ public class Permissions {
|
||||
/*
|
||||
* MCMMO.BYPASS.*
|
||||
*/
|
||||
public boolean hardcoremodeBypass(Player player) {
|
||||
return player.hasPermission("mcmmo.bypass.hardcoremode");
|
||||
}
|
||||
|
||||
public boolean arcaneBypass(Player player) {
|
||||
return player.hasPermission("mcmmo.bypass.arcanebypass");
|
||||
}
|
||||
@@ -72,7 +76,7 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.taming.fastfoodservice");
|
||||
}
|
||||
|
||||
public boolean sharpenedclaws(Player player) {
|
||||
public boolean sharpenedClaws(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.sharpenedclaws");
|
||||
}
|
||||
|
||||
@@ -108,6 +112,14 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.fishing.shakemob");
|
||||
}
|
||||
|
||||
public boolean fishingTreasures(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.fishing.treasures");
|
||||
}
|
||||
|
||||
public boolean fishingMagic(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.fishing.magic");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.MINING.*
|
||||
*/
|
||||
@@ -144,6 +156,10 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.repair.repairbonus");
|
||||
}
|
||||
|
||||
public boolean repairMastery(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.repairmastery");
|
||||
}
|
||||
|
||||
public boolean arcaneForging(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.arcaneforging");
|
||||
}
|
||||
@@ -180,6 +196,14 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.repair.toolrepair");
|
||||
}
|
||||
|
||||
public boolean otherMaterialRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.othermaterialrepair");
|
||||
}
|
||||
|
||||
public boolean otherRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.otherrepair");
|
||||
}
|
||||
|
||||
public boolean stringRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.stringrepair");
|
||||
}
|
||||
@@ -212,14 +236,14 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.archery.trackarrows");
|
||||
}
|
||||
|
||||
public boolean ignition(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.archery.ignition");
|
||||
}
|
||||
|
||||
public boolean daze(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.archery.daze");
|
||||
}
|
||||
|
||||
public boolean archeryBonus(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.archery.bonusdamage");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.HERBALISM.*
|
||||
*/
|
||||
@@ -240,6 +264,10 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.herbalism.greenthumbwheat");
|
||||
}
|
||||
|
||||
public boolean farmersDiet(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.herbalism.farmersdiet");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.EXCAVATION.*
|
||||
*/
|
||||
@@ -288,6 +316,10 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.axes.impact");
|
||||
}
|
||||
|
||||
public boolean greaterImpact(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.axes.greaterimpact");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.ACROBATICS.*
|
||||
*/
|
||||
@@ -316,6 +348,10 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.blastmining.demolitionsexpertise");
|
||||
}
|
||||
|
||||
public boolean blastMining(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.blastmining.detonate");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ITEM.*
|
||||
*/
|
||||
@@ -372,10 +408,6 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.skills.mining");
|
||||
}
|
||||
|
||||
public boolean blastMining(Player player) {
|
||||
return player.hasPermission("mcmmo.skills.blastmining");
|
||||
}
|
||||
|
||||
public boolean fishing(Player player) {
|
||||
return player.hasPermission("mcmmo.skills.fishing");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -12,10 +14,6 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
@@ -29,6 +27,8 @@ public class Skills {
|
||||
private final static int TIME_CONVERSION_FACTOR = 1000;
|
||||
private final static double MAX_DISTANCE_AWAY = 10.0;
|
||||
|
||||
private final static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Checks to see if the cooldown for an item or ability is expired.
|
||||
*
|
||||
@@ -268,9 +268,11 @@ public class Skills {
|
||||
*/
|
||||
public static SkillType getSkillType(String skillName) {
|
||||
for (SkillType x : SkillType.values()) {
|
||||
if (x.toString().equals(skillName.toUpperCase()))
|
||||
if (x.toString().equals(skillName.toUpperCase())) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -345,14 +347,18 @@ public class Skills {
|
||||
/**
|
||||
* Handle tool durability loss from abilities.
|
||||
*
|
||||
* @param inhand The item to damage
|
||||
* @param inHand The item to damage
|
||||
* @param durabilityLoss The durability to remove from the item
|
||||
*/
|
||||
public static void abilityDurabilityLoss(ItemStack inhand, int durabilityLoss) {
|
||||
public static void abilityDurabilityLoss(ItemStack inHand, int durabilityLoss) {
|
||||
if (Config.getInstance().getAbilitiesDamageTools()) {
|
||||
if (!inhand.containsEnchantment(Enchantment.DURABILITY)) {
|
||||
inhand.setDurability((short) (inhand.getDurability() + durabilityLoss));
|
||||
if (inHand.containsEnchantment(Enchantment.DURABILITY)) {
|
||||
int level = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
if (random.nextInt(level + 1) > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
inHand.setDurability((short) (inHand.getDurability() + durabilityLoss));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,6 +389,9 @@ public class Skills {
|
||||
}
|
||||
|
||||
int ticks = 2 + (PP.getSkillLevel(type) / 50);
|
||||
if (ability.getMaxTicks() != 0 && ticks > ability.getMaxTicks()) {
|
||||
ticks = ability.getMaxTicks();
|
||||
}
|
||||
|
||||
if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown())) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
@@ -427,7 +436,7 @@ public class Skills {
|
||||
/* FALLS THROUGH */
|
||||
|
||||
case GREEN_TERRA:
|
||||
if (!ability.blockCheck(block.getType())) {
|
||||
if (!ability.blockCheck(block)) {
|
||||
activate = false;
|
||||
break;
|
||||
}
|
||||
@@ -12,20 +12,19 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class Users {
|
||||
|
||||
public static String location = mcMMO.usersFile;
|
||||
public static String directory = mcMMO.flatFileDirectory;
|
||||
public static String directoryb = mcMMO.leaderboardDirectory;
|
||||
|
||||
private final static mcMMO plugin = mcMMO.p;
|
||||
public static HashMap<String, PlayerProfile> players = new HashMap<String, PlayerProfile>();
|
||||
|
||||
|
||||
/**
|
||||
* Load users.
|
||||
*/
|
||||
public static void loadUsers() {
|
||||
new File(directory).mkdir();
|
||||
new File(directoryb).mkdir();
|
||||
File theDir = new File(location);
|
||||
|
||||
|
||||
new File(plugin.flatFileDirectory).mkdir();
|
||||
new File(plugin.leaderboardDirectory).mkdir();
|
||||
File theDir = new File(plugin.usersFile);
|
||||
|
||||
if (!theDir.exists()) {
|
||||
try {
|
||||
@@ -105,7 +104,7 @@ public class Users {
|
||||
* @return the player's profile
|
||||
*/
|
||||
public static PlayerProfile getProfileByName(String playerName) {
|
||||
if (mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline() || players.containsKey(playerName.toLowerCase())) {
|
||||
if (plugin.getServer().getOfflinePlayer(playerName).isOnline() || players.containsKey(playerName.toLowerCase())) {
|
||||
if (players.containsKey(playerName.toLowerCase())) {
|
||||
return players.get(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public interface ChunkletManager {
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is loaded, it should load appropriate data
|
||||
*
|
||||
* @param cx Chunk X coordiate that is loaded
|
||||
* @param cz Chunk Z coordiate that is loaded
|
||||
* @param world World that the chunk was loaded in
|
||||
*/
|
||||
public void chunkLoaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is unloaded, it should unload and save appropriate data
|
||||
*
|
||||
* @param cx Chunk X coordiate that is unloaded
|
||||
* @param cz Chunk Z coordiate that is unloaded
|
||||
* @param world World that the chunk was unloaded in
|
||||
*/
|
||||
public void chunkUnloaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Save all ChunkletStores related to the given world
|
||||
*
|
||||
* @param world World to save
|
||||
*/
|
||||
public void saveWorld(World world);
|
||||
|
||||
/**
|
||||
* Unload all ChunkletStores from memory related to the given world after saving them
|
||||
*
|
||||
* @param world World to unload
|
||||
*/
|
||||
public void unloadWorld(World world);
|
||||
|
||||
/**
|
||||
* Save all ChunkletStores
|
||||
*/
|
||||
public void saveAll();
|
||||
|
||||
/**
|
||||
* Unload all ChunkletStores after saving them
|
||||
*/
|
||||
public void unloadAll();
|
||||
|
||||
/**
|
||||
* Check to see if a given location is set to true
|
||||
*
|
||||
* @param x X coordinate to check
|
||||
* @param y Y coordinate to check
|
||||
* @param z Z coordinate to check
|
||||
* @param world World to check in
|
||||
* @return true if the given location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Check to see if a given block location is set to true
|
||||
*
|
||||
* @param block Block location to check
|
||||
* @return true if the given block location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(Block block);
|
||||
|
||||
/**
|
||||
* Set a given location to true, should create stores as necessary if the location does not exist
|
||||
*
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
public void setTrue(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Set a given block location to true, should create stores as necessary if the location does not exist
|
||||
*
|
||||
* @param block Block location to set
|
||||
*/
|
||||
public void setTrue(Block block);
|
||||
|
||||
/**
|
||||
* Set a given location to false, should not create stores if one does not exist for the given location
|
||||
*
|
||||
* @param x X coordinate to set
|
||||
* @param y Y coordinate to set
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
public void setFalse(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Set a given block location to false, should not create stores if one does not exist for the given location
|
||||
*
|
||||
* @param block Block location to set
|
||||
*/
|
||||
public void setFalse(Block block);
|
||||
|
||||
/**
|
||||
* Delete any ChunkletStores that are empty
|
||||
*/
|
||||
public void cleanUp();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
|
||||
public class ChunkletManagerFactory {
|
||||
public static ChunkletManager getChunkletManager() {
|
||||
HiddenConfig hConfig = HiddenConfig.getInstance();
|
||||
|
||||
if(hConfig.getChunkletsEnabled()) {
|
||||
return new HashChunkletManager();
|
||||
} else {
|
||||
return new NullChunkletManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface ChunkletStore extends Serializable {
|
||||
/**
|
||||
* Checks the value at the given coordinates
|
||||
*
|
||||
* @param x x coordinate in current chunklet
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
* @return true if the value is true at the given coordinates, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Set the value to true at the given coordinates
|
||||
*
|
||||
* @param x x coordinate in current chunklet
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
*/
|
||||
public void setTrue(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Set the value to false at the given coordinates
|
||||
*
|
||||
* @param x x coordinate in current chunklet
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
*/
|
||||
public void setFalse(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return true if all values in the chunklet are false, false if otherwise
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user