1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-20 10:43:12 +01:00

Compare commits

..

128 Commits

Author SHA1 Message Date
GJ
d35cdc91f8 Think it's finally right... 2012-05-17 22:24:45 -04:00
GJ
8d643277c0 Locale update. 2012-05-17 22:22:53 -04:00
GJ
5be1858b45 Stupid file... 2012-05-17 22:20:25 -04:00
GJ
13d6e16630 Stupid file... 2012-05-17 22:18:44 -04:00
GJ
dcb1cbbdb7 Locale update. 2012-05-17 22:11:16 -04:00
nossr50
f7f077be3e Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2012-05-17 19:00:14 -07:00
nossr50
3d79416520 Getting ready for promotions in this good economy 2012-05-17 18:59:51 -07:00
GJ
c559e70270 Mod support - able to define tiers for custom blocks now.
Tier 1 - breaks with wood/gold
Tier 2 - breaks with stone
Tier 3 - breaks with iron
Tier 4 - breaks with diamond
2012-05-17 21:57:41 -04:00
GJ
efcc15d89d Custom blocks should now work right with Super Breaker. 2012-05-17 21:37:14 -04:00
GJ
d17fe6bb7a Mod Support - Item Tiers.
1 is Wood, 2 is Stone, 3 is Iron, 4 is Diamond.
2012-05-17 21:19:17 -04:00
NuclearW
01235ff398 isInJar 2012-05-17 21:02:26 -04:00
NuclearW
3d6e490505 Expunge this line 2012-05-17 20:49:43 -04:00
NuclearW
bd3491d210 Registration 2012-05-17 20:01:37 -04:00
NuclearW
d139146e0b Too much space 2012-05-17 19:57:56 -04:00
GJ
b36da06fad Mod Support - Custom blocks now allow for the setting of how many items
they drop when broken.
2012-05-17 17:21:59 -04:00
GJ
d20c5e1773 Mod Support - Woodcutting now works. Still need to add # of drops from a
given block.
2012-05-17 17:03:56 -04:00
GJ
0afc0d59a4 Config refactoring. 2012-05-17 10:26:21 -04:00
NuclearW
26481c547a Beginnings of RepairManager implementation
Plus more factories for a stronger economy
2012-05-17 09:43:42 -04:00
NuclearW
45fe8c182b Put new permissions to good use 2012-05-17 09:43:42 -04:00
NuclearW
c25ddd0dbc <GJ> MOAR PERMISSIONS! 2012-05-17 09:43:42 -04:00
NuclearW
efc9a10fdf Make use of enum 2012-05-17 09:43:42 -04:00
NuclearW
a8eb9dfedf <GJ> All hail the enum! 2012-05-17 09:43:42 -04:00
NuclearW
87cf5cb932 Add metadata value for repair material 2012-05-17 09:43:41 -04:00
GJ
e1ca2c0b98 Mod support - Fixed blocks config not loading or generating. 2012-05-17 08:33:50 -04:00
NuclearW
a9295751c8 Beginnings of RepairManager interface
Not sure yet exactly what to leave in Repair and what to have in the Manager implementation.

I'm fairly sure that the xpHandler should be in Repair, but that's private at the moment so usage from the Manager is impossible except with public modifier, which is unacceptable.

Considering moving Repair to the new repair package, perhaps eventually all skills will have packages and skills.  Moving it seems like the logical solution with protected modifier.
2012-05-17 04:32:14 -04:00
NuclearW
2a46a5c00a Remove boost from the repair xpHandler
Replace old false values with doubles which will produce identical results

While the boost value will remain confusing in configs later, it will now at least be easier.
2012-05-17 04:28:31 -04:00
NuclearW
d3b7af3c5f Beginnings of the repairable 2012-05-17 04:01:47 -04:00
NuclearW
db59f24873 Cleanup 2012-05-17 03:57:16 -04:00
GJ
5645bf7982 Mod support - XP gain & double drops should now work for custom blocks
EXCEPT Woodcutting. Custom excavation blocks will also never drop
treasures.
2012-05-17 00:24:33 -04:00
GJ
6cbf87b52c Fixed custom tools & armor not being repairable. 2012-05-16 15:48:52 -04:00
GJ
bc642deebd Custom armor can now be repaired. 2012-05-15 16:12:59 -04:00
GJ
e84a9643f8 Enchanted custom tools should now support Arcane Forging. 2012-05-15 14:39:39 -04:00
GJ
e9af0ebdc5 Custom tools - modify XP gain from breaking blocks on a per tool basis. 2012-05-15 14:21:21 -04:00
GJ
29ee8a035b Custom tools - should now support enabling/disabling ability activation
per tool.
2012-05-15 13:44:39 -04:00
GJ
81ac4e8d01 WIP on custom mod support - should now be able to repair custom tools at
an anvil.
2012-05-15 10:44:57 -04:00
NuclearW
ecc68d373f Typo fix in Acrobatics guide 2012-05-15 04:06:05 -04:00
NuclearW
3032572f18 New factories means more jobs for a better economy 2012-05-15 01:43:34 -04:00
NuclearW
bcee6abb65 Re-add call to updateInventory 2012-05-15 00:49:19 -04:00
nossr50
7e0b8ddf50 HudType will default to 'STANDARD' for MySQL DB - only good for new users 2012-05-14 15:13:55 -07:00
NuclearW
91dcb508b3 POOT DONATION HERE 2012-05-14 17:52:07 -04:00
GJ
d549e2722d Removed unused import. 2012-05-14 10:48:46 -04:00
nossr50
3bb29c8308 mcMMO's motd now links to the new website rather than the wiki 2012-05-13 19:00:49 -07:00
nossr50
0121228d88 Update README.creole 2012-05-13 15:30:09 -07:00
bm01
cbafa7110a Fixed minor Green Terra bugs on Stone Brick 2012-05-10 15:54:29 +02:00
bm01
06791beabd Fixed double Config instantiation causing NPE on PlayerProfile.save() 2012-05-09 15:58:11 +02:00
bm01
68b9857409 Fixed /<skill> command being processed twice when an alias was used 2012-05-09 13:06:40 +02:00
bm01
112a0df8c2 Minor locale fix 2012-05-09 12:10:59 +02:00
bm01
73717278ff Fixed /party not showing properly the member list 2012-05-09 11:38:22 +02:00
bm01
5fa79926db Fixed arrow boucing off entities on daze proc 2012-05-08 21:58:01 +02:00
bm01
06f97ac2f1 Fixed a bug where a player could gain Acrobatics exp while riding a cart 2012-05-08 20:20:23 +02:00
bm01
c2b4961b8d Removed exp gain when an arrow strikes its shooter 2012-05-08 20:12:41 +02:00
bm01
9b3838b912 Improved attacker and defender's party check 2012-05-08 19:42:26 +02:00
bm01
946ea19371 Fixed bad /party fix :( 2012-05-08 06:58:50 +02:00
NuclearW
419e011d0b Changelog for last commit 2012-05-07 22:50:24 -04:00
NuclearW
b0157c9bd2 Replace Bukkit Metadata for user placed blocks 2012-05-07 22:38:22 -04:00
nossr50
37d146e8fa Fixed various NPE errors when loading up mcMMO 2012-05-06 14:51:25 -07:00
bm01
063d982750 Fixed the fix! 2012-05-06 11:05:51 +02:00
bm01
fbfeaa0f95 Fixed /party not working properly with 2 arguments 2012-05-06 11:02:08 +02:00
bm01
9b11b02658 Minor locale fix 2012-05-06 09:55:15 +02:00
bm01
3e435c419a Refixed NPE due to GainXp task 2012-05-06 09:47:25 +02:00
GJ
1b37ba8daa Fixed a few issues from the merge, added the mod directory to the zip
backup.
2012-05-05 13:51:54 -04:00
nossr50
b529219a0e Merge branch 'master' of github.com:mcMMO-Dev/mcMMO
Conflicts:
	src/main/java/com/gmail/nossr50/mcMMO.java
2012-05-05 10:20:26 -07:00
nossr50
d9b3eff18f Changed how a few variables were initialized 2012-05-05 10:16:41 -07:00
GJ
cb5ada6ec9 Fix for config files not being created at startup. 2012-05-05 13:02:55 -04:00
bm01
baf7ffd441 Fixed french locale string causing IAE on repair skillup 2012-05-04 20:17:17 +02:00
GJ
2b4ca80a95 Start of work on allowing custom tool/block mods. This version should
allow for XP gain from vanilla blocks with custom tools. Please report
any issues to facilitate further development.
2012-05-04 14:04:42 -04:00
bm01
b5963936fd Fixed /ability not checking the right permission 2012-05-04 19:42:00 +02:00
bm01
354ed9ede0 Fixed NPE on /party 2012-05-04 11:04:05 +02:00
bm01
7ad9b8ff3e Changed Arrow Retrieval to drop arrows individually 2012-05-04 10:27:49 +02:00
bm01
6dc522a044 Fixed Arrow Retrieval dropping only one arrow 2012-05-03 16:45:30 +02:00
GJ
3e91bc8c1e Can now enable/disable specific skills for PVP & PVE 2012-05-03 10:39:32 -04:00
nossr50
3218c544dc Added level curve modifier 2012-05-02 06:10:32 -07:00
GJ
1ae11da036 Start of work on allowing Combat skills to be enabled for just PVP or
PVE
2012-05-01 22:42:45 -04:00
bm01
84e36d758e Fixed /p and /a incompatibilities with bChatManager 2012-05-02 00:55:43 +02:00
bm01
06ede80435 Fixed Iron Grip working reversely 2012-05-01 23:51:49 +02:00
bm01
dbc57060ee Reduced bleeding ticks damage 2012-05-01 23:49:11 +02:00
GJ
798bd46d0a Command updates - Repair (Finally done!) 2012-05-01 16:29:52 -04:00
GJ
c95f388d8d Allow for checking if ALL double drops are disabled via config. 2012-05-01 15:56:09 -04:00
GJ
a9024ebc6b Fixed bug with getting NO logs from Tree Feller if double drops were
disabled in the config file.
2012-05-01 15:25:28 -04:00
GJ
33bc2d8a6b Command updates - Woodcutting & Unarmed 2012-05-01 15:15:30 -04:00
GJ
cc60f2f308 Command update - Swords 2012-05-01 14:28:20 -04:00
GJ
edaa51593b Skills refactoring 2012-05-01 13:58:47 -04:00
GJ
e2265dd6f7 Updates to repair command, minor permission node & config updates 2012-05-01 13:53:00 -04:00
nossr50
e1cf89c3bf Vamprirism updates. 2012-05-01 09:04:29 -07:00
nossr50
8cd1541893 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2012-05-01 08:48:10 -07:00
nossr50
9d510815b4 Vampirism for hardcore mode, needs testing. 2012-05-01 08:47:57 -07:00
GJ
44d22d93da Command update - Mining. Also fixed typo on new Herbalism permission. 2012-05-01 10:39:50 -04:00
nossr50
f7405a82e6 Fixed NPE when user clicks the HUD button for Spout 2012-05-01 06:30:57 -07:00
GJ
04f3e44c3a Command updates - Herbalism 2012-05-01 09:11:56 -04:00
GJ
6cc207a10c Fixed bug with Chimera Wing failing when used on half-blocks - Fixes
MCCORE-221

Also added treasures.yml to the zip backup.
2012-05-01 08:28:54 -04:00
GJ
6b5e615a23 Tabs are bad and we should feel bad for having them. 2012-05-01 07:54:37 -04:00
Grant
46268a7cf3 Merge pull request #202 from shatteredbeam/master
Zip automation running in SQL mode Fix
2012-05-01 04:41:09 -07:00
bm01
3682fbf531 Reverted last commit 2012-05-01 10:51:17 +02:00
bm01
0928b54d90 Actually fixed Hardcore 2012-05-01 10:49:36 +02:00
bm01
5a10339adc Fixed Hardcore mode always enabled 2012-05-01 10:43:04 +02:00
Shatteredbeam
7c412cbec8 Fix for zip backup running in SQL mode. 2012-05-01 00:07:17 -07:00
bm01
d235ca8ed8 Fixed SQLReconnect not working 2012-05-01 07:53:03 +02:00
GJ
97511be64a One more tweak. 2012-05-01 01:43:00 -04:00
GJ
3bd5aaa251 Importing by * is a bad idea. 2012-05-01 01:40:47 -04:00
GJ
ae2d9d8387 Locale update. 2012-05-01 01:33:42 -04:00
GJ
33c9694d26 Changelog update & the removal of a useless p 2012-05-01 01:25:13 -04:00
GJ
dbede7f81a Added config options for specific double drops. Implements MCCORE-226 2012-05-01 01:14:32 -04:00
bm01
c8ad2bb454 Added bm01 to authors :3 2012-05-01 01:34:21 +02:00
bm01
18c52a5e23 Cleanup 2012-05-01 01:32:50 +02:00
bm01
ca1954ff80 Merge pull request #201 from shatteredbeam/master
Zip Handling PR -
2012-04-30 16:08:13 -07:00
shatteredbeam
5a3574734c Added automatic backup of datafiles. 2012-04-30 15:48:59 -07:00
nossr50
5c6d10b2db Mining now completely ignore Silk Touch enchanted picks 2012-04-30 09:30:07 -07:00
nossr50
7e96ced4c4 Shortened the hardcore mode message 2012-04-30 07:19:13 -07:00
nossr50
8da259cabc Updated perm node behaviour and changelog 2012-04-30 07:17:10 -07:00
nossr50
f978d739bb Updates 2012-04-30 07:11:03 -07:00
nossr50
7b2d50e93e *Actually* fixing the Maths 2012-04-30 07:05:11 -07:00
nossr50
8bec50663f Fixing some Maths 2012-04-30 07:01:00 -07:00
nossr50
f4f5063efe Always forgot to update the changelog 2012-04-30 06:45:56 -07:00
nossr50
11782ac34d Bah, don't know why this got deleted. 2012-04-30 06:44:56 -07:00
nossr50
bfec3fff36 Forgot to register events for the new listener 2012-04-30 06:43:12 -07:00
nossr50
d8c0a56577 Added basic hardcore mode functionality, needs testing. 2012-04-30 06:41:58 -07:00
nossr50
ff1326a44f Revert "Added basic functionality of Hardcore Mode, needs testing..."
This reverts commit 1fa4fccbcc.
2012-04-30 06:41:09 -07:00
nossr50
1fa4fccbcc Added basic functionality of Hardcore Mode, needs testing... 2012-04-30 06:39:30 -07:00
nossr50
323b41fd58 Adding in config nodes for Hardcore Mode (WIP) 2012-04-30 06:21:14 -07:00
GJ
3d2b881b0e Command cleanup - Fishing. Added 2 new fishing permissions nodes. 2012-04-30 08:26:37 -04:00
GJ
def41af469 Command update - Excavation 2012-04-30 07:51:02 -04:00
GJ
4750aba763 Added permissions node for Greater Impact, cleanup of Axes command 2012-04-30 07:46:08 -04:00
GJ
5a9249dee1 Locale file update. 2012-04-29 23:05:57 -04:00
GJ
064fc0a8e2 Command format & permission changes, other minor cleanup. 2012-04-29 22:58:54 -04:00
bm01
67de70432c Fixed /party displaying twice the leader 2012-04-30 03:10:33 +02:00
bm01
facd71bd71 Minor locale things 2012-04-30 03:09:05 +02:00
nossr50
96e6270520 Changed MySQL to not save everything at once 2012-04-29 12:02:24 -07:00
nossr50
51c45e86ce Fixing formatting 2012-04-29 08:11:03 -07:00
120 changed files with 6890 additions and 2281 deletions

View File

@@ -7,6 +7,53 @@ Key:
! Change
- Removal
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 +78,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

View File

@@ -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.

View File

@@ -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.07</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>

View File

@@ -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);
}

View File

@@ -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 {

View File

@@ -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{

View File

@@ -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?

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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"));

View File

@@ -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;

View File

@@ -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

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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,8 +12,9 @@ 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.misc.Repair;
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 +22,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 +53,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 +127,36 @@ public class RepairCommand implements CommandExecutor {
}
private void dataCalculations(float skillValue) {
repairMasteryBonus = String.valueOf(skillValue / 5);
DecimalFormat percent = new DecimalFormat("##0.00%");
Config configInstance = Config.getInstance();
diamondLevel = configInstance.getRepairDiamondLevelRequirement();
goldLevel = configInstance.getRepairGoldLevelRequirement();
ironLevel = configInstance.getRepairIronLevelRequirement();
stoneLevel = configInstance.getRepairStoneLevelRequirement();
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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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 {

View File

@@ -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); }
@@ -130,12 +148,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,7 +199,40 @@ 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 */
@@ -164,14 +246,11 @@ public class Config extends ConfigLoader {
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); }
@@ -185,6 +264,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 +319,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 +362,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 +446,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 +475,4 @@ public class Config extends ConfigLoader {
if(defaulthud == null)
defaulthud = HUDType.STANDARD;
}
}
}

View File

@@ -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();

View File

@@ -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) {

View File

@@ -0,0 +1,99 @@
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.CustomItem;
public class CustomArmorConfig extends ModConfigLoader{
private static CustomArmorConfig instance;
public static CustomArmorConfig getInstance() {
if (instance == null) {
instance = new CustomArmorConfig(mcMMO.p);
}
return instance;
}
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> customItems = new ArrayList<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...");
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) {
ItemStack repairMaterial = new ItemStack(repairID, 1, (short) 0, repairData);
armor = new CustomItem(durability, repairMaterial, repairQuantity, repairable, id);
}
else {
armor = new CustomItem(durability, null, 0, repairable, id);
}
idList.add(id);
customIDs.add(id);
customItems.add(armor);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,107 @@
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.CustomItem;
import com.gmail.nossr50.datatypes.mods.CustomTool;
public class CustomToolsConfig extends ModConfigLoader {
private static CustomToolsConfig instance;
public static CustomToolsConfig getInstance() {
if (instance == null) {
instance = new CustomToolsConfig(mcMMO.p);
}
return instance;
}
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<CustomItem> customItems = new ArrayList<CustomItem>();
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...");
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) {
ItemStack repairMaterial = new ItemStack(repairID, 1, (short) 0, repairData);
tool = new CustomTool(durability, repairMaterial, repairQuantity, repairable, tier, abilityEnabled, multiplier, id);
}
else {
tool = new CustomTool(durability, null, 0, repairable, tier, abilityEnabled, multiplier, id);
}
idList.add(id);
customIDs.add(id);
customItems.add(tool);
}
}
}

View File

@@ -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);
}
}

View File

@@ -1,13 +1,12 @@
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 {
@@ -130,33 +129,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 +167,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;

View File

@@ -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.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.ItemChecks;
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,14 @@ public class PlayerProfile {
xp += trueBonus;
}
if (Config.getInstance().getToolModsEnabled()) {
ItemStack item = player.getItemInHand();
if (ItemChecks.isCustomTool(item)) {
xp = (int) (xp * ModChecks.getToolFromItemStack(item).getXpMultiplier());
}
}
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
lastgained = skillType;
@@ -1112,7 +1121,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?
}
/**

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -0,0 +1,60 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomItem {
protected int itemID;
protected boolean repairable;
protected ItemStack repairMaterial;
protected int repairQuantity;
protected short durability;
public CustomItem(short durability, ItemStack repairMaterial, int repairQuantity, boolean repairable, int itemID) {
this.itemID = itemID;
this.repairable = repairable;
this.repairMaterial = repairMaterial;
this.repairQuantity = repairQuantity;
this.durability = durability;
}
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
public boolean isRepairable() {
return repairable;
}
public void setRepairable(boolean repairable) {
this.repairable = repairable;
}
public ItemStack getRepairMaterial() {
return repairMaterial;
}
public void setRepairMaterial(ItemStack repairMaterial) {
this.repairMaterial = repairMaterial;
}
public int getRepairQuantity() {
return repairQuantity;
}
public void setRepairQuantity(int repairQuantity) {
this.repairQuantity = repairQuantity;
}
public short getDurability() {
return durability;
}
public void setDurability(short durability) {
this.durability = durability;
}
}

View File

@@ -0,0 +1,40 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomTool extends CustomItem {
private double xpMultiplier;
private boolean abilityEnabled;
private int tier;
public CustomTool(short durability, ItemStack repairMaterial, int repairQuantity, boolean repairable, int tier, boolean abilityEnabled, double xpMultiplier, int itemID) {
super(durability, repairMaterial, repairQuantity, repairable, 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;
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -8,16 +8,17 @@ 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.misc.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;
@@ -26,6 +27,7 @@ import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -36,7 +38,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 +59,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 +82,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 (mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.setTrue(event.getBlock().getRelative(event.getDirection()));
}
}
@@ -107,15 +108,15 @@ 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()) {
@@ -145,16 +146,16 @@ public class BlockListener implements Listener {
*/
/* Green Terra */
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || BlockChecks.canBeGreenTerra(block))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
/* Triple drops */
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.canBeGreenTerra(mat)) {
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canBeGreenTerra(block)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
if (Permissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
if (Permissions.getInstance().herbalism(player) && BlockChecks.canBeGreenTerra(block)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
@@ -162,8 +163,8 @@ public class BlockListener implements Listener {
* MINING
*/
if (Permissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
if (Permissions.getInstance().mining(player) && BlockChecks.canBeSuperBroken(block)) {
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
Mining.miningBlockCheck(player, block);
}
else if (!Config.getInstance().getMiningRequiresTool()) {
@@ -185,14 +186,21 @@ public class BlockListener implements Listener {
}
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
WoodCutting.treeFeller(event);
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
WoodCutting.treeFeller(event);
}
}
else {
WoodCutting.treeFeller(event);
}
}
/*
* EXCAVATION
*/
if (Excavation.canBeGigaDrillBroken(mat) && Permissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.getInstance().excavation(player) && !mcMMO.placeStore.isTrue(block)) {
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player);
}
@@ -202,8 +210,8 @@ public class BlockListener implements Listener {
}
//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);
}
}
@@ -225,20 +233,20 @@ public class BlockListener implements Listener {
/*
* 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) && mat.equals(Material.LOG) && Permissions.getInstance().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) || mat.equals(Material.SNOW))) {
Skills.abilityCheck(player, SkillType.UNARMED);
}
}
@@ -251,13 +259,28 @@ public class BlockListener implements Listener {
/*
* 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) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) {
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
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 (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else if (!Config.getInstance().getExcavationRequiresTool()) {
event.setInstaBreak(true);
@@ -277,16 +300,26 @@ public class BlockListener implements Listener {
}
}
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);
if (!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { //TODO: Why are we checking this?
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);
}
}
else {
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)) {
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (mat.equals(Material.LEAVES) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);

View File

@@ -1,11 +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.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -30,14 +33,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 +61,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;
@@ -110,7 +121,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()) {
Acrobatics.acrobaticsCheck(player, event);
}
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
@@ -144,12 +155,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 +224,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 +317,7 @@ public class EntityListener implements Listener {
break;
}
PP.addXP(SkillType.TAMING, xp);
PP.addXP(player, SkillType.TAMING, xp);
Skills.XpCheckSkill(SkillType.TAMING, player);
}
}

View File

@@ -0,0 +1,28 @@
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);
}
}
}

View File

@@ -37,16 +37,17 @@ 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.skills.misc.Repair;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Item;
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;
public class PlayerListener implements Listener {
@@ -165,8 +166,10 @@ public class PlayerListener implements Listener {
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"));
player.sendMessage(ChatColor.GOLD+"Server is running "+ChatColor.GREEN+plugin.getName()+" "+plugin.getDescription().getVersion());
player.sendMessage(ChatColor.GOLD+"http://www.mcmmo.info"+ChatColor.DARK_AQUA+" - mcMMO Website");
//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
@@ -201,14 +204,26 @@ public class PlayerListener implements Listener {
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 (ItemChecks.isTool(is) || ItemChecks.isArmor(is)) {
Repair.repairCheck(player, is);
event.setCancelled(true);
player.updateInventory();
}
else if (Config.getInstance().getToolModsEnabled() && ItemChecks.isCustomTool(is) && ModChecks.getToolFromItemStack(is).isRepairable()) {
Repair.repairCheck(player, is);
event.setCancelled(true);
player.updateInventory();
}
else if (Config.getInstance().getArmorModsEnabled() && ItemChecks.isCustomArmor(is) && ModChecks.getArmorFromItemStack(is).isRepairable()) {
Repair.repairCheck(player, is);
event.setCancelled(true);
player.updateInventory();
}
}
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(mat)) {
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
Skills.activationCheck(player, SkillType.HERBALISM);
}
@@ -222,13 +237,13 @@ public class PlayerListener implements Listener {
}
/* GREEN THUMB CHECK */
if (Permissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
if (Permissions.getInstance().greenThumbBlocks(player) && BlockChecks.makeMossy(block) && is.getType().equals(Material.SEEDS)) {
Herbalism.greenThumbBlocks(is, player, block);
}
/* ITEM CHECKS */
if (BlockChecks.abilityBlockCheck(mat)) {
Item.itemchecks(player);
if (BlockChecks.abilityBlockCheck(block)) {
Item.itemChecks(player);
}
/* BLAST MINING CHECK */
@@ -252,7 +267,7 @@ 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()) {
@@ -286,66 +301,61 @@ 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 +364,15 @@ 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];
if (plugin.aliasMap.containsKey(command)) {
if (command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
if (plugin.aliasMap.containsKey(command.toLowerCase())) {
//We should find a better way to avoid string replacement where the alias is equals to the command
if (command.equals(plugin.aliasMap.get(command.toLowerCase()))) {
return;
}
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
event.setMessage(message.replace(command, plugin.aliasMap.get(command.toLowerCase())));
}
}
}

View 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());
}
}

View File

@@ -6,17 +6,27 @@ 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.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.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Metrics;
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;
@@ -29,7 +39,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 +46,48 @@ 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;
/* 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();
if (!Config.getInstance().getUseMySQL()) {
if (configInstance.getToolModsEnabled()) {
CustomToolsConfig.getInstance().load();
}
if (configInstance.getArmorModsEnabled()) {
CustomArmorConfig.getInstance().load();
}
if (configInstance.getBlockModsEnabled()) {
CustomBlocksConfig.getInstance().load();
}
if (!configInstance.getUseMySQL()) {
Users.loadUsers();
}
@@ -77,11 +97,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 +125,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 +133,28 @@ public class mcMMO extends JavaPlugin {
registerCommands();
if (Config.getInstance().getStatsTrackingEnabled()) {
if (configInstance.getStatsTrackingEnabled()) {
try {
Metrics metrics = new Metrics(this);
metrics.start();
}
catch (IOException e) {
Metrics metrics = new Metrics(this);
metrics.start();
}
catch (IOException e) {
System.out.println("Failed to submit stats.");
}
}
}
// Get our ChunkletManager
placeStore = ChunkletManagerFactory.getChunkletManager();
}
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 +196,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 +224,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 +237,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 +254,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 +346,7 @@ public class mcMMO extends JavaPlugin {
}
/*
* Boilerplate Custom Config Stuff
* Boilerplate Custom Config Stuff (Treasures)
*/
private FileConfiguration treasuresConfig = null;
@@ -310,9 +361,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 +394,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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}

View File

@@ -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);

View File

@@ -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()) {

View File

@@ -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++;
}
}
}

View File

@@ -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 {

View File

@@ -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());
}
}
}
}

View File

@@ -1,24 +1,28 @@
package com.gmail.nossr50.skills;
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.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 {
public static Map<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
private static Random random = new Random();
/**
@@ -32,12 +36,15 @@ public class Archery {
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);
for (Entry<Entity, Integer> entry : arrowTracker.entrySet()) {
if (entry.getKey() == entity) {
entry.setValue(entry.getValue() + 1);
return;
}
}
arrowTracker.put(entity, 1);
}
}
@@ -46,8 +53,9 @@ public class Archery {
*
* @param defender Defending player
* @param attacker Attacking player
* @param event The event to modify
*/
public static void dazeCheck(Player defender, Player attacker) {
public static void dazeCheck(Player defender, Player attacker, EntityDamageByEntityEvent event) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
@@ -61,9 +69,9 @@ public class Archery {
loc.setPitch(-90);
}
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().daze(attacker)) {
if (random.nextInt(2000) <= skillCheck) {
defender.teleport(loc);
Combat.dealDamage(defender, 4);
event.setDamage(event.getDamage() + 4);
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
@@ -73,13 +81,16 @@ public class Archery {
* 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));
}
public static void arrowRetrievalCheck(Entity entity) {
for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) {
Entry<Entity, Integer> entry = it.next();
plugin.arrowTracker.remove(entity);
if (entry.getKey() == entity) {
Misc.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
it.remove();
return;
}
}
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.skills.combat;
import java.util.Random;
@@ -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 {
@@ -110,7 +111,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 +121,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));

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.skills.combat;
import java.util.Random;

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.skills.combat;
import java.util.Random;

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.skills.combat;
import java.util.Random;
@@ -54,7 +54,7 @@ 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);

View File

@@ -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));
}
}

View File

@@ -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:
@@ -120,7 +108,7 @@ public class Excavation {
}
//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);

View File

@@ -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();

View File

@@ -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.mcDropItem(loc, is);
}
break;
case CACTUS:
if (configInstance.getCactiDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, catciDrops);
}
break;
case CROPS:
if (configInstance.getWheatDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case MELON_BLOCK:
if (configInstance.getMelonsDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, 3);
Misc.mcRandomDropItems(loc, is, 50, 4);
}
break;
case NETHER_WARTS:
if (configInstance.getNetherWartsDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, 2);
Misc.mcRandomDropItems(loc, is, 50, 3);
}
break;
case PUMPKIN:
if (configInstance.getPumpkinsDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case RED_MUSHROOM:
if (configInstance.getRedMushroomsDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case SUGAR_CANE_BLOCK:
if (configInstance.getSugarCaneDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, caneDrops);
}
break;
case VINE:
if (configInstance.getVinesDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case WATER_LILY:
if (configInstance.getWaterLiliesDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case YELLOW_FLOWER:
if (configInstance.getYellowFlowersDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
default:
if (customPlant) {
Misc.mcDropItem(loc, is);
}
break;
}
}
}
PP.addXP(SkillType.HERBALISM, xp);
PP.addXP(player, SkillType.HERBALISM, xp);
Skills.XpCheckSkill(SkillType.HERBALISM, player);
}
@@ -286,7 +318,7 @@ public class Herbalism {
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"));
}
}
}

View File

@@ -0,0 +1,318 @@
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.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.BlockChecks;
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.config.mods.CustomBlocksConfig;
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);
Config configInstance = Config.getInstance();
switch (type) {
case COAL_ORE:
if (configInstance.getCoalDoubleDropsEnabled()) {
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
Misc.mcDropItem(loc, item);
}
break;
case DIAMOND_ORE:
if (configInstance.getDiamondDoubleDropsEnabled()) {
item = new ItemStack(Material.DIAMOND);
Misc.mcDropItem(loc, item);
}
break;
case ENDER_STONE:
if (configInstance.getEndStoneDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
if (configInstance.getRedstoneDoubleDropsEnabled()) {
item = new ItemStack(Material.REDSTONE);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItem(loc, item, 50);
}
break;
case GLOWSTONE:
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
item = new ItemStack(Material.GLOWSTONE_DUST);
Misc.mcDropItems(loc, item, 2);
Misc.mcRandomDropItems(loc, item, 50, 2);
}
break;
case GOLD_ORE:
if (configInstance.getGoldDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case IRON_ORE:
if (configInstance.getIronDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case LAPIS_ORE:
if (configInstance.getLapisDoubleDropsEnabled()) {
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItems(loc, item, 50, 4);
}
break;
case MOSSY_COBBLESTONE:
if (configInstance.getMossyCobblestoneDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case NETHERRACK:
if (configInstance.getNetherrackDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case OBSIDIAN:
if (configInstance.getObsidianDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case SANDSTONE:
if (configInstance.getSandstoneDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case STONE:
if (configInstance.getStoneDoubleDropsEnabled()) {
item = new ItemStack(Material.COBBLESTONE);
Misc.mcDropItem(loc, item);
}
break;
default:
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
item = ModChecks.getCustomBlock(block).getItemDrop();
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:
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
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) || player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
return;
}
miningXP(player, block);
if (BlockChecks.canBeSuperBroken(block)) {
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)) {
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 (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customItems.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
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());
}
}
}
}
}

View File

@@ -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.mcDropItem(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.mcRandomDropItem(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) {
@@ -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.mcDropItem(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.mcDropItem(location, item);
}
break;
case REDWOOD:
if (configInstance.getSpruceDoubleDropsEnabled()) {
Misc.mcDropItem(location, item);
}
break;
case BIRCH:
if (configInstance.getBirchDoubleDropsEnabled()) {
Misc.mcDropItem(location, item);
}
break;
case JUNGLE:
if (configInstance.getJungleDoubleDropsEnabled()) {
Misc.mcDropItem(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();
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.skills.misc;
import java.util.Random;
@@ -12,6 +12,7 @@ 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 {
@@ -58,7 +59,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 +77,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 +112,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);
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.skills.misc;
import java.util.Map;
import java.util.Random;
@@ -16,19 +16,26 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomToolsConfig;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.ItemChecks;
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.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
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 all the item repair checks.
@@ -47,22 +54,22 @@ public class Repair {
/*
* 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);
if (ItemChecks.isArmor(is) && permInstance.armorRepair(player)) {
if (ItemChecks.isDiamondArmor(is) && inventory.contains(configInstance.getRepairDiamondMaterial()) && skillLevel >= configInstance.getRepairDiamondLevelRequirement() && permInstance.diamondRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 6);
}
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.isIronArmor(is) && inventory.contains(configInstance.getRepairIronMaterial()) && skillLevel >= configInstance.getRepairIronLevelRequirement() && permInstance.ironRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairIronMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2);
}
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.isGoldArmor(is) && inventory.contains(configInstance.getRepairGoldMaterial()) && skillLevel >= configInstance.getRepairGoldLevelRequirement() && permInstance.goldRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 4);
}
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 if (ItemChecks.isLeatherArmor(is) && inventory.contains(configInstance.getRepairLeatherMaterial()) && permInstance.leatherRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairLeatherMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1);
}
else {
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
@@ -72,35 +79,81 @@ public class 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.isTool(is) && permInstance.toolRepair(player)) {
if (ItemChecks.isStoneTool(is) && inventory.contains(configInstance.getRepairStoneMaterial()) && skillLevel >= configInstance.getRepairStoneLevelRequirement() && permInstance.stoneRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairStoneMaterial()));
xpHandler(player, PP, is, durabilityBefore, .5);
}
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.isWoodTool(is) && inventory.contains(configInstance.getRepairWoodMaterial()) && permInstance.woodRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairWoodMaterial()));
xpHandler(player, PP, is, durabilityBefore, .5);
}
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.isIronTool(is) && inventory.contains(configInstance.getRepairIronMaterial()) && skillLevel >= configInstance.getRepairIronLevelRequirement() && permInstance.ironRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairIronMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1);
}
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.isDiamondTool(is) && inventory.contains(configInstance.getRepairDiamondMaterial()) && skillLevel >= configInstance.getRepairDiamondLevelRequirement() && permInstance.diamondRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1);
}
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.isGoldTool(is) && inventory.contains(configInstance.getRepairGoldMaterial()) && skillLevel >= configInstance.getRepairGoldLevelRequirement() && permInstance.goldRepair(player)) {
repairItem(player, is, new ItemStack(configInstance.getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 8);
}
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 if (ItemChecks.isStringTool(is) && inventory.contains(configInstance.getRepairStringMaterial()) && permInstance.stringRepair(player)){
repairItem(player, is, new ItemStack(configInstance.getRepairStringMaterial()));
xpHandler(player, PP, is, durabilityBefore, .5);
}
else {
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
}
}
/*
* REPAIR CUSTOM TOOLS
*/
else if (ItemChecks.isCustomTool(is) && permInstance.toolRepair(player)) {
CustomToolsConfig toolsInstance = CustomToolsConfig.getInstance();
for (CustomItem tool : toolsInstance.customItems) {
if (tool.getItemID() == is.getTypeId()) {
ItemStack repairMaterial = tool.getRepairMaterial();
if (inventory.contains(repairMaterial)) {
repairCustomItem(player, is, repairMaterial);
xpHandler(player, PP, is, durabilityBefore, 1);
}
else {
needMoreVespeneGas(is, player);
}
break;
}
}
}
/*
* REPAIR CUSTOM ARMOR
*/
else if (ItemChecks.isCustomArmor(is) && permInstance.armorRepair(player)) {
CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
for (CustomItem armor : armorInstance.customItems) {
if (armor.getItemID() == is.getTypeId()) {
ItemStack repairMaterial = armor.getRepairMaterial();
if (inventory.contains(repairMaterial)) {
repairCustomItem(player, is, repairMaterial);
xpHandler(player, PP, is, durabilityBefore, 1);
}
else {
needMoreVespeneGas(is, player);
}
break;
}
}
}
}
else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
@@ -117,17 +170,13 @@ public class 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) {
private static void xpHandler(Player player, PlayerProfile PP, ItemStack is, short durabilityBefore, double modify) {
short durabilityAfter = is.getDurability();
short dif = (short) (durabilityBefore - durabilityAfter);
if (boost) {
dif = (short) (dif * modify);
}
else{
dif = (short) (dif / modify);
}
dif = (short) (dif * modify);
//TODO: What exactly is this for, and should we have it for armor as well?
if (ItemChecks.isShovel(is)) {
dif = (short) (dif / 3);
}
@@ -138,11 +187,11 @@ public class Repair {
dif = (short) (dif / 2);
}
PP.addXP(SkillType.REPAIR, dif * 10);
PP.addXP(player, SkillType.REPAIR, dif * 10);
Skills.XpCheckSkill(SkillType.REPAIR, player);
//CLANG CLANG
if (Config.getInstance().spoutEnabled) {
if (configInstance.spoutEnabled) {
SpoutSounds.playRepairNoise(player, mcMMO.p);
}
}
@@ -156,16 +205,16 @@ public class Repair {
public static int getArcaneForgingRank(PlayerProfile PP) {
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels4()) {
if (skillLevel >= configInstance.getArcaneForgingRankLevels4()) {
return 4;
}
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels3()) {
else if (skillLevel >= configInstance.getArcaneForgingRankLevels3()) {
return 3;
}
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels2()) {
else if (skillLevel >= configInstance.getArcaneForgingRankLevels2()) {
return 2;
}
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels1()) {
else if (skillLevel >= configInstance.getArcaneForgingRankLevels1()) {
return 1;
}
else {
@@ -188,7 +237,7 @@ public class Repair {
int rank = getArcaneForgingRank(Users.getProfile(player));
if (rank == 0 || !Permissions.getInstance().arcaneForging(player)) {
if (rank == 0 || !permInstance.arcaneForging(player)) {
for (Enchantment x : enchants.keySet()) {
is.removeEnchantment(x);
}
@@ -204,7 +253,7 @@ public class Repair {
if (random.nextInt(100) <= getEnchantChance(rank)) {
int enchantLevel = enchant.getValue();
if (Config.getInstance().getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
if (random.nextInt(100) <= getDowngradeChance(rank)) {
is.addEnchantment(enchantment, enchantLevel--);
downgraded = true;
@@ -238,16 +287,16 @@ public class Repair {
public static int getEnchantChance(int rank) {
switch (rank) {
case 4:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank4();
return configInstance.getArcaneForgingKeepEnchantsChanceRank4();
case 3:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank3();
return configInstance.getArcaneForgingKeepEnchantsChanceRank3();
case 2:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank2();
return configInstance.getArcaneForgingKeepEnchantsChanceRank2();
case 1:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank1();
return configInstance.getArcaneForgingKeepEnchantsChanceRank1();
default:
return 0;
@@ -263,16 +312,16 @@ public class Repair {
public static int getDowngradeChance(int rank) {
switch (rank) {
case 4:
return Config.getInstance().getArcaneForgingDowngradeChanceRank4();
return configInstance.getArcaneForgingDowngradeChanceRank4();
case 3:
return Config.getInstance().getArcaneForgingDowngradeChanceRank3();
return configInstance.getArcaneForgingDowngradeChanceRank3();
case 2:
return Config.getInstance().getArcaneForgingDowngradeChanceRank2();
return configInstance.getArcaneForgingDowngradeChanceRank2();
case 1:
return Config.getInstance().getArcaneForgingDowngradeChanceRank1();
return configInstance.getArcaneForgingDowngradeChanceRank1();
default:
return 100;
@@ -284,25 +333,28 @@ public class Repair {
*
* @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
* @param repairAmount 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) {
private static short repairCalculate(Player player, short durability, int repairAmount) {
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);
if (permInstance.repairMastery(player)) {
bonus = (repairAmount * bonus);
repairAmount += bonus;
}
durability -= ramt;
if (checkPlayerProcRepair(player)) {
repairAmount = (short) (repairAmount * 2);
}
durability -= repairAmount;
if (durability < 0) {
durability = 0;
}
return durability;
}
@@ -315,31 +367,70 @@ public class Repair {
*/
private static short getRepairAmount(ItemStack is, Player player){
short maxDurability = is.getType().getMaxDurability();
int ramt = 0;
int repairAmount = 0;
if (ItemChecks.isShovel(is)) {
ramt = maxDurability;
repairAmount = maxDurability;
}
else if (ItemChecks.isHoe(is) || ItemChecks.isSword(is) || is.getType().equals(Material.SHEARS)) {
ramt = maxDurability / 2;
else if (ItemChecks.isHoe(is) || ItemChecks.isSword(is) || is.getType().equals(Material.SHEARS) || is.getType().equals(Material.FISHING_ROD)) {
repairAmount = maxDurability / 2;
}
else if (ItemChecks.isAxe(is) || ItemChecks.isMiningPick(is) || ItemChecks.isStringTool(is)) {
ramt = maxDurability / 3;
else if (ItemChecks.isAxe(is) || ItemChecks.isPickaxe(is) || is.getType().equals(Material.BOW)) {
repairAmount = maxDurability / 3;
}
else if (ItemChecks.isBoots(is)) {
ramt = maxDurability / 4;
repairAmount = maxDurability / 4;
}
else if (ItemChecks.isHelmet(is)) {
ramt = maxDurability / 5;
repairAmount = maxDurability / 5;
}
else if (ItemChecks.isPants(is)) {
ramt = maxDurability / 7;
repairAmount = maxDurability / 7;
}
else if (ItemChecks.isChestplate(is)) {
ramt = maxDurability / 8;
repairAmount = maxDurability / 8;
}
return repairCalculate(player, is.getDurability(), ramt);
return repairCalculate(player, is.getDurability(), repairAmount);
}
/**
* Gets the base durability amount to repair a custom item.
*
* @param is The custom item being repaired
* @param player The player repairing the custom item
* @return The final amount of durability repaired to the custom item
*/
private static short getCustomRepairAmount(ItemStack is, Player player) {
short maxDurability = 0;
int materialsRequired = 0;
int repairAmount = 0;
CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
if (ModChecks.getToolFromItemStack(is) != null) {
for (CustomItem tool : toolInstance.customItems) {
if (tool.getItemID() == is.getTypeId()) {
maxDurability = tool.getDurability();
materialsRequired = tool.getRepairQuantity();
break;
}
}
}
else if (ModChecks.getArmorFromItemStack(is) != null) {
for (CustomItem armor : armorInstance.customItems) {
if (armor.getItemID() == is.getTypeId()) {
maxDurability = armor.getDurability();
materialsRequired = armor.getRepairQuantity();
break;
}
}
}
repairAmount = maxDurability / materialsRequired;
return repairCalculate(player, is.getDurability(), repairAmount);
}
/**
@@ -356,45 +447,48 @@ public class Repair {
}
else {
if (ItemChecks.isDiamondTool(is) || ItemChecks.isDiamondArmor(is)) {
if (skillLevel < Config.getInstance().getRepairDiamondLevelRequirement()) {
if (skillLevel < configInstance.getRepairDiamondLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptDiamond"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.BLUE + Misc.prettyItemString(Config.getInstance().getRepairDiamondMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.BLUE + Misc.prettyItemString(configInstance.getRepairDiamondMaterial()));
}
}
else if (ItemChecks.isIronTool(is) || ItemChecks.isIronArmor(is)) {
if (skillLevel < Config.getInstance().getRepairIronLevelRequirement()) {
if (skillLevel < configInstance.getRepairIronLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptIron"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairIronMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(configInstance.getRepairIronMaterial()));
}
}
else if (ItemChecks.isGoldTool(is) || ItemChecks.isGoldArmor(is)) {
if (skillLevel < Config.getInstance().getRepairGoldLevelRequirement()) {
if (skillLevel < configInstance.getRepairGoldLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptGold"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GOLD + Misc.prettyItemString(Config.getInstance().getRepairGoldMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GOLD + Misc.prettyItemString(configInstance.getRepairGoldMaterial()));
}
}
else if (ItemChecks.isStoneTool(is)) {
if (skillLevel < Config.getInstance().getRepairStoneLevelRequirement()) {
if (skillLevel < configInstance.getRepairStoneLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptStone"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairStoneMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(configInstance.getRepairStoneMaterial()));
}
}
else if (ItemChecks.isWoodTool(is)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.DARK_GREEN + Misc.prettyItemString(Config.getInstance().getRepairWoodMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.DARK_GREEN + Misc.prettyItemString(configInstance.getRepairWoodMaterial()));
}
else if (ItemChecks.isLeatherArmor(is)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairLeatherMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(configInstance.getRepairLeatherMaterial()));
}
else if (ItemChecks.isStringTool(is)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairStringMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(configInstance.getRepairStringMaterial()));
}
else {
player.sendMessage("You do not have the material needed to repair this item!"); //TODO: Use locale
}
}
}
@@ -410,7 +504,7 @@ public class Repair {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().repairBonus(player)) {
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && permInstance.repairBonus(player)) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
return true;
}
@@ -425,7 +519,7 @@ public class Repair {
* @param item The item being repaired
* @param repairMaterial The repair reagent
*/
public static void repairItem(Player player, ItemStack item, ItemStack repairMaterial) {
private static void repairItem(Player player, ItemStack item, ItemStack repairMaterial) {
short initialDurability = item.getDurability();
short newDurability = getRepairAmount(item, player);
PlayerInventory inventory = player.getInventory();
@@ -445,7 +539,35 @@ public class Repair {
}
/* Handle the enchants */
if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.getInstance().arcaneBypass(player)) {
if (configInstance.getArcaneForgingEnchantLossEnabled() && !permInstance.arcaneBypass(player)) {
addEnchants(player, item);
}
item.setDurability(newDurability);
}
/**
* Repairs a custom item.
*
* @param player The player repairing an item
* @param item The custom item being repaired
* @param repairMaterial The repair reagent
*/
private static void repairCustomItem(Player player, ItemStack item, ItemStack repairMaterial) {
short initialDurability = item.getDurability();
short newDurability = getCustomRepairAmount(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;
}
inventory.removeItem(repairMaterial);
if (configInstance.getArcaneForgingEnchantLossEnabled() && !permInstance.arcaneBypass(player)) {
addEnchants(player, item);
}
@@ -462,7 +584,7 @@ public class Repair {
PlayerProfile PP = Users.getProfile(player);
if (!PP.getPlacedAnvil()) {
if (Config.getInstance().spoutEnabled) {
if (configInstance.spoutEnabled) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) {

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,38 @@
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);
/**
* 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);
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,70 @@
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();
}

View File

@@ -0,0 +1,8 @@
package com.gmail.nossr50.skills.repair;
public class RepairableFactory {
public static Repairable getRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType) {
// TODO: Add in loading from config what type of manager we want.
return new SimpleRepairable(itemId, repairMaterialId, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType);
}
}

View File

@@ -0,0 +1,42 @@
package com.gmail.nossr50.skills.repair;
import java.util.HashMap;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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 void handleRepair(Player player, ItemStack item) {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,66 @@
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;
protected SimpleRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType) {
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);
}
@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;
}
}

View File

@@ -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);

View File

@@ -1,19 +1,23 @@
package com.gmail.nossr50.util;
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 +31,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 +53,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 +90,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 +103,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:
@@ -112,8 +117,150 @@ public class BlockChecks {
case REDSTONE_ORE:
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 CROPS:
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:
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;
}
}
}
}

View File

@@ -27,15 +27,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.
@@ -61,53 +62,89 @@ public class Combat {
combatAbilityChecks(attacker);
if (ItemChecks.isSword(itemInHand) && Permissions.getInstance().swords(attacker)) {
if (Permissions.getInstance().swordsBleed(attacker)) {
if (ItemChecks.isSword(itemInHand) && permInstance.swords(attacker)) {
if (!configInstance.getSwordsPVP()) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getSwordsPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (permInstance.swordsBleed(attacker)) {
Swords.bleedCheck(attacker, target, plugin);
}
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.getInstance().serratedStrikes(attacker)) {
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 (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getAxesPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
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 (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getUnarmedPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
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 (targetType.equals(EntityType.PLAYER) && 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;
@@ -119,16 +156,28 @@ public class Combat {
Player master = (Player) wolf.getOwner();
PlayerProfile PPo = Users.getProfile(master);
if (Permissions.getInstance().taming(master)) {
if (Permissions.getInstance().fastFoodService(master)) {
if (!configInstance.getTamingPVP()) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getTamingPVE()) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (permInstance.taming(master)) {
if (permInstance.fastFoodService(master)) {
Taming.fastFoodService(PPo, wolf, event);
}
if (Permissions.getInstance().sharpenedclaws(master)) {
if (permInstance.sharpenedClaws(master)) {
Taming.sharpenedClaws(PPo, event);
}
if (Permissions.getInstance().gore(master)) {
if (permInstance.gore(master)) {
Taming.gore(PPo, event, master, plugin);
}
@@ -138,13 +187,38 @@ public class Combat {
break;
case ARROW:
archeryCheck((EntityDamageByEntityEvent) event, plugin);
if (!configInstance.getArcheryPVP() && ((Arrow) damager).getShooter().getType().equals(EntityType.PLAYER)) {
if (targetType.equals(EntityType.PLAYER) || (targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
if (!configInstance.getArcheryPVE() && !((Arrow) damager).getShooter().getType().equals(EntityType.PLAYER)) {
if (!targetType.equals(EntityType.PLAYER) || !(targetType.equals(EntityType.WOLF) && ((Wolf) target).isTamed())) {
return;
}
}
archeryCheck(event, plugin);
break;
}
if (targetType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event);
if (configInstance.getSwordsPVP() && damagerType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event);
}
if (configInstance.getSwordsPVE() && !damagerType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event);
}
if (configInstance.getAcrobaticsPVP() && damagerType.equals(EntityType.PLAYER)) {
Acrobatics.dodgeChecks(event);
}
if (configInstance.getAcrobaticsPVE() && !damagerType.equals(EntityType.PLAYER)) {
Acrobatics.dodgeChecks(event);
}
}
}
@@ -181,48 +255,46 @@ public class Combat {
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;
/* 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)) {
/* 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(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;
}
Archery.dazeCheck(defender, attacker);
if (target != attacker) {
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
}
}
}
@@ -246,7 +318,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 +341,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 +366,14 @@ 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 (Config.getInstance().getToolModsEnabled()) {
if (ItemChecks.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,11 +385,11 @@ public class Combat {
if (!(entity instanceof LivingEntity)) {
continue;
}
if (numberOfTargets <= 0) {
break;
}
switch (entity.getType()) {
case WOLF:
AnimalTamer tamer = ((Wolf) entity).getOwner();
@@ -319,50 +399,57 @@ public class Combat {
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;
default:
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 +468,7 @@ public class Combat {
double baseXP = 0;
if (target instanceof Player) {
if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
if (!configInstance.getExperienceGainsPlayerVersusPlayerEnabled()) {
return;
}
@@ -389,72 +476,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:

View File

@@ -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,"

View File

@@ -0,0 +1,41 @@
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) {
PlayerProfile PP = Users.getProfile(player);
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;
PP.modifySkill(st, newValue);
}
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've suffered a penalty to skills from death.");
}
public static void invokeVampirism(Player killer, Player defender) {
PlayerProfile PPk = Users.getProfile(killer);
PlayerProfile PPd = Users.getProfile(defender);
for(SkillType st : SkillType.values()) {
if(st.equals(SkillType.ALL))
continue;
int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D));
PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
}
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen knowledge from that player.");
}
}

View File

@@ -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()));
}
}

View File

@@ -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;
}
}
}
@@ -190,6 +242,21 @@ public class ItemChecks {
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
}
/**
* 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 is) {
if (customArmorEnabled && CustomArmorConfig.getInstance().customIDs.contains(is.getTypeId())) {
return true;
}
else {
return false;
}
}
/**
* Checks to see if an item is a leather armor piece.
*
@@ -276,6 +343,21 @@ public class ItemChecks {
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
}
/**
* 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 is) {
if (customToolsEnabled && CustomToolsConfig.getInstance().customIDs.contains(is.getTypeId())) {
return true;
}
else {
return false;
}
}
/**
* Checks to see if an item is a stone tool.
*
@@ -395,4 +477,3 @@ public class ItemChecks {
}
}
}

View File

@@ -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.

View File

@@ -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 (ItemChecks.isCustomTool(inHand)) {
tier = ModChecks.getToolFromItemStack(inHand).getTier();
}
return tier;
}

View File

@@ -0,0 +1,126 @@
package com.gmail.nossr50.util;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
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 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 ay if it exists, null otherwise
*/
public static CustomItem getArmorFromItemStack(ItemStack item) {
int id = item.getTypeId();
if (!armorInstance.customIDs.contains(id)) {
return null;
}
for (CustomItem armor : armorInstance.customItems) {
if (armor.getItemID() == id) {
return armor;
}
}
return null;
}
/**
* Get the custom tool associated with an item.
*
* @param item The item to check
* @return the armor if it exists, null otherwise
*/
public static CustomTool getToolFromItemStack(ItemStack item) {
int id = item.getTypeId();
if (!toolInstance.customIDs.contains(id)) {
return null;
}
for (CustomItem tool : toolInstance.customItems) {
if (tool.getItemID() == id) {
return (CustomTool) tool;
}
}
return null;
}
/**
* 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 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;
}
}
}

View File

@@ -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");
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills;
package com.gmail.nossr50.util;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
@@ -12,10 +12,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;
@@ -427,7 +423,7 @@ public class Skills {
/* FALLS THROUGH */
case GREEN_TERRA:
if (!ability.blockCheck(block.getType())) {
if (!ability.blockCheck(block)) {
activate = false;
break;
}

View File

@@ -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());
}

View File

@@ -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();
}

View File

@@ -0,0 +1,8 @@
package com.gmail.nossr50.util.blockmeta;
public class ChunkletManagerFactory {
public static ChunkletManager getChunkletManager() {
// TODO: Add in loading from config what type of manager we want.
return new HashChunkletManager();
}
}

View File

@@ -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();
}

View File

@@ -0,0 +1,8 @@
package com.gmail.nossr50.util.blockmeta;
public class ChunkletStoreFactory {
protected static ChunkletStore getChunkletStore() {
// TODO: Add in loading from config what type of store we want.
return new PrimitiveChunkletStore();
}
}

View File

@@ -0,0 +1,227 @@
package com.gmail.nossr50.util.blockmeta;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Block;
public class HashChunkletManager implements ChunkletManager {
private HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
public void chunkLoaded(int cx, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) return;
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) return;
for(int y = 1; y <= 4; y++) {
File yFile = new File(czDir, "" + y);
if(!yFile.exists()) {
continue;
} else {
ChunkletStore in = deserializeChunkletStore(yFile);
if(in != null) {
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
}
}
}
}
public void chunkUnloaded(int cx, int cz, World world) {
boolean found = false;
for(String key : store.keySet()) {
if(key.startsWith(world.getName() + "," + cx + "," + cz)) found = true;
}
if(!found) return;
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + cx);
if(!cxDir.exists()) cxDir.mkdir();
File czDir = new File(cxDir, "" + cz);
if(!czDir.exists()) czDir.mkdir();
for(int y = 1; y <= 4; y++) {
File yFile = new File(czDir, "" + y);
if(store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) {
ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + y);
serializeChunkletStore(out, yFile);
}
}
}
public void saveWorld(World world) {
String worldName = world.getName();
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
for(String key : store.keySet()) {
String[] info = key.split(",");
if(worldName.equals(info[0])) {
File cxDir = new File(dataDir, "" + info[1]);
if(!cxDir.exists()) cxDir.mkdir();
File czDir = new File(cxDir, "" + info[2]);
if(!czDir.exists()) czDir.mkdir();
File yFile = new File(czDir, "" + info[3]);
serializeChunkletStore(store.get(key), yFile);
}
}
}
public void unloadWorld(World world) {
saveWorld(world);
String worldName = world.getName();
for(String key : store.keySet()) {
String tempWorldName = key.split(",")[0];
if(tempWorldName.equals(worldName)) {
store.remove(key);
}
}
}
public void saveAll() {
for(World world : Bukkit.getWorlds()) {
saveWorld(world);
}
}
public void unloadAll() {
saveAll();
for(World world : Bukkit.getWorlds()) {
unloadWorld(world);
}
}
public boolean isTrue(int x, int y, int z, World world) {
int cx = x / 16;
int cz = z / 16;
int cy = y / 64;
if(!store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) return false;
ChunkletStore check = store.get(world.getName() + "," + cx + "," + cz + "," + cy);
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
int iy = Math.abs(y) % 64;
return check.isTrue(ix, iy, iz);
}
public boolean isTrue(Block block) {
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
}
public void setTrue(int x, int y, int z, World world) {
int cx = x / 16;
int cz = z / 16;
int cy = y / 64;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
int iy = Math.abs(y) % 64;
ChunkletStore cStore;
if(!store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
cStore = ChunkletStoreFactory.getChunkletStore();
store.put(world.getName() + "," + cx + "," + cz + "," + cy, cStore);
}
cStore = store.get(world.getName() + "," + cx + "," + cz + "," + cy);
cStore.setTrue(ix, iy, iz);
}
public void setTrue(Block block) {
setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
}
public void setFalse(int x, int y, int z, World world) {
int cx = x / 16;
int cz = z / 16;
int cy = y / 64;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
int iy = Math.abs(y) % 64;
ChunkletStore cStore;
if(!store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
return; // No need to make a store for something we will be setting to false
}
cStore = store.get(world.getName() + "," + cx + "," + cz + "," + cy);
cStore.setFalse(ix, iy, iz);
}
public void setFalse(Block block) {
setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld());
}
public void cleanUp() {
for(String key : store.keySet()) {
if(store.get(key).isEmpty()) {
String[] info = key.split(",");
File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + info[1]);
if(!cxDir.exists()) continue;
File czDir = new File(cxDir, "" + info[2]);
if(!czDir.exists()) continue;
File yFile = new File(czDir, "" + info[3]);
yFile.delete();
//Delete empty directories
if(czDir.list().length == 0) czDir.delete();
if(cxDir.list().length == 0) cxDir.delete();
}
}
}
/**
* @param cStore ChunkletStore to save
* @param location Where on the disk to put it
*/
private void serializeChunkletStore(ChunkletStore cStore, File location) {
try {
FileOutputStream fileOut = new FileOutputStream(location);
ObjectOutputStream objOut = new ObjectOutputStream(fileOut);
objOut.writeObject(cStore);
objOut.close();
fileOut.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* @param location Where on the disk to read from
* @return ChunkletStore from the specified location
*/
private ChunkletStore deserializeChunkletStore(File location) {
ChunkletStore storeIn = null;
try {
FileInputStream fileIn = new FileInputStream(location);
ObjectInputStream objIn = new ObjectInputStream(fileIn);
storeIn = (ChunkletStore) objIn.readObject();
objIn.close();
fileIn.close();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return storeIn;
}
}

View File

@@ -0,0 +1,31 @@
package com.gmail.nossr50.util.blockmeta;
public class PrimitiveChunkletStore implements ChunkletStore {
private static final long serialVersionUID = -3453078050608607478L;
/** X, Z, Y */
private boolean[][][] store = new boolean[16][16][64];
public boolean isTrue(int x, int y, int z) {
return store[x][z][y];
}
public void setTrue(int x, int y, int z) {
store[x][z][y] = true;
}
public void setFalse(int x, int y, int z) {
store[x][z][y] = false;
}
public boolean isEmpty() {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
for(int y = 0; y < 64; y++) {
if(store[x][z][y]) return false;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,128 @@
package net.shatteredlands.shatt.backup;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
public class ZipLibrary {
private final static mcMMO plugin = mcMMO.p;
private static String BackupDirectory = plugin.mainDirectory + "backup" + File.separator;
private static File BackupDir = new File(BackupDirectory);
private static File FlatFileDirectory = new File(plugin.flatFileDirectory);
private static File ModFileDirectory = new File(plugin.modDirectory);
private static File UsersFile = new File(plugin.usersFile);
private static File ConfigFile = new File(plugin.mainDirectory + "config.yml");
private static File TreasuresFile = new File(plugin.mainDirectory + "treasures.yml");
private static File Leaderboards = new File(plugin.leaderboardDirectory);
public static void mcMMObackup() throws IOException {
if (Config.getInstance().getUseMySQL()) {
System.out.println("No Backup performed, in SQL Mode.");
return;
}
try {
if (BackupDir.mkdir()) {
mcMMO.p.getLogger().info("Created Backup Directory.");
}
} catch (Exception e) {
mcMMO.p.getLogger().severe(e.toString());
}
//Generate the proper date for the backup filename
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
File fileZip = new File(BackupDirectory + File.separator + dateFormat.format(date) + ".zip");
//Create the Source List, and add directories/etc to the file.
List<File> sources = new ArrayList<File>();
sources.add(FlatFileDirectory);
sources.add(ModFileDirectory);
sources.add(UsersFile);
sources.add(ConfigFile);
sources.add(TreasuresFile);
sources.add(Leaderboards);
//Actually do something
System.out.println("Backing up your mcMMO Configuration... ");
packZip(fileZip, sources);
}
private static void packZip(File output, List<File> sources) throws IOException {
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(output));
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
for (File source : sources) {
if (source.isDirectory()) {
zipDir(zipOut, "", source);
}
else {
zipFile(zipOut, "", source);
}
}
zipOut.flush();
zipOut.close();
System.out.println("Backup Completed.");
}
private static String buildPath(String path, String file) {
if (path == null || path.isEmpty()) {
return file;
}
else {
return path + File.separator + file;
}
}
private static void zipDir(ZipOutputStream zos, String path, File dir) throws IOException {
if (!dir.canRead()) {
System.out.println("Cannot read " + dir.getCanonicalPath() + " (Maybe because of permissions?)");
return;
}
File[] files = dir.listFiles();
path = buildPath(path, dir.getName());
for (File source : files) {
if (source.isDirectory()) {
zipDir(zos, path, source);
}
else {
zipFile(zos, path, source);
}
}
}
private static void zipFile(ZipOutputStream zos, String path, File file) throws IOException {
if (!file.canRead()) {
System.out.println("Cannot read " + file.getCanonicalPath() + "(File Permissions?)");
return;
}
zos.putNextEntry(new ZipEntry(buildPath(path, file.getName())));
FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[4092];
int byteCount = 0;
while ((byteCount = fis.read(buffer)) != -1) {
zos.write(buffer, 0, byteCount);
}
fis.close();
zos.closeEntry();
}
}

View File

@@ -0,0 +1,75 @@
#
# Settings for Boots
###
Boots:
Boot_1:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
Boot_2:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
#
# Settings for Chestplates
###
Chestplates:
Chestplate_1:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
Chestplate_2:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
#
# Settings for Helmets
###
Helmets:
Helmet_1:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
Helmet_2:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
#
# Settings for Leggings
###
Leggings:
Legging_1:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
Legging_2:
ID: 999
Repairable: true
Repair_Material_ID: 99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999

View File

@@ -0,0 +1,89 @@
#
# Settings for Custom Excavation Blocks
###
Excavation:
Block_1:
ID: 999
Data_Value: 0
XP_Gain: 99
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
Block_2:
ID: 999
Data_Value: 0
XP_Gain: 99
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
#
# Settings for Custom Herbalism Blocks
###
Herbalism:
Block_1:
ID: 999
Data_Value: 0
XP_Gain: 99
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
Block_2:
ID: 999
Data_Value: 0
XP_Gain: 99
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
#
# Settings for Custom Mining Blocks
###
Mining:
Block_1:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Ore: true
Tier: 1
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
Block_2:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Ore: true
Tier: 1
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
#
# Settings for Custom Woodcutting Blocks
###
Woodcutting:
Block_1:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Log: true
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1
Block_2:
ID: 999
Data_Value: 0
XP_Gain: 99
Is_Log: true
Drop_Item: false
Drop_Item_ID: 999
Drop_Item_Data_Value: 0
Drop_Item_Amount: 1

Some files were not shown because too many files have changed in this diff Show More