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

Compare commits

...

173 Commits

Author SHA1 Message Date
bm01
dc48d467f5 Return to HashMap! 2012-06-24 22:46:45 +02:00
nossr50
0b0390620e Whoops :D 2012-06-24 13:26:49 -07:00
nossr50
24eb34c182 Back to the old way of doing things 2012-06-24 13:26:21 -07:00
nossr50
1a5bd1b6a2 Getting ready for release 2012-06-24 12:59:54 -07:00
nossr50
ab7b6ce460 Fixed bug that caused NPE when trying to compare null parties 2012-06-24 12:48:03 -07:00
GJ
c4cd677021 Added new methods to replace deprecation in latest Bukkit. Commented out
until RB.
2012-06-23 12:13:51 -04:00
bm01
6b84d39dda Fixed AE abilities not being applied correctly 2012-06-22 23:10:17 +02:00
bm01
e61342177d Simplified combat ability checks 2012-06-22 20:20:28 +02:00
bm01
d51fa92b46 Made 'shooterless' arrows dodgeable 2012-06-22 19:39:14 +02:00
bm01
3e20dc7de6 combatChecks optimization 2012-06-22 18:54:49 +02:00
GJ
dce1d7ba39 Fixed calculations on Reduced Cooldown perk 2012-06-22 10:57:51 -04:00
GJ
adffea1d52 Increased the seconds for activation time perk. 2012-06-22 10:13:37 -04:00
GJ
20b73dcc84 Fixed not checking if an Entity was a LivingEntity before applying the
Counter-Attack ability.
2012-06-22 09:47:18 -04:00
GJ
b331fa353b Added increased activate time donor perks 2012-06-21 23:01:02 -04:00
GJ
9fe14609af Locale update. 2012-06-21 22:26:29 -04:00
GJ
f6973b8907 Changelog update. 2012-06-21 21:51:43 -04:00
GJ
8738036f6f Added Reduced Cooldown perk for donors. 2012-06-21 21:50:48 -04:00
GJ
fce02dc0e5 Fixed possible NPE with Acrobatics fall checks. 2012-06-21 21:04:19 -04:00
GJ
2bef0e833f Rework of Swords handling 2012-06-21 09:04:45 -04:00
GJ
9040a2a2e3 Optimizations to Combat.java 2012-06-18 08:50:14 -04:00
NuclearW
4407ed0a6f Fixed bug with Chunklets not being reloaded on /reload 2012-06-16 21:43:04 -04:00
GJ
09721518b0 Fixed Unarmed using Taming levels.
My copy-paste skills are failing.
2012-06-15 11:11:57 -04:00
GJ
8ad6337dde Avoid calling the same thing 3 times. 2012-06-15 10:58:38 -04:00
bm01
271740d2ac Re-added mcMMO.getPlayerProfile(Player) 2012-06-15 10:03:00 +02:00
GJ
48dd537257 More reworking of Unarmed, renamed ArcheryBonusDamageEventHandler for
clarity's sake.
2012-06-14 23:59:36 -04:00
GJ
77b4aaa50d Updating Unarmed (WIP) 2012-06-14 23:59:35 -04:00
bm01
1014316581 Whoops D: 2012-06-15 03:32:46 +02:00
bm01
739cd83155 Forgot to cancel the task 2012-06-15 03:30:36 +02:00
bm01
df08bc4da0 Changelog update 2012-06-15 02:56:36 +02:00
bm01
55e832d4f6 Do not track arrow if the bow has Infinity 2012-06-15 02:53:11 +02:00
bm01
032472dcb3 Avoid unnecessary iteration 2012-06-15 02:46:41 +02:00
bm01
68bf93d1ac Remove inactive entities from the arrow tracker 2012-06-15 02:43:13 +02:00
bm01
ba133f94fc Extra equals 2012-06-15 02:34:24 +02:00
bm01
064c16f4d7 Reverted last commit 2012-06-15 02:14:53 +02:00
bm01
5a394ee744 Fixed killed entities not being removed from arrowTracker 2012-06-15 02:08:15 +02:00
bm01
3bc2f5dc55 Fixed Archery using Taming skill level 2012-06-15 02:06:06 +02:00
GJ
6f63818e5f Check for the block before throwing the fake break event. 2012-06-14 10:24:58 -04:00
GJ
a5d7bee939 Spacing 2012-06-14 00:01:31 -04:00
bm01
9d396162f1 Hardcore.java cleanup 2012-06-14 01:22:35 +02:00
bm01
4a0d9a96ab Fixed minor bug with Vampirism notification 2012-06-14 00:48:40 +02:00
GJ
9f65e5a9ab PermissionsHandler was a stupid idea. 2012-06-13 12:31:20 -04:00
GJ
c71f4e438b Organize imports. 2012-06-13 08:54:02 -04:00
GJ
14d13eb4c7 Archery rework. 2012-06-13 08:53:18 -04:00
GJ
29c629eb22 WIP on Archery rework. 2012-06-12 21:36:17 -04:00
bm01
050b794b42 Fixed NPE with /mmoedit 2012-06-12 23:31:32 +02:00
NuclearW
89b5f8c275 Changelog 2012-06-12 17:01:18 -04:00
NuclearW
f589197321 Load the lowest chunklets right now.
Thanks for @Glitchfinder for finding this glitch.

Closes #205
2012-06-12 17:00:05 -04:00
NuclearW
09575a68f0 Handle corrupt chunklets by making a new one and not throw stacktrace 2012-06-12 16:45:28 -04:00
NuclearW
c1b838e356 Typo fix 2012-06-12 16:45:00 -04:00
GJ
8ed2696315 Fix issue with trying to remove all of the item in hand. 2012-06-12 15:11:13 -04:00
GJ
ab138bdba2 Javadocs, added Lighting to the damage types affected by Shock Proof 2012-06-12 14:48:28 -04:00
GJ
5ba9fb78fd More tweaks to Taming. 2012-06-12 14:42:38 -04:00
GJ
2d47447375 Begin rework of Taming skill 2012-06-12 11:07:51 -04:00
GJ
d9eaede4c2 Spacing 2012-06-12 11:07:27 -04:00
GJ
c6db11a10b Use EntityDamage event instead of EntityDamageByEnitity 2012-06-12 10:23:34 -04:00
GJ
2225e542ad Spacing issues. 2012-06-12 09:20:39 -04:00
GJ
975e13d45f Tweaked how we check XP gain permissions. 2012-06-12 08:10:18 -04:00
bm01
534a165c45 Tweaked a few things 2012-06-12 06:18:00 +02:00
bm01
5cff6ed67b Removed xpGainATS, it actually never worked 2012-06-12 05:59:26 +02:00
bm01
3448733834 Removed unused variable 2012-06-12 05:40:07 +02:00
bm01
c382c95d24 Re-added respawnATS 2012-06-12 05:38:32 +02:00
GJ
0034226fa7 Reorder constructors to avoid errors 2012-06-11 21:03:49 -04:00
GJ
5f067a6bb5 More tweaks to Acrobatics. 2012-06-11 20:37:09 -04:00
GJ
6ab1996440 Reworking of Acrobatics, plus an Acrobatics bugfix. 2012-06-11 16:11:23 -04:00
bm01
5bff6d63f2 Removed unneeded reference 2012-06-11 08:26:48 +02:00
bm01
5fe227b874 Forgot to change getParties 2012-06-11 08:26:22 +02:00
bm01
cbaf2f8370 More work on parties 2012-06-11 07:50:10 +02:00
bm01
393ac886e2 Removed unneeded method 2012-06-10 06:57:55 +02:00
bm01
c9082083d1 Merged ProfileSaveTask and RemoveProfileFromMemory 2012-06-10 06:56:39 +02:00
bm01
5d0d89e74d Changed party name restriction 2012-06-09 22:24:04 +02:00
bm01
e9c3583fd8 Added few forgotten things 2012-06-09 20:11:11 +02:00
bm01
81eadc1418 No longer use/save party name in database and users flat file 2012-06-09 19:48:18 +02:00
bm01
dfff0efc0b Cleanup 2012-06-09 19:29:44 +02:00
bm01
3732db2226 Reworked Party 2012-06-09 03:08:36 +02:00
bm01
e9ccdcfbbe Missing space! 2012-06-08 20:04:45 +02:00
bm01
01345a5dc4 Fixed /mcremove on existing PlayerProfile 2012-06-08 20:03:02 +02:00
bm01
90c8e57ed7 Reworked a little Users.java 2012-06-08 20:00:02 +02:00
GJ
d644b4c331 Fixed NPE with repairing items that rely on metadata. 2012-06-06 18:27:52 -04:00
GJ
2f15c71412 Because making it upper case broke all the things. 2012-06-06 18:02:22 -04:00
GJ
0a44a74f59 Cleanup (Yes, I'm that picky). 2012-06-06 16:49:42 -04:00
bm01
f876fe8d25 Made API classes 'statics' 2012-06-06 22:04:21 +02:00
GJ
290032646f Protect our hashmaps from bad people. 2012-06-06 15:38:44 -04:00
GJ
e5d2ed4bb2 Because lowercase class names are evil. 2012-06-06 14:49:07 -04:00
GJ
e9ea0e0389 Created a variable for player name. 2012-06-06 09:32:01 -04:00
bm01
35565bb021 Removed PlayerProfile save on User.removeUser, it's already done in RemoveProfileFromMemoryTask 2012-06-06 02:20:33 +02:00
bm01
56aff1d191 Replaced playerName fields in PlayerProfile and Users by the Player object 2012-06-06 02:03:27 +02:00
GJ
b8be1d1866 Fix the Javadocs 2012-06-05 11:05:51 -04:00
GJ
1d7d2cd52e Make it static. 2012-06-05 11:05:44 -04:00
GJ
71446a12af Static ALL the things! 2012-06-05 10:42:56 -04:00
GJ
ca6cafaebd Cleanup 2012-06-05 10:42:56 -04:00
GJ
c97be335ee Avoid using mcMMO.p when we can 2012-06-05 10:42:56 -04:00
GJ
fd1227b87e No need for public constructor 2012-06-05 10:42:56 -04:00
bm01
7ef72c501e Cleanup 2012-06-05 16:32:26 +02:00
GJ
f7ee96aa99 Fixed bug where admin chat was displayed to the whole server. 2012-06-05 10:19:23 -04:00
GJ
b84478898d Cleanup. 2012-06-05 10:18:05 -04:00
GJ
6afe0e8a34 Organize imports. 2012-06-05 10:13:10 -04:00
GJ
6e4f4b5c8d More cleanup. 2012-06-05 10:07:45 -04:00
bm01
f86fe4a138 Changelog update 2012-06-05 16:03:08 +02:00
bm01
63c663b8c1 Fixed Archery PVP/PVE enablement not being used properly 2012-06-05 16:00:32 +02:00
bm01
a1296596fa Fixed possible NPE when a projectile doesn't have a shooter 2012-06-05 16:00:27 +02:00
GJ
1cca4de9e5 Cleanup! 2012-06-05 09:57:10 -04:00
GJ
7ada587df3 More Spout tool stuff. 2012-06-04 10:36:24 -04:00
GJ
1e58c32a5f Change XP processing to use a single function. 2012-06-04 09:30:51 -04:00
GJ
2a27048174 Functions that start with capital letters are bad. 2012-06-04 09:08:41 -04:00
GJ
2b291954cf Javadocs. 2012-06-04 09:03:25 -04:00
GJ
8f8bfc62ca Cleanup. 2012-06-04 08:51:10 -04:00
GJ
38d4d448a9 Remove unused imports. 2012-06-04 08:46:12 -04:00
nossr50
d5d11ca4bd Whoops 2012-06-03 15:39:13 -07:00
nossr50
e3e400f376 This should make us AntiCheat friendly. 2012-06-03 14:38:33 -07:00
GJ
6637758ad0 Fixed Spout item checks. 2012-06-01 15:29:16 -04:00
GJ
41e9bd3cb5 WIP - Spout custom tool support 2012-05-31 16:02:11 -04:00
GJ
c2d1909379 Changelog update. 2012-05-31 16:00:20 -04:00
GJ
77688f297f Fixed a few permissions errors. 2012-05-31 15:23:38 -04:00
GJ
714f665cc7 Woodcutting to SkillCommand 2012-05-31 15:15:00 -04:00
GJ
ec138d5741 Unarmed to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
560e5aa19a Taming to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
ad162f3366 Swords to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
5d07830339 Repair to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
b310d25ee3 Cleanup. 2012-05-31 15:14:59 -04:00
GJ
443ccbd807 Mining to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
8cdecf80c7 Herbalism to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
a16d5435de Removed unneeded function call. 2012-05-31 15:14:59 -04:00
GJ
ec02422226 Fishing to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
cc5d438550 Excavation to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
806d116501 Axes to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
066c9d9fec Archery to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
5b3b9fbc30 Tweak the way SkillCommands are constructed. 2012-05-31 15:14:58 -04:00
GJ
d15e189b7c Acrobatics to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
1bd9974f89 Abstract Skill Commands 2012-05-31 15:14:58 -04:00
NuclearW
90296d87df Similarly return admin chat to ye olden method 2012-05-30 11:18:47 -04:00
NuclearW
75b287771a Return party chat to ye olden method 2012-05-30 11:18:46 -04:00
GJ
5765504796 Locale updates. 2012-05-30 11:11:07 -04:00
GJ
dda8c0c9e0 Fixed bug with Tree Feller changing durability too soon. 2012-05-30 10:48:25 -04:00
GJ
ce9d668602 Fixed bug with locale strings and party teleport. 2012-05-30 10:41:22 -04:00
NuclearW
39c2c5f25f Handle EOFException in Chunklets by returning a new empty ChunkletStore and printing an error. 2012-05-29 21:02:36 -04:00
nossr50
12a7d794b4 Always forget the changelog 2012-05-28 17:02:02 -04:00
nossr50
ff8b0300ae Make the MOTD prettier about the perks 2012-05-28 16:49:21 -04:00
NuclearW
f882df4cb7 Fix this yaml error 2012-05-28 16:43:06 -04:00
nossr50
e1300005cb Notify users of their perks on login (if MOTD enabled) 2012-05-28 13:14:10 -07:00
nossr50
e599ab9214 Added permissions that will grant users 4x 3x or 2x XP 2012-05-28 13:07:52 -07:00
GJ
92acf62884 More mod fixes for Woodcutting. 2012-05-27 14:40:35 -04:00
GJ
c2fb57fce9 Fix Tree Feller not working with custom axes 2012-05-27 14:31:37 -04:00
GJ
3699d26e5d Only try to back up the mod files if they exist... 2012-05-27 10:23:13 -04:00
GJ
6eb0159ea1 More tracking of falling sand/gravel. (WIP) 2012-05-27 10:21:00 -04:00
GJ
433913c77a Another fix for falling sand/gravel tracking issues. 2012-05-27 09:42:38 -04:00
bm01
d955feef61 Fixed piston tracking 2012-05-27 10:34:04 +02:00
GJ
5377b9b618 Remove debug messages. 2012-05-26 21:11:50 -04:00
GJ
5c9371c575 Fixed falling sand/gravel stuff not being tracked 2012-05-26 19:52:24 -04:00
GJ
23d916f191 Fixed dupe exploit with pistons (again). 2012-05-26 10:50:12 -04:00
GJ
35d4914518 This has to be Arrow to keep Potions from giving XP. 2012-05-24 15:26:01 -04:00
GJ
eb2ec71d2b More priority tweaks. 2012-05-24 14:17:51 -04:00
GJ
dc50758dc9 Minor priority tweaks to the Spout XP bar. 2012-05-24 14:02:23 -04:00
GJ
9775d71c28 Cleanup. 2012-05-24 10:35:46 -04:00
GJ
c40e4ee9ee Cleanup. 2012-05-24 10:30:07 -04:00
GJ
2b469c385c Changelog update 2012-05-24 08:39:13 -04:00
GJ
a104fe45aa Fix for NoCheatPlus fight.noswing checks 2012-05-24 08:38:44 -04:00
bm01
257df25a67 Fixed NPE, Config.defaulthud was used instead of SpoutConfig.defaulthud 2012-05-24 06:58:11 +02:00
bm01
2a977557c2 Made sure that SpoutConfig.load is called when the instance is created, for safety 2012-05-24 06:18:43 +02:00
bm01
d0e9f03311 Reverted last commit from NuclearW 2012-05-24 05:29:05 +02:00
bm01
97ca699170 Removed unneeded method override 2012-05-24 05:27:29 +02:00
NuclearW
702537e8fd We don't need this 2012-05-23 15:33:08 -04:00
NuclearW
83a3488d0d Because loading a config we hadn't made yet makes sense 2012-05-23 15:32:58 -04:00
GJ
450e938092 Change Spout Config file to only load if Spout is enabled.
Removed unused imports.
2012-05-23 14:31:03 -04:00
GJ
b88e076f27 Updates to config loading. 2012-05-23 13:52:33 -04:00
GJ
0fe90df01e Cleanup. 2012-05-23 11:16:23 -04:00
GJ
66ad909908 Cleanup. 2012-05-23 11:08:56 -04:00
GJ
77d74717d2 Moved all Spout checks into one listener. 2012-05-23 11:06:02 -04:00
GJ
63f683982f Moved Spout stuff to its own config file. 2012-05-23 10:50:47 -04:00
GJ
9525ce8299 Cleanup. 2012-05-23 09:35:16 -04:00
GJ
d7b8ec1274 Cleanup. 2012-05-23 07:33:19 -04:00
GJ
96cd16faf7 Cleanup 2012-05-23 07:32:03 -04:00
NuclearW
9ddc7501fe Derp 2012-05-22 09:16:40 -04:00
NuclearW
301c496fb2 Onward to 1.3.09 2012-05-22 08:45:21 -04:00
157 changed files with 6206 additions and 4559 deletions

View File

@@ -7,6 +7,40 @@ Key:
! Change
- Removal
Version 1.3.09
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
+ Added reduced cooldown permission nodes as special perks (1/4, 1/3, 1/2 cooldown)
+ Added increased activation time permissions nodes as special perks (+4, +8, and +12 seconds)
+ Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
+ Added offline party members to the list displayed by /party
+ Added possibility to kick offline members from parties
= Fixed bug that would cause a NPE for players that had no parties
= Fixed Vampirism not notifying the correct amount of stolen levels
= Fixed bug with Acrobatics not saving you from deadly falls
= Fixed /mcremove being applied only after a reload
= Fixed Archery PVE disablement not working properly
= Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter
= Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing)
= Fixed tiny memory leak concerning Archery
= Fixed bug where you could receive Archery XP from Potions
= Fixed bug where Chunklets for the < 64 y coordinates would not be properly loaded
= Fixed exploit with block duplication via piston pushing
= Fixed bug with falling sand/gravel not being tracked
= Fixed bug with Tree Feller not working with custom axes
= Fixed bug with locale strings when trying to teleport to a non-existent player
= Fixed bug with Tree Feller changing durability before checking for axe splintering
= Fixed bug with Repair Mastery permission due to typo
= Fixed bug with repairing items that use metadata
= Fixed bug with Chunklets not being reloaded on /reload
= Fixed possible NPE when falling with no item in hand
! API methods can now only be used in a static way
! Arrows shot from a bow having the Infinity enchantment can no longer be retrieved
! Arrows that aren't shot by an entity are now able to be dodged (currently only from dispensers)
! Changed Spout settings to be in their own config file (spout.yml)
! Changed file format for parties (parties.yml), previous files are no longer used
! Changed mcMMO to inform on corrupt Chunklets and make new ones
Version 1.3.08
+ Added more notifications about Vampirism and Hardcore mode on player death
+ Added information about Hardcore mode when joining a server running Hardcore mode

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.3.08</version>
<version>1.3.09</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>

View File

@@ -9,7 +9,10 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ChatAPI {
public final class ChatAPI {
private ChatAPI() {}
/**
* Send a message to all members of a party
* </br>
@@ -19,7 +22,7 @@ public class ChatAPI {
* @param party The name of the party to send to
* @param message The message to send
*/
public void sendPartyChat(String sender, String party, String message) {
public static void sendPartyChat(String sender, String party, String message) {
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
@@ -33,7 +36,7 @@ public class ChatAPI {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Users.getProfile(player).inParty()) {
if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) {
if (Users.getProfile(player).getParty().getName().equalsIgnoreCase(chatEvent.getParty())) {
player.sendMessage(pPrefix + chatEvent.getMessage());
}
}
@@ -48,7 +51,7 @@ public class ChatAPI {
* @param sender The name of the sender to display in the chat
* @param message The message to send
*/
public void sendAdminChat(String sender, String message) {
public static void sendAdminChat(String sender, String message) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);

View File

@@ -6,7 +6,9 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class ExperienceAPI {
public final class ExperienceAPI {
private ExperienceAPI() {}
/**
* Check the XP of a player. This should be called after giving XP to process level-ups.
@@ -14,12 +16,12 @@ public class ExperienceAPI {
* @param player The player to check
* @param skillType The skill to check
*/
private void checkXP(Player player, SkillType skillType) {
private static void checkXP(Player player, SkillType skillType) {
if (skillType.equals(SkillType.ALL)) {
Skills.XpCheckAll(player);
Skills.xpCheckAll(player, Users.getProfile(player));
}
else {
Skills.XpCheckSkill(skillType, player);
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
}
}
@@ -32,7 +34,7 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addRawXP(Player player, SkillType skillType, int XP) {
public static void addRawXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverride(skillType, XP);
checkXP(player, skillType);
}
@@ -46,7 +48,7 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addMultipliedXP(Player player, SkillType skillType, int XP) {
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverrideBonus(skillType, XP);
checkXP(player, skillType);
}
@@ -60,8 +62,8 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXP(player, skillType, XP);
public static void addXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXP(skillType, XP);
checkXP(player, skillType);
}
@@ -74,7 +76,7 @@ public class ExperienceAPI {
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*/
public int getXP(Player player, SkillType skillType) {
public static int getXP(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillXpLevel(skillType);
}
@@ -87,7 +89,7 @@ public class ExperienceAPI {
* @param skillType The skill to get the XP amount for
* @return the amount of XP left before leveling up a specifc skill
*/
public int getXPToNextLevel(Player player, SkillType skillType) {
public static int getXPToNextLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getXpToLevel(skillType);
}
@@ -101,7 +103,7 @@ public class ExperienceAPI {
* @param levels Number of levels to add
* @param notify True if this should fire a level up notification, false otherwise.
*/
public void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
Users.getProfile(player).addLevels(skillType, levels);
if (notify) {
@@ -118,7 +120,7 @@ public class ExperienceAPI {
* @param skillType The skill to get the level for
* @return the level of a given skill
*/
public int getLevel(Player player, SkillType skillType) {
public static int getLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillLevel(skillType);
}
@@ -130,7 +132,7 @@ public class ExperienceAPI {
* @param player The player to get the power level for
* @return the power level of the player
*/
public int getPowerLevel(Player player) {
public static int getPowerLevel(Player player) {
return Users.getProfile(player).getPowerLevel();
}
}

View File

@@ -1,13 +1,16 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PartyAPI {
public final class PartyAPI {
private PartyAPI() {}
/**
* Get the name of the party a player is in.
@@ -17,8 +20,8 @@ public class PartyAPI {
* @param player The player to check the party name of
* @return the name of the player's party
*/
public String getPartyName(Player player) {
return Users.getProfile(player).getParty();
public static String getPartyName(Player player) {
return Users.getProfile(player).getParty().getName();
}
/**
@@ -29,7 +32,7 @@ public class PartyAPI {
* @param player The player to check
* @return true if the player is in a party, false otherwise
*/
public boolean inParty(Player player) {
public static boolean inParty(Player player) {
return Users.getProfile(player).inParty();
}
@@ -42,19 +45,19 @@ public class PartyAPI {
* @param playerb The second player to check
* @return true if the two players are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb) {
return Party.getInstance().inSameParty(playera, playerb);
public static boolean inSameParty(Player playera, Player playerb) {
return PartyManager.getInstance().inSameParty(playera, playerb);
}
/**
* Get a list of all current party names.
* Get a list of all current parties.
* </br>
* This function is designed for API usage.
*
* @return the list of parties.
*/
public ArrayList<String> getParties() {
return Party.getInstance().getParties();
public static List<Party> getParties() {
return PartyManager.getInstance().getParties();
}
/**
@@ -65,8 +68,8 @@ public class PartyAPI {
* @param player The player to add to the party
* @param partyName The party to add the player to
*/
public void addToParty(Player player, String partyName) {
Party.getInstance().addToParty(player, Users.getProfile(player), partyName, false, null);
public static void addToParty(Player player, String partyName) {
PartyManager.getInstance().addToParty(player.getName(), Users.getProfile(player), PartyManager.getInstance().getParty(partyName)); //TODO this will throw a NPE if the party doesn't exist
}
/**
@@ -76,8 +79,8 @@ public class PartyAPI {
*
* @param player The player to remove
*/
public void removeFromParty(Player player) {
Party.getInstance().removeFromParty(player, Users.getProfile(player));
public static void removeFromParty(Player player) {
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
}
/**
@@ -88,8 +91,8 @@ public class PartyAPI {
* @param partyName The party name
* @return the leader of the party
*/
public Player getPartyLeader(String partyName) {
return Party.getInstance().getPartyLeader(partyName);
public static String getPartyLeader(String partyName) {
return PartyManager.getInstance().getPartyLeader(partyName);
}
/**
@@ -100,8 +103,8 @@ public class PartyAPI {
* @param partyName The name of the party to set the leader of
* @param player The player to set as leader
*/
public void setPartyLeader(String partyName, String player) {
Party.getInstance().setPartyLeader(partyName, player);
public static void setPartyLeader(String partyName, String player) {
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
}
/**
@@ -112,8 +115,8 @@ public class PartyAPI {
* @param player The player to check
* @return all the players in the player's party
*/
public ArrayList<Player> getAllMembers(Player player) {
return Party.getInstance().getAllMembers(player);
public static List<String> getAllMembers(Player player) {
return PartyManager.getInstance().getAllMembers(player);
}
/**
@@ -124,8 +127,8 @@ public class PartyAPI {
* @param partyName The party to check
* @return all online players in this party
*/
public ArrayList<Player> getOnlineMembers(String partyName) {
return Party.getInstance().getOnlineMembers(partyName);
public static List<Player> getOnlineMembers(String partyName) {
return PartyManager.getInstance().getOnlineMembers(partyName);
}
/**
@@ -136,7 +139,7 @@ public class PartyAPI {
* @param player The player to check
* @return all online players in the player's party
*/
public ArrayList<Player> getOnlineMembers(Player player) {
return Party.getInstance().getOnlineMembers(player);
public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getInstance().getOnlineMembers(player);
}
}

View File

@@ -0,0 +1,54 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.ToolType;
public final class SpoutToolsAPI {
private SpoutToolsAPI() {}
public static List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
public static List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
public static List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
public static List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
public static List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
/**
* Add a custom Spout tool to mcMMO for XP gain & ability use.
* </br>
* This function is designed for API usage.
*
* @param spoutTool The tool to add
* @param type The type of tool to add
*/
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
switch (type) {
case AXE:
spoutAxes.add(spoutTool);
break;
case HOE:
spoutHoes.add(spoutTool);
break;
case PICKAXE:
spoutPickaxes.add(spoutTool);
break;
case SHOVEL:
spoutShovels.add(spoutTool);
break;
case SWORD:
spoutSwords.add(spoutTool);
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,85 @@
package com.gmail.nossr50.commands;
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.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 abstract class SkillCommand implements CommandExecutor {
private SkillType skill;
private String skillString;
private String permission;
protected Player player;
protected PlayerProfile profile;
protected float skillValue;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected Permissions permInstance = Permissions.getInstance();
public SkillCommand(SkillType skill) {
this.skill = skill;
this.skillString = Misc.getCapitalized(skill.toString());
this.permission = "mcmmo.skills." + skillString.toLowerCase();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, permission)) {
return true;
}
player = (Player) sender;
profile = Users.getProfile(player);
skillValue = profile.getSkillLevel(skill);
dataCalculations();
permissionsCheck();
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
if (effectsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
effectsDisplay();
if (statsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
statsDisplay();
Page.grabGuidePageForSkill(skill, player, args);
return true;
}
protected abstract void dataCalculations();
protected abstract void permissionsCheck();
protected abstract boolean effectsHeaderPermissions();
protected abstract void effectsDisplay();
protected abstract boolean statsHeaderPermissions();
protected abstract void statsDisplay();
}

View File

@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
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.Misc;
@@ -47,7 +48,8 @@ public class AddxpCommand implements CommandExecutor {
xp = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
PlayerProfile profile = Users.getProfile(modifiedPlayer);
profile.addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -59,10 +61,10 @@ public class AddxpCommand implements CommandExecutor {
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
Skills.xpCheckAll(modifiedPlayer, profile);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
}
}
else {
@@ -78,8 +80,9 @@ public class AddxpCommand implements CommandExecutor {
case 3:
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
String playerName = modifiedPlayer.getName();
PlayerProfile profile = Users.getProfile(modifiedPlayer);
if (!Users.getProfile(modifiedPlayer).isLoaded()) {
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
@@ -94,7 +97,7 @@ public class AddxpCommand implements CommandExecutor {
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
profile.addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -109,10 +112,10 @@ public class AddxpCommand implements CommandExecutor {
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
Skills.xpCheckAll(modifiedPlayer, profile);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
}
}
else {

View File

@@ -7,7 +7,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@@ -17,16 +16,10 @@ import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class MmoeditCommand implements CommandExecutor {
private final mcMMO plugin;
public MmoeditCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer modifiedPlayer;
PlayerProfile PP;
PlayerProfile playerProfile;
int newValue;
SkillType skill;
String skillName;
@@ -48,7 +41,7 @@ public class MmoeditCommand implements CommandExecutor {
modifiedPlayer = (Player) sender;
newValue = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
PP = Users.getProfile(modifiedPlayer);
playerProfile = Users.getProfile(modifiedPlayer);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -57,7 +50,7 @@ public class MmoeditCommand implements CommandExecutor {
skillName = Misc.getCapitalized(skill.toString());
}
PP.modifySkill(skill, newValue);
playerProfile.modifySkill(skill, newValue);
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
}
else {
@@ -71,46 +64,47 @@ public class MmoeditCommand implements CommandExecutor {
return true;
case 3:
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
String playerName = modifiedPlayer.getName();
PP = Users.getProfile(modifiedPlayer);
if (!PP.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
if (!Misc.isInt(args[2])) {
sender.sendMessage(usage);
return true;
}
if (!Skills.isSkill(args[1])) {
skill = Skills.getSkillType(args[1]);
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (Misc.isInt(args[2])) {
newValue = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
}
else {
skillName = Misc.getCapitalized(skill.toString());
}
Users.getProfile(modifiedPlayer).modifySkill(skill, newValue);
newValue = Integer.valueOf(args[2]);
playerProfile = Users.getProfile(args[0]);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}
if (playerProfile != null) {
Player player = playerProfile.getPlayer();
sender.sendMessage(message);
if (modifiedPlayer.isOnline()) {
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
if (player.isOnline()) {
player.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
}
}
else {
sender.sendMessage(usage);
playerProfile = new PlayerProfile(null, args[0], false);
if (!playerProfile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
}
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + args[0] + "."); //TODO: Use locale
playerProfile.modifySkill(skill, newValue);
playerProfile.save();
return true;
default:

View File

@@ -7,11 +7,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
public class McmmoCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String description = LocaleLoader.getString("mcMMO.Description");
@@ -19,7 +19,7 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) {
if (Config.getInstance().spoutEnabled && sender instanceof SpoutPlayer) {
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
SpoutPlayer sPlayer = (SpoutPlayer) sender;
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);

View File

@@ -61,7 +61,7 @@ public class McrefreshCommand implements CommandExecutor {
return true;
}
PP.setRecentlyHurt((long) 0);
PP.setRecentlyHurt(0);
PP.resetCooldowns();
PP.resetToolPrepMode();
PP.resetAbilityMode();

View File

@@ -5,6 +5,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -13,6 +14,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
@@ -22,7 +24,7 @@ public class McremoveCommand implements CommandExecutor {
public McremoveCommand (mcMMO plugin) {
this.plugin = plugin;
this.location = plugin.usersFile;
this.location = mcMMO.usersFile;
}
@Override
@@ -40,7 +42,7 @@ public class McremoveCommand implements CommandExecutor {
switch (args.length) {
case 1:
playerName = args[0];
success = ChatColor.GREEN + playerName + "was successfully removed from the database!"; //TODO: Locale
success = ChatColor.GREEN + playerName + " was successfully removed from the database!"; //TODO: Locale
break;
default:
@@ -96,11 +98,15 @@ public class McremoveCommand implements CommandExecutor {
}
//Force PlayerProfile stuff to update
Player player = plugin.getServer().getPlayer(playerName);
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
PlayerProfile playerProfile = Users.getProfile(player);
if (player != null && Users.players.containsKey(playerName.toLowerCase())) {
Users.removeUser(player);
Users.addUser(player);
if (playerProfile != null) {
Users.getProfiles().remove(playerProfile);
if (player.isOnline()) {
Users.addUser((Player) player);
}
}
return true;

View File

@@ -7,6 +7,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -19,7 +20,7 @@ public class MctopCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
if (!Config.getInstance().getUseMySQL()) {
switch (args.length) {

View File

@@ -63,15 +63,23 @@ public class ACommand implements CommandExecutor {
if (sender instanceof Player) {
Player player = (Player) sender;
PP = Users.getProfile(player);
if (PP.getAdminChatMode()) {
player.chat(message);
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return true;
}
else {
PP.toggleAdminChat();
player.chat(message);
PP.toggleAdminChat();
message = chatEvent.getMessage();
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} ";
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
p.sendMessage(prefix + message);
}
}
}
else {

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class AcceptCommand implements CommandExecutor {
@@ -32,32 +33,33 @@ public class AcceptCommand implements CommandExecutor {
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
if (PP.hasPartyInvite()) {
Party partyInstance = Party.getInstance();
if (playerProfile.hasPartyInvite()) {
PartyManager partyManagerInstance = PartyManager.getInstance();
if (playerProfile.inParty()) {
Party party = playerProfile.getParty();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
if (PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), PP.getInvite(), EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(player.getName(), party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite(), EventReason.JOINED_PARTY);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
PP.acceptInvite();
partyInstance.addToParty(player, PP, PP.getParty(), true, null);
partyManagerInstance.joinInvitedParty(player, playerProfile);
}
else {
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));

View File

@@ -11,6 +11,7 @@ import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
//TODO: Make this work from console.
@@ -36,11 +37,9 @@ public class InviteCommand implements CommandExecutor {
switch (args.length) {
case 1:
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
Party partyInstance = Party.getInstance();
if (!PP.inParty()) {
if (!playerProfile.inParty()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@@ -48,13 +47,12 @@ public class InviteCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[0]);
if (target != null) {
if (partyInstance.canInvite(player, PP)) {
PlayerProfile PPt = Users.getProfile(target);
PPt.modifyInvite(PP.getParty());
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
Party party = playerProfile.getParty();
Users.getProfile(target).setInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() }));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PCommand implements CommandExecutor {
@@ -30,7 +31,6 @@ public class PCommand implements CommandExecutor {
return true;
}
switch (args.length) {
case 0:
if (sender instanceof Player) {
@@ -58,9 +58,9 @@ public class PCommand implements CommandExecutor {
default:
if (sender instanceof Player) {
Player player = (Player) sender;
PP = Users.getProfile(player);
Party party = Users.getProfile(player).getParty();
if (!PP.inParty()) {
if (party == null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@@ -71,13 +71,20 @@ public class PCommand implements CommandExecutor {
message = message + " " + args [i];
}
if (PP.getPartyChatMode()) {
player.chat(message);
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return true;
}
else {
PP.togglePartyChat();
player.chat(message);
PP.togglePartyChat();
message = chatEvent.getMessage();
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") ";
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
for (Player member : party.getOnlineMembers()) {
member.sendMessage(prefix + message);
}
}
else {
@@ -86,7 +93,7 @@ public class PCommand implements CommandExecutor {
return true;
}
if (!Party.getInstance().isParty(args[0])) {
if (!PartyManager.getInstance().isParty(args[0])) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return true;
}
@@ -109,8 +116,8 @@ public class PCommand implements CommandExecutor {
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
for (Player player : Party.getInstance().getOnlineMembers(args[0])) {
player.sendMessage(prefix + message);
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
member.sendMessage(prefix + message);
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -13,6 +14,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PartyCommand implements CommandExecutor {
@@ -34,55 +36,54 @@ public class PartyCommand implements CommandExecutor {
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
Party partyInstance = Party.getInstance();
boolean inParty = PP.inParty();
String partyName = PP.getParty();
boolean isLeader = partyInstance.isPartyLeader(playerName, partyName);
if (PP.inParty() && (!partyInstance.isParty(PP.getParty()) || !partyInstance.isInParty(player, PP))) {
partyInstance.addToParty(player, PP, PP.getParty(), false, null);
}
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
switch (args.length) {
case 0:
if (!inParty) {
if (party == null) {
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
}
else {
String tempList = "";
Server server = plugin.getServer();
String leader = party.getLeader();
StringBuffer tempList = new StringBuffer();
for (Player p : partyInstance.getAllMembers(player)) {
if (p.equals(partyInstance.getPartyLeader(partyName))) {
tempList += ChatColor.GOLD;
for (String otherPlayerName : party.getMembers()) {
if (leader.equals(otherPlayerName)) {
tempList.append(ChatColor.GOLD);
}
else if (server.getPlayer(otherPlayerName) != null) {
tempList.append(ChatColor.WHITE);
}
else {
tempList += ChatColor.WHITE;
tempList.append(ChatColor.GRAY);
}
tempList += p.getName() + " ";
tempList.append(otherPlayerName + " ");
}
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] { partyName }));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] { tempList }));
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
}
return true;
case 1:
if (args[0].equalsIgnoreCase("q")) {
if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY);
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(playerName, party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
}
else {
@@ -98,13 +99,13 @@ public class PartyCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
}
else if (args[0].equalsIgnoreCase("lock")) {
if (inParty) {
if (isLeader) {
if (partyInstance.isPartyLocked(partyName)) {
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
}
else {
partyInstance.lockParty(partyName);
party.setLocked(true);
player.sendMessage(LocaleLoader.getString("Party.Locked"));
}
}
@@ -117,13 +118,13 @@ public class PartyCommand implements CommandExecutor {
}
}
else if (args[0].equalsIgnoreCase("unlock")) {
if (inParty) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (!party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
}
else {
partyInstance.unlockParty(partyName);
party.setLocked(false);
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
}
@@ -136,15 +137,15 @@ public class PartyCommand implements CommandExecutor {
}
}
else {
if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(playerName, party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
@@ -155,53 +156,40 @@ public class PartyCommand implements CommandExecutor {
}
}
partyInstance.addToParty(player, PP, args[0], false, null);
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
}
return true;
case 2:
if (PP.inParty()) {
if (playerProfile.inParty()) {
if (args[0].equalsIgnoreCase("password")) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
partyInstance.lockParty(partyName);
}
partyInstance.setPartyPassword(partyName, args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] { args[1] }));
if (party.getLeader().equals(playerName)) {
party.setLocked(true);
party.setPassword(args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("kick")) {
if (isLeader) {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
PlayerProfile PPt = Users.getProfile(target);
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
else {
String partyName = party.getName();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(target, PPt);
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] { partyName }));
partyManagerInstance.removeFromParty(args[1], party);
}
}
else {
@@ -209,39 +197,26 @@ public class PartyCommand implements CommandExecutor {
}
}
else if (args[0].equalsIgnoreCase("owner")) {
if (isLeader) {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
else {
partyInstance.setPartyLeader(partyName, targetName);
partyManagerInstance.setPartyLeader(args[1], party);
}
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyInstance.addToParty(player, PP, args[0], false, args[1]);
partyManagerInstance.removeFromParty(playerName, party);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
}
else {
@@ -252,7 +227,7 @@ public class PartyCommand implements CommandExecutor {
return true;
}
partyInstance.addToParty(player, PP, args[0], false, args[1]);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
return true;

View File

@@ -12,7 +12,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PtpCommand implements CommandExecutor {
@@ -39,11 +39,6 @@ public class PtpCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (!Party.getInstance().isInParty(player, PP)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
if (PP.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
return true;
@@ -57,7 +52,7 @@ public class PtpCommand implements CommandExecutor {
}
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}
@@ -66,8 +61,8 @@ public class PtpCommand implements CommandExecutor {
return true;
}
if (Party.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
if (PartyManager.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@@ -1,22 +1,10 @@
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
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 AcrobaticsCommand implements CommandExecutor {
private float skillValue;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String rollChance;
private String gracefulRollChance;
@@ -25,67 +13,12 @@ public class AcrobaticsCommand implements CommandExecutor {
private boolean canRoll;
private boolean canGracefulRoll;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.ACROBATICS);
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Acrobatics.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Acrobatics") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
return true;
public AcrobaticsCommand() {
super(SkillType.ACROBATICS);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
if (skillValue >= 1000) {
dodgeChance = "20.00%";
rollChance = "100.00%";
@@ -108,11 +41,50 @@ public class AcrobaticsCommand implements CommandExecutor {
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
@Override
protected void permissionsCheck() {
canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void effectsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
}
}

View File

@@ -1,22 +1,10 @@
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
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 {
private float skillValue;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String retrieveChance;
@@ -25,67 +13,12 @@ public class ArcheryCommand implements CommandExecutor {
private boolean canDaze;
private boolean canRetrieve;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
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);
return true;
public ArcheryCommand() {
super(SkillType.ARCHERY);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
if (skillValue >= 1000) {
skillShotBonus = "200.00%";
dazeChance = "50.00%";
@@ -98,11 +31,50 @@ public class ArcheryCommand implements CommandExecutor {
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
@Override
protected void permissionsCheck() {
canSkillShot = permInstance.archeryBonus(player);
canDaze = permInstance.daze(player);
canRetrieve = permInstance.trackArrows(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
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") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void statsDisplay() {
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 }));
}
}
}

View File

@@ -1,21 +1,10 @@
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
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 {
private float skillValue;
public class AxesCommand extends SkillCommand {
private String critChance;
private String bonusDamage;
private String impactDamage;
@@ -28,31 +17,46 @@ public class AxesCommand implements CommandExecutor {
private boolean canImpact;
private boolean canGreaterImpact;
public AxesCommand() {
super(SkillType.AXES);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
impactDamage = String.valueOf(5 + ((int) skillValue / 30));
skullSplitterLength = String.valueOf(2 + ((int) skillValue / 50));
greaterImpactDamage = "2";
if (skillValue >= 750) {
critChance = "37.50";
bonusDamage = "4";
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.axes")) {
return true;
else if (skillValue >= 200) {
critChance = percent.format(skillValue / 2000);
bonusDamage = "4";
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
else {
critChance = percent.format(skillValue / 2000);
bonusDamage = String.valueOf((int) skillValue / 50);
}
}
@Override
protected void permissionsCheck() {
canSkullSplitter = permInstance.skullSplitter(player);
canCritical = permInstance.criticalHit(player);
canBonusDamage = permInstance.axeBonus(player);
canImpact = permInstance.impact(player);
canGreaterImpact = permInstance.greaterImpact(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void effectsDisplay() {
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
}
@@ -72,11 +76,15 @@ public class AxesCommand implements CommandExecutor {
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") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void statsDisplay() {
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}) }));
}
@@ -96,38 +104,5 @@ public class AxesCommand implements CommandExecutor {
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 >= 750) {
critChance = "37.50";
bonusDamage = "4";
}
else if (skillValue >= 200) {
critChance = percent.format(skillValue / 2000);
bonusDamage = "4";
}
else {
critChance = percent.format(skillValue / 2000);
bonusDamage = String.valueOf((int) skillValue / 50);
}
}
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

@@ -1,50 +1,37 @@
package com.gmail.nossr50.commands.skills;
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
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;
public class ExcavationCommand extends SkillCommand {
private String gigaDrillBreakerLength;
private boolean canGigaDrill;
private boolean canTreasureHunt;
public ExcavationCommand() {
super(SkillType.EXCAVATION);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
protected void dataCalculations() {
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) {
return true;
}
@Override
protected void permissionsCheck() {
canGigaDrill = permInstance.gigaDrillBreaker(player);
canTreasureHunt = permInstance.excavationTreasures(player);
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canGigaDrill || canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
@Override
protected boolean effectsHeaderPermissions() {
return canGigaDrill || canTreasureHunt;
}
@Override
protected void effectsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
}
@@ -52,25 +39,17 @@ public class ExcavationCommand implements CommandExecutor {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGigaDrill;
}
@Override
protected void statsDisplay() {
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);
return true;
}
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,22 +1,11 @@
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
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 {
public class FishingCommand extends SkillCommand {
private int lootTier;
private String magicChance;
@@ -24,31 +13,30 @@ public class FishingCommand implements CommandExecutor {
private boolean canMagicHunt;
private boolean canShake;
public FishingCommand() {
super(SkillType.FISHING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
protected void dataCalculations() {
lootTier = Fishing.getFishingLootTier(profile);
magicChance = percent.format((float) lootTier / 15);
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) {
return true;
}
@Override
protected void permissionsCheck() {
canTreasureHunt = permInstance.fishingTreasures(player);
canMagicHunt = permInstance.fishingMagic(player);
canShake = permInstance.shakeMob(player);
}
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) }));
if (canTreasureHunt || canMagicHunt || canShake) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void effectsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
}
@@ -60,11 +48,15 @@ public class FishingCommand implements CommandExecutor {
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") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void statsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
}
@@ -75,30 +67,12 @@ public class FishingCommand implements CommandExecutor {
if (canShake) {
//TODO: Do we really need to display this twice? Not like there are any associated stats.
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
if (skillValue < 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,23 +1,11 @@
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.commands.SkillCommand;
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 {
private float skillValue;
public class HerbalismCommand extends SkillCommand {
private String greenTerraLength;
private String greenThumbChance;
private String greenThumbStage;
@@ -31,83 +19,12 @@ public class HerbalismCommand implements CommandExecutor {
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled )|| canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
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);
return true;
public HerbalismCommand() {
super(SkillType.HERBALISM);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1500) {
@@ -154,8 +71,8 @@ public class HerbalismCommand implements CommandExecutor {
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
canGreenTerra = permInstance.greenTerra(player);
@@ -165,4 +82,60 @@ public class HerbalismCommand implements CommandExecutor {
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
}
@Override
protected void effectsDisplay() {
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") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
}
@Override
protected void statsDisplay() {
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 }));
}
}
}

View File

@@ -1,24 +1,12 @@
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.commands.SkillCommand;
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;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
private String superBreakerLength;
private String blastMiningRank;
@@ -32,98 +20,12 @@ public class MiningCommand implements CommandExecutor {
private boolean canDemoExpert;
private boolean doubleDropsDisabled;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.mining")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled ) || canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
}
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);
return true;
public MiningCommand() {
super(SkillType.MINING);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
superBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
@@ -182,8 +84,8 @@ public class MiningCommand implements CommandExecutor {
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
canBiggerBombs = permInstance.biggerBombs(player);
@@ -193,4 +95,75 @@ public class MiningCommand implements CommandExecutor {
canSuperBreaker = permInstance.superBreaker(player);
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void effectsDisplay() {
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
}
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") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void statsDisplay() {
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 (skillValue < 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 (skillValue < 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 (skillValue < 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 }));
}
}
}
}

View File

@@ -1,26 +1,15 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.commands.SkillCommand;
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.Repair;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class RepairCommand implements CommandExecutor {
private float skillValue;
public class RepairCommand extends SkillCommand {
private int arcaneForgingRank;
private String repairMasteryBonus;
private String superRepairChance;
@@ -40,33 +29,56 @@ public class RepairCommand implements CommandExecutor {
private int ironLevel;
private int stoneLevel;
public RepairCommand() {
super(SkillType.REPAIR);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
repairMasteryBonus = percent.format(skillValue / 500);
if (skillValue >= 1000) {
superRepairChance = "100.00%";
}
else {
superRepairChance = percent.format(skillValue / 1000);
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.repair")) {
return true;
}
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
@Override
protected void permissionsCheck() {
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);
}
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) }));
if (canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
@Override
protected boolean effectsHeaderPermissions() {
return canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
}
@Override
protected void effectsDisplay() {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
if (canMasterRepair) {
@@ -98,12 +110,16 @@ public class RepairCommand implements CommandExecutor {
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") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canArcaneForge || canMasterRepair || canSuperRepair;
}
if (canMasterRepair) {
@Override
protected void statsDisplay() {
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
}
@@ -122,48 +138,5 @@ public class RepairCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
}
}
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
// We're using pickaxes here, not the best but works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
repairMasteryBonus = percent.format(skillValue / 500);
if (skillValue >= 1000) {
superRepairChance = "100.00%";
}
else {
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,22 +1,10 @@
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
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 {
private float skillValue;
public class SwordsCommand extends SkillCommand {
private String counterAttackChance;
private String bleedLength;
private String bleedChance;
@@ -26,70 +14,12 @@ public class SwordsCommand implements CommandExecutor {
private boolean canSerratedStrike;
private boolean canBleed;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.swords")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canBleed || canCounter || canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
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);
return true;
public SwordsCommand() {
super(SkillType.SWORDS);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 750) {
@@ -109,11 +39,53 @@ public class SwordsCommand implements CommandExecutor {
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
@Override
protected void permissionsCheck() {
canBleed = permInstance.swordsBleed(player);
canCounter = permInstance.counterAttack(player);
canSerratedStrike = permInstance.serratedStrikes(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void effectsDisplay() {
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") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void statsDisplay() {
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 }));
}
}
}

View File

@@ -1,23 +1,11 @@
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.commands.SkillCommand;
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 TamingCommand implements CommandExecutor {
private float skillValue;
public class TamingCommand extends SkillCommand {
private String goreChance;
private boolean canBeastLore;
@@ -29,30 +17,39 @@ public class TamingCommand implements CommandExecutor {
private boolean canCallWild;
private boolean canFastFood;
public TamingCommand() {
super(SkillType.TAMING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
if (skillValue >= 1000) {
goreChance = "100.00%";
}
else {
goreChance = percent.format(skillValue / 1000);
} }
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.taming")) {
return true;
}
@Override
protected void permissionsCheck() {
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);
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
@Override
protected boolean effectsHeaderPermissions() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
}
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) }));
if (canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
@Override
protected void effectsDisplay() {
Config configInstance = Config.getInstance();
if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
@@ -84,16 +81,20 @@ public class TamingCommand implements CommandExecutor {
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() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { configInstance.getTamingCOTWOcelotCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { configInstance.getTamingCOTWWolfCost() }));
}
}
if (canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
}
@Override
protected void statsDisplay() {
if (canFastFood) {
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
if (skillValue < 50) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
}
else {
@@ -102,7 +103,7 @@ public class TamingCommand implements CommandExecutor {
}
if (canEnvironmentallyAware) {
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
if (skillValue < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
}
else {
@@ -111,7 +112,7 @@ public class TamingCommand implements CommandExecutor {
}
if (canThickFur) {
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
if (skillValue < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
}
else {
@@ -120,7 +121,7 @@ public class TamingCommand implements CommandExecutor {
}
if (canShockProof) {
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
if (skillValue < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
}
else {
@@ -129,7 +130,7 @@ public class TamingCommand implements CommandExecutor {
}
if (canSharpenedClaws) {
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
if (skillValue < 750) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
}
else {
@@ -140,33 +141,5 @@ public class TamingCommand implements CommandExecutor {
if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
}
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
if (skillValue >= 1000) {
goreChance = "100.00%";
}
else {
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,22 +1,10 @@
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.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
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 {
private float skillValue;
public class UnarmedCommand extends SkillCommand {
private String berserkLength;
private String deflectChance;
private String disarmChance;
@@ -27,75 +15,12 @@ public class UnarmedCommand implements CommandExecutor {
private boolean canBonusDamage;
private boolean canDeflect;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.unarmed")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
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) }));
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
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);
return true;
public UnarmedCommand() {
super(SkillType.UNARMED);
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
protected void dataCalculations() {
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
@@ -112,15 +37,61 @@ public class UnarmedCommand implements CommandExecutor {
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();
} }
@Override
protected void permissionsCheck() {
canBerserk = permInstance.berserk(player);
canBonusDamage = permInstance.unarmedBonus(player);
canDeflect = permInstance.deflect(player);
canDisarm = permInstance.disarm(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
}
@Override
protected void effectsDisplay() {
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") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
}
@Override
protected void statsDisplay() {
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 }));
}
}
}

View File

@@ -1,23 +1,11 @@
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.commands.SkillCommand;
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 {
private float skillValue;
public class WoodcuttingCommand extends SkillCommand {
private String treeFellerLength;
private String doubleDropChance;
@@ -26,31 +14,39 @@ public class WoodcuttingCommand implements CommandExecutor {
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
public WoodcuttingCommand() {
super(SkillType.WOODCUTTING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
doubleDropChance = "100.00%";
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.woodcutting")) {
return true;
else {
doubleDropChance = percent.format(skillValue / 1000);
}
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
permissionsCheck(player);
canTreeFell = permInstance.treeFeller(player);
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
canLeafBlow = permInstance.leafBlower(player);
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
}
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) }));
if ((canDoubleDrop && !doubleDropsDisabled ) || canLeafBlow || canTreeFell) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
@Override
protected boolean effectsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void effectsDisplay() {
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
}
@@ -62,14 +58,18 @@ public class WoodcuttingCommand implements CommandExecutor {
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") }));
}
@Override
protected boolean statsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void statsDisplay() {
//TODO: Remove? Basically duplicates the above.
if (canLeafBlow) {
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
if (skillValue < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
}
else {
@@ -84,32 +84,5 @@ public class WoodcuttingCommand implements CommandExecutor {
if (canTreeFell) {
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.00%";
}
else {
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

@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
@@ -32,7 +32,7 @@ public class MchudCommand implements CommandExecutor {
return true;
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled()) {
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@@ -6,8 +6,10 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -26,7 +28,7 @@ public class XplockCommand implements CommandExecutor {
return true;
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
public class Config extends ConfigLoader {
public int xpGainMultiplier = 1;
@@ -196,7 +195,7 @@ public class Config extends ConfigLoader {
}
/* Mining */
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
@@ -341,7 +340,6 @@ public class Config extends ConfigLoader {
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getCreeperXP() { return config.getDouble("Experience.Combat.Multiplier.Creeper", 4.0); }
public double getSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Skeleton", 2.0); }
@@ -373,103 +371,18 @@ public class Config extends ConfigLoader {
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
/*
* SPOUT SETTINGS
*/
public boolean spoutEnabled;
public boolean getShowPowerLevelForSpout() { return config.getBoolean("Spout.HUD.Show_Power_Level", true); }
/* Spout XP Bar */
public boolean getSpoutXPBarEnabled() { return config.getBoolean("Spout.XP.Bar.Enabled", true); }
public boolean getSpoutXPBarIconEnabled() { return config.getBoolean("Spout.XP.Icon.Enabled", true); }
public int getSpoutXPBarXPosition() { return config.getInt("Spout.XP.Bar.X_POS", 95); }
public int getSpoutXPBarYPosition() { return config.getInt("Spout.XP.Bar.Y_POS", 6); }
public int getSpoutXPIconXPosition() { return config.getInt("Spout.XP.Icon.X_POS", 78); }
public int getSpoutXPIconYPosition() { return config.getInt("Spout.XP.Icon.Y_POS", 2); }
/* Spout HUD Colors */
public double getSpoutRetroHUDXPBorderRed() { return config.getDouble("Spout.HUD.Retro.Colors.Border.RED", 0.0); }
public double getSpoutRetroHUDXPBorderGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Border.GREEN", 0.0); }
public double getSpoutRetroHUDXPBorderBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Border.BLUE", 0.0); }
public double getSpoutRetroHUDXPBackgroundRed() { return config.getDouble("Spout.HUD.Retro.Colors.Background.RED", 0.75); }
public double getSpoutRetroHUDXPBackgroundGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Background.GREEN", 0.75); }
public double getSpoutRetroHUDXPBackgroundBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Background.BLUE", 0.75); }
public double getSpoutRetroHUDAcrobaticsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3); }
public double getSpoutRetroHUDAcrobaticsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
public double getSpoutRetroHUDAcrobaticsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
public double getSpoutRetroHUDArcheryRed() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.RED", 0.3); }
public double getSpoutRetroHUDArcheryGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.GREEN", 0.3); }
public double getSpoutRetroHUDArcheryBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.BLUE", 0.75); }
public double getSpoutRetroHUDAxesRed() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.RED", 0.3); }
public double getSpoutRetroHUDAxesGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.GREEN", 0.3); }
public double getSpoutRetroHUDAxesBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.BLUE", 0.75); }
public double getSpoutRetroHUDExcavationRed() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.RED", 0.3); }
public double getSpoutRetroHUDExcavationGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.GREEN", 0.3); }
public double getSpoutRetroHUDExcavationBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.BLUE", 0.75); }
public double getSpoutRetroHUDHerbalismRed() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.RED", 0.3); }
public double getSpoutRetroHUDHerbalismGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
public double getSpoutRetroHUDHerbalismBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
public double getSpoutRetroHUDMiningRed() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.RED", 0.3); }
public double getSpoutRetroHUDMiningGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.GREEN", 0.3); }
public double getSpoutRetroHUDMiningBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.BLUE", 0.75); }
public double getSpoutRetroHUDRepairRed() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.RED", 0.3); }
public double getSpoutRetroHUDRepairGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.GREEN", 0.3); }
public double getSpoutRetroHUDRepairBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.BLUE", 0.75); }
public double getSpoutRetroHUDSwordsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.RED", 0.3); }
public double getSpoutRetroHUDSwordsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.GREEN", 0.3); }
public double getSpoutRetroHUDSwordsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.BLUE", 0.75); }
public double getSpoutRetroHUDTamingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.RED", 0.3); }
public double getSpoutRetroHUDTamingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.GREEN", 0.3); }
public double getSpoutRetroHUDTamingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.BLUE", 0.75); }
public double getSpoutRetroHUDUnarmedRed() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.RED", 0.3); }
public double getSpoutRetroHUDUnarmedGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
public double getSpoutRetroHUDUnarmedBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
public double getSpoutRetroHUDWoodcuttingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.RED", 0.3); }
public double getSpoutRetroHUDWoodcuttingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
public double getSpoutRetroHUDWoodcuttingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
public double getSpoutRetroHUDFishingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.RED", 0.3); }
public double getSpoutRetroHUDFishingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.GREEN", 0.3); }
public double getSpoutRetroHUDFishingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.BLUE", 0.75); }
/*
* CONFIG LOADING
*/
public HUDType defaulthud;
private Config(mcMMO plugin) {
super(plugin, "config.yml");
config = plugin.getConfig();
saveIfNotExist();
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
}
@Override
protected void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveDefaultConfig();
}
addDefaults();
loadKeys();
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO config.yml File...");
// Setup default HUD
String temp = config.getString("Spout.HUD.Default", "STANDARD");
for (HUDType x : HUDType.values()) {
if (x.toString().toLowerCase().equalsIgnoreCase(temp.toString().toLowerCase())) {
defaulthud = x;
}
}
if(defaulthud == null)
defaulthud = HUDType.STANDARD;
}
}

View File

@@ -4,11 +4,12 @@ import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
public abstract class ConfigLoader {
protected String fileName;
protected File configFile;
protected File dataFolder;
protected final mcMMO plugin;
@@ -16,14 +17,24 @@ public abstract class ConfigLoader {
public ConfigLoader(mcMMO plugin, String fileName){
this.plugin = plugin;
this.fileName = fileName;
dataFolder = plugin.getDataFolder();
configFile = new File(dataFolder, File.separator + fileName);
config = YamlConfiguration.loadConfiguration(configFile);
}
/**
* Load this config file.
*/
protected abstract void load();
public void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
saveConfig();
}
addDefaults();
loadKeys();
}
/**
* Save this config file.
@@ -32,16 +43,28 @@ public abstract class ConfigLoader {
try {
config.save(configFile);
}
catch (IOException e) {
e.printStackTrace();
catch (IOException ex) {
plugin.getLogger().severe("Could not save config to " + configFile + ex);
}
}
protected void saveIfNotExist() {
if (!configFile.exists()) {
if (plugin.getResource(fileName) != null) {
plugin.saveResource(fileName, false);
}
}
rereadFromDisk();
}
protected void rereadFromDisk() {
config = YamlConfiguration.loadConfiguration(configFile);
}
/**
* Add the defaults to this config file.
*/
protected void addDefaults() {
// Load from included config.yml
config.options().copyDefaults(true);
saveConfig();
}

View File

@@ -27,8 +27,10 @@ public class HiddenConfig extends ConfigLoader {
}
@Override
protected void load() {
if(plugin.isInJar(fileName)) loadKeys();
public void load() {
if (plugin.getResource(fileName) != null) {
loadKeys();
}
}
@Override

View File

@@ -14,17 +14,15 @@ import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class RepairConfig extends ConfigLoader {
private final String fileName;
private List<Repairable> repairables;
public RepairConfig(mcMMO plugin, String fileName) {
super(plugin, fileName);
this.fileName = fileName;
this.config = YamlConfiguration.loadConfiguration(this.configFile);
}
@Override
protected void load() {
public void load() {
loadKeys();
}
@@ -34,19 +32,20 @@ public class RepairConfig extends ConfigLoader {
ConfigurationSection section = config.getConfigurationSection("Repairables");
Set<String> keys = section.getKeys(false);
for(String key : keys) {
for (String key : keys) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
if(!config.contains("Repairables." + key + ".ItemId")) {
if (!config.contains("Repairables." + key + ".ItemId")) {
reason.add(key + " is missing ItemId");
}
if(!config.contains("Repairables." + key + ".RepairMaterialId")) {
if (!config.contains("Repairables." + key + ".RepairMaterialId")) {
reason.add(key + " is missing RepairMaterialId");
}
if(!config.contains("Repairables." + key + ".MaximumDurability")) {
if (!config.contains("Repairables." + key + ".MaximumDurability")) {
reason.add(key + " is missing MaximumDurability");
}
@@ -65,27 +64,29 @@ public class RepairConfig extends ConfigLoader {
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
if(minimumLevel < 0) {
if (minimumLevel < 0) {
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
}
if(minimumQuantity < 0) {
if (minimumQuantity < 0) {
reason.add(key + " has an invalid MinimumQuantity of " + minimumQuantity);
}
try {
repairItemType = RepairItemType.valueOf(repairItemTypeString);
} catch (IllegalArgumentException ex) {
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
try {
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
} catch (IllegalArgumentException ex) {
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
}
if(noErrorsInRepairable(reason)) {
if (noErrorsInRepairable(reason)) {
Repairable repairable = RepairableFactory.getRepairable(itemId, repairMaterialId, (byte) repairMetadata, minimumLevel, minimumQuantity, (short) maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
repairables.add(repairable);
}
@@ -93,7 +94,10 @@ public class RepairConfig extends ConfigLoader {
}
protected List<Repairable> getLoadedRepairables() {
if(repairables == null) return new ArrayList<Repairable>();
if (repairables == null) {
return new ArrayList<Repairable>();
}
return repairables;
}

View File

@@ -16,32 +16,41 @@ public class RepairConfigManager {
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder();
File vanilla = new File(dataFolder, "repair.vanilla.yml");
if(!vanilla.exists()) {
if (!vanilla.exists()) {
plugin.saveResource("repair.vanilla.yml", false);
}
for(String location : dataFolder.list()) {
if(!pattern.matcher(location).matches()) continue;
for (String location : dataFolder.list()) {
if (!pattern.matcher(location).matches()) {
continue;
}
plugin.getLogger().info("Loading " + location + " repair config file...");
File file = new File(dataFolder, location);
if(file.isDirectory()) continue;
if (file.isDirectory()) {
continue;
}
RepairConfig rConfig = new RepairConfig(plugin, location);
rConfig.load();
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
if(rConfigRepairables != null) {
if (rConfigRepairables != null) {
repairables.addAll(rConfigRepairables);
}
}
}
public List<Repairable> getLoadedRepairables() {
if(repairables == null) return new ArrayList<Repairable>();
if (repairables == null) {
return new ArrayList<Repairable>();
}
return repairables;
}
}

View File

@@ -0,0 +1,98 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
public class SpoutConfig extends ConfigLoader {
private static SpoutConfig instance;
public static SpoutConfig getInstance() {
if (instance == null) {
instance = new SpoutConfig(mcMMO.p);
instance.load();
}
return instance;
}
public HUDType defaulthud;
private SpoutConfig(mcMMO plugin) {
super(plugin, "spout.yml");
saveIfNotExist();
}
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
/* XP Bar */
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
/* HUD Colors */
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
public double getRetroHUDAcrobaticsRed() { return config.getDouble("HUD.Retro.Colors.Acrobatics.RED", 0.3); }
public double getRetroHUDAcrobaticsGreen() { return config.getDouble("HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
public double getRetroHUDAcrobaticsBlue() { return config.getDouble("HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
public double getRetroHUDArcheryRed() { return config.getDouble("HUD.Retro.Colors.Archery.RED", 0.3); }
public double getRetroHUDArcheryGreen() { return config.getDouble("HUD.Retro.Colors.Archery.GREEN", 0.3); }
public double getRetroHUDArcheryBlue() { return config.getDouble("HUD.Retro.Colors.Archery.BLUE", 0.75); }
public double getRetroHUDAxesRed() { return config.getDouble("HUD.Retro.Colors.Axes.RED", 0.3); }
public double getRetroHUDAxesGreen() { return config.getDouble("HUD.Retro.Colors.Axes.GREEN", 0.3); }
public double getRetroHUDAxesBlue() { return config.getDouble("HUD.Retro.Colors.Axes.BLUE", 0.75); }
public double getRetroHUDExcavationRed() { return config.getDouble("HUD.Retro.Colors.Excavation.RED", 0.3); }
public double getRetroHUDExcavationGreen() { return config.getDouble("HUD.Retro.Colors.Excavation.GREEN", 0.3); }
public double getRetroHUDExcavationBlue() { return config.getDouble("HUD.Retro.Colors.Excavation.BLUE", 0.75); }
public double getRetroHUDHerbalismRed() { return config.getDouble("HUD.Retro.Colors.Herbalism.RED", 0.3); }
public double getRetroHUDHerbalismGreen() { return config.getDouble("HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
public double getRetroHUDHerbalismBlue() { return config.getDouble("HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
public double getRetroHUDMiningRed() { return config.getDouble("HUD.Retro.Colors.Mining.RED", 0.3); }
public double getRetroHUDMiningGreen() { return config.getDouble("HUD.Retro.Colors.Mining.GREEN", 0.3); }
public double getRetroHUDMiningBlue() { return config.getDouble("HUD.Retro.Colors.Mining.BLUE", 0.75); }
public double getRetroHUDRepairRed() { return config.getDouble("HUD.Retro.Colors.Repair.RED", 0.3); }
public double getRetroHUDRepairGreen() { return config.getDouble("HUD.Retro.Colors.Repair.GREEN", 0.3); }
public double getRetroHUDRepairBlue() { return config.getDouble("HUD.Retro.Colors.Repair.BLUE", 0.75); }
public double getRetroHUDSwordsRed() { return config.getDouble("HUD.Retro.Colors.Swords.RED", 0.3); }
public double getRetroHUDSwordsGreen() { return config.getDouble("HUD.Retro.Colors.Swords.GREEN", 0.3); }
public double getRetroHUDSwordsBlue() { return config.getDouble("HUD.Retro.Colors.Swords.BLUE", 0.75); }
public double getRetroHUDTamingRed() { return config.getDouble("HUD.Retro.Colors.Taming.RED", 0.3); }
public double getRetroHUDTamingGreen() { return config.getDouble("HUD.Retro.Colors.Taming.GREEN", 0.3); }
public double getRetroHUDTamingBlue() { return config.getDouble("HUD.Retro.Colors.Taming.BLUE", 0.75); }
public double getRetroHUDUnarmedRed() { return config.getDouble("HUD.Retro.Colors.Unarmed.RED", 0.3); }
public double getRetroHUDUnarmedGreen() { return config.getDouble("HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
public double getRetroHUDUnarmedBlue() { return config.getDouble("HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
public double getRetroHUDWoodcuttingRed() { return config.getDouble("HUD.Retro.Colors.Woodcutting.RED", 0.3); }
public double getRetroHUDWoodcuttingGreen() { return config.getDouble("HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
public double getRetroHUDWoodcuttingBlue() { return config.getDouble("HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO spout.yml File...");
// Setup default HUD
String temp = config.getString("Spout.HUD.Default", "STANDARD");
for (HUDType x : HUDType.values()) {
if (x.toString().equalsIgnoreCase(temp.toString())) {
defaulthud = x;
}
}
if (defaulthud == null) {
defaulthud = HUDType.STANDARD;
}
}
}

View File

@@ -43,18 +43,7 @@ public class TreasuresConfig extends ConfigLoader{
private TreasuresConfig(mcMMO plugin) {
super(plugin, "treasures.yml");
config = plugin.getTreasuresConfig();
}
@Override
protected void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveTreasuresConfig();
}
addDefaults();
loadKeys();
saveIfNotExist();
}
@Override

View File

@@ -37,18 +37,6 @@ public class CustomArmorConfig extends ModConfigLoader{
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
@@ -93,7 +81,7 @@ public class CustomArmorConfig extends ModConfigLoader{
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
}
armor = new CustomItem(id);
armor = new CustomItem(id, durability);
idList.add(id);
customIDs.add(id);

View File

@@ -36,18 +36,6 @@ public class CustomBlocksConfig extends ModConfigLoader{
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

View File

@@ -39,18 +39,6 @@ public class CustomToolsConfig extends ModConfigLoader {
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
@@ -100,7 +88,7 @@ public class CustomToolsConfig extends ModConfigLoader {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
}
tool = new CustomTool(tier, abilityEnabled, multiplier, id);
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
idList.add(id);
customIDs.add(id);

View File

@@ -10,7 +10,7 @@ import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
@@ -119,9 +119,9 @@ public class HUDmmo {
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
Color border = new Color((float) Config.getInstance().getSpoutRetroHUDXPBorderRed(), (float) Config.getInstance().getSpoutRetroHUDXPBorderGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBorderBlue(), 1f);
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) Config.getInstance().getSpoutRetroHUDXPBackgroundRed(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundBlue(), 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpicon = new GenericTexture();
@@ -185,12 +185,12 @@ public class HUDmmo {
xpbg.setPriority(RenderPriority.Low);
xpbg.setDirty(true);
if (Config.getInstance().getSpoutXPBarEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
@@ -206,26 +206,28 @@ public class HUDmmo {
* @param sPlayer Player to initialize XP bar for
*/
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
if (Config.getInstance().getSpoutXPBarEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(Config.getInstance().getSpoutXPBarXPosition());
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
xpbar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpbar.setHeight(8);
xpbar.setWidth(256);
xpbar.setPriority(RenderPriority.Lowest);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(16);
xpicon.setWidth(32);
xpicon.setX(Config.getInstance().getSpoutXPIconXPosition());
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition());
xpicon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpicon.setPriority(RenderPriority.High);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
@@ -241,25 +243,27 @@ public class HUDmmo {
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
if (Config.getInstance().getSpoutXPBarEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(center_x - 64);
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpbar.setHeight(4);
xpbar.setWidth(128);
xpbar.setPriority(RenderPriority.Lowest);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(8);
xpicon.setWidth(16);
xpicon.setX(center_x - (8 + 64));
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition() + 2);
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpicon.setPriority(RenderPriority.High);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
@@ -276,7 +280,7 @@ public class HUDmmo {
* @param PP Profile of the given player
*/
private void updateXpBarStandard(Player player, PlayerProfile PP) {
if (!Config.getInstance().getSpoutXPBarEnabled()) {
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
return;
}
@@ -286,7 +290,7 @@ public class HUDmmo {
return;
}
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
@@ -302,7 +306,7 @@ public class HUDmmo {
* @param PP Profile of the given player
*/
private void updateXpBarRetro(Player player, PlayerProfile PP) {
if (!Config.getInstance().getSpoutXPBarEnabled()) {
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
return;
}
@@ -327,40 +331,40 @@ public class HUDmmo {
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) Config.getInstance().getSpoutRetroHUDAcrobaticsRed(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsGreen(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) Config.getInstance().getSpoutRetroHUDArcheryRed(), (float) Config.getInstance().getSpoutRetroHUDArcheryGreen(), (float) Config.getInstance().getSpoutRetroHUDArcheryBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) Config.getInstance().getSpoutRetroHUDAxesRed(), (float) Config.getInstance().getSpoutRetroHUDAxesGreen(), (float) Config.getInstance().getSpoutRetroHUDAxesBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) Config.getInstance().getSpoutRetroHUDExcavationRed(), (float) Config.getInstance().getSpoutRetroHUDExcavationGreen(), (float) Config.getInstance().getSpoutRetroHUDExcavationBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) Config.getInstance().getSpoutRetroHUDHerbalismRed(), (float) Config.getInstance().getSpoutRetroHUDHerbalismGreen(), (float) Config.getInstance().getSpoutRetroHUDHerbalismBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) Config.getInstance().getSpoutRetroHUDMiningRed(), (float) Config.getInstance().getSpoutRetroHUDMiningGreen(), (float) Config.getInstance().getSpoutRetroHUDMiningBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) Config.getInstance().getSpoutRetroHUDRepairRed(), (float) Config.getInstance().getSpoutRetroHUDRepairGreen(), (float) Config.getInstance().getSpoutRetroHUDRepairBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) Config.getInstance().getSpoutRetroHUDSwordsRed(), (float) Config.getInstance().getSpoutRetroHUDSwordsGreen(), (float) Config.getInstance().getSpoutRetroHUDSwordsBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) Config.getInstance().getSpoutRetroHUDTamingRed(), (float) Config.getInstance().getSpoutRetroHUDTamingGreen(), (float) Config.getInstance().getSpoutRetroHUDTamingBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) Config.getInstance().getSpoutRetroHUDUnarmedRed(), (float) Config.getInstance().getSpoutRetroHUDUnarmedGreen(), (float) Config.getInstance().getSpoutRetroHUDUnarmedBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) Config.getInstance().getSpoutRetroHUDWoodcuttingRed(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingGreen(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) Config.getInstance().getSpoutRetroHUDFishingRed(), (float) Config.getInstance().getSpoutRetroHUDFishingGreen(), (float) Config.getInstance().getSpoutRetroHUDFishingBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);

View File

@@ -4,67 +4,71 @@ import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.mcMMO;
public class PlayerProfile {
/* HUD */
private HUDType hud;
private int xpbarinc = 0;
private int xpbarinc;
private SkillType lastgained;
private SkillType skillLock;
/* Party Stuff */
private String party;
private String invite;
private Party party;
private Party invite;
/* Toggles */
private boolean loaded = false;
private boolean partyhud = true, spoutcraft = false, xpbarlocked = false;
private boolean placedAnvil = false;
private boolean partyChatMode = false, adminChatMode = false;
private boolean godMode = false;
private boolean loaded;
private boolean partyhud = true, spoutcraft, xpbarlocked;
private boolean placedAnvil;
private boolean partyChatMode, adminChatMode;
private boolean godMode;
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
private boolean hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false,
pickaxePreparationMode = false, axePreparationMode = false;
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
pickaxePreparationMode, axePreparationMode;
private boolean abilityuse = true;
/* Timestamps */
private int xpGainATS = 0;
private int recentlyHurt = 0;
private int recentlyHurt;
private int respawnATS;
/* mySQL STUFF */
private int lastlogin = 0;
private int userid = 0;
private int userid;
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
private Player player;
private String playerName;
private final String location = mcMMO.p.usersFile;
private final static String location = mcMMO.usersFile;
public PlayerProfile(String name, boolean addNew) {
hud = Config.getInstance().defaulthud;
playerName = name;
public PlayerProfile(Player player, String playerName, boolean addNew) {
hud = SpoutConfig.getInstance().defaulthud;
this.player = player;
this.playerName = playerName;
party = PartyManager.getInstance().getPlayerParty(playerName);
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
@@ -80,63 +84,63 @@ public class PlayerProfile {
if (Config.getInstance().getUseMySQL()) {
if (!loadMySQL() && addNew) {
addMySQLPlayer();
loaded = true;
}
}
else if (!load() && addNew) {
addPlayer();
loaded = true;
}
lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
}
public String getPlayerName() {
return this.playerName;
}
public Player getPlayer() {
return mcMMO.p.getServer().getPlayer(playerName);
return player;
}
public String getPlayerName() {
return playerName;
}
public void setPlayer(Player player) {
this.player = player;
this.playerName = player.getName();
}
public boolean loadMySQL() {
int id = 0;
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
this.userid = id;
if (id > 0) {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id);
if(huds.get(1) == null)
{
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"huds (user_id) VALUES ("+id+")");
} else {
if(huds.get(1).get(0) != null)
{
for(HUDType x : HUDType.values())
{
if(x.toString().equals(huds.get(1).get(0)))
{
hud = x;
userid = mcMMO.database.getInt("SELECT id FROM " + Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
if (userid == 0) {
return false;
}
else {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM " + Config.getInstance().getMySQLTablePrefix() + "huds WHERE user_id = " + userid);
if (huds.get(1) == null) {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "huds (user_id) VALUES (" + userid + ")");
}
else {
if (huds.get(1).get(0) != null) {
for (HUDType x : HUDType.values()) {
if (x.toString().equals(huds.get(1).get(0))) {
hud = x;
}
}
}
} else {
hud = Config.getInstance().defaulthud;
else {
hud = SpoutConfig.getInstance().defaulthud;
}
}
HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE id = " + id);
//lastlogin = Integer.parseInt(users.get(1).get(0));
party = users.get(1).get(1);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+Config.getInstance().getMySQLTablePrefix()+"cooldowns WHERE user_id = " + id);
/*
* I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works
*/
if(cooldowns.get(1) == null)
{
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + Config.getInstance().getMySQLTablePrefix() + "cooldowns WHERE user_id = " + userid);
if(cooldowns.get(1) == null) {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
}
else
{
else {
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldowns.get(1).get(0)));
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldowns.get(1).get(1)));
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldowns.get(1).get(2)));
@@ -146,7 +150,8 @@ public class PlayerProfile {
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6)));
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
}
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + userid);
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
@@ -159,7 +164,7 @@ public class PlayerProfile {
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + userid);
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
@@ -175,118 +180,109 @@ public class PlayerProfile {
loaded = true;
return true;
}
else {
return false;
}
}
public void addMySQLPlayer() {
int id = 0;
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
this.userid = id;
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
userid = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "skills (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userid + ")");
}
public boolean load()
{
public boolean load() {
try {
//Open the user file
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
while((line = in.readLine()) != null)
{
while ((line = in.readLine()) != null) {
//Find if the line contains the player we want.
String[] character = line.split(":");
if(!character[0].equals(playerName)){continue;}
//Get Mining
if(character.length > 1 && Misc.isInt(character[1]))
if (!character[0].equals(playerName)) {
continue;
}
if (character.length > 1 && Misc.isInt(character[1]))
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
//Party
if(character.length > 3)
party = character[3];
//Mining XP
if(character.length > 4 && Misc.isInt(character[4]))
if (character.length > 4 && Misc.isInt(character[4]))
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
if(character.length > 5 && Misc.isInt(character[5]))
if (character.length > 5 && Misc.isInt(character[5]))
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
if(character.length > 6 && Misc.isInt(character[6]))
if (character.length > 6 && Misc.isInt(character[6]))
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
if(character.length > 7 && Misc.isInt(character[7]))
if (character.length > 7 && Misc.isInt(character[7]))
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
if(character.length > 8 && Misc.isInt(character[8]))
if (character.length > 8 && Misc.isInt(character[8]))
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
if(character.length > 9 && Misc.isInt(character[9]))
if (character.length > 9 && Misc.isInt(character[9]))
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
if(character.length > 10 && Misc.isInt(character[10]))
if (character.length > 10 && Misc.isInt(character[10]))
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
if(character.length > 11 && Misc.isInt(character[11]))
if (character.length > 11 && Misc.isInt(character[11]))
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
if(character.length > 12 && Misc.isInt(character[12]))
if (character.length > 12 && Misc.isInt(character[12]))
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
if(character.length > 13 && Misc.isInt(character[13]))
if (character.length > 13 && Misc.isInt(character[13]))
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
if(character.length > 14 && Misc.isInt(character[14]))
if (character.length > 14 && Misc.isInt(character[14]))
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
if(character.length > 15 && Misc.isInt(character[15]))
if (character.length > 15 && Misc.isInt(character[15]))
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
if(character.length > 16 && Misc.isInt(character[16]))
if (character.length > 16 && Misc.isInt(character[16]))
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
if(character.length > 17 && Misc.isInt(character[17]))
if (character.length > 17 && Misc.isInt(character[17]))
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
if(character.length > 18 && Misc.isInt(character[18]))
if (character.length > 18 && Misc.isInt(character[18]))
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
if(character.length > 19 && Misc.isInt(character[19]))
if (character.length > 19 && Misc.isInt(character[19]))
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
if(character.length > 20 && Misc.isInt(character[20]))
if (character.length > 20 && Misc.isInt(character[20]))
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
if(character.length > 21 && Misc.isInt(character[21]))
if (character.length > 21 && Misc.isInt(character[21]))
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
if(character.length > 22 && Misc.isInt(character[22]))
if (character.length > 22 && Misc.isInt(character[22]))
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
if(character.length > 24 && Misc.isInt(character[24]))
if (character.length > 24 && Misc.isInt(character[24]))
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
if(character.length > 25 && Misc.isInt(character[25]))
if (character.length > 25 && Misc.isInt(character[25]))
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
if(character.length > 26)
if (character.length > 26)
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
if(character.length > 27)
if (character.length > 27)
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
if(character.length > 28)
if (character.length > 28)
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
if(character.length > 29)
if (character.length > 29)
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
if(character.length > 30)
if (character.length > 30)
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
if(character.length > 31)
if (character.length > 31)
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(character[31]));
if(character.length > 32)
if (character.length > 32)
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
if(character.length > 33)
{
for(HUDType x : HUDType.values())
{
if(x.toString().equalsIgnoreCase(character[33]))
{
if (character.length > 33) {
for (HUDType x : HUDType.values()) {
if (x.toString().equalsIgnoreCase(character[33])) {
hud = x;
}
}
}
if(character.length > 34)
if (character.length > 34)
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
if(character.length > 35)
if (character.length > 35)
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
if(character.length > 36)
if (character.length > 36)
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
in.close();
loaded = true;
in.close();
return true;
}
in.close();
} catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
@@ -295,51 +291,50 @@ public class PlayerProfile {
}
public void save() {
Long timestamp = System.currentTimeMillis() / 1000; //Convert to seconds
Long timestamp = System.currentTimeMillis() / 1000;
// if we are using mysql save to database
if (Config.getInstance().getUseMySQL()) {
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"cooldowns SET "
+" mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
+", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
+", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
+", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA)
+", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)
+", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
+", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"skills SET "
+" taming = "+skills.get(SkillType.TAMING)
+", mining = "+skills.get(SkillType.MINING)
+", repair = "+skills.get(SkillType.REPAIR)
+", woodcutting = "+skills.get(SkillType.WOODCUTTING)
+", unarmed = "+skills.get(SkillType.UNARMED)
+", herbalism = "+skills.get(SkillType.HERBALISM)
+", excavation = "+skills.get(SkillType.EXCAVATION)
+", archery = " +skills.get(SkillType.ARCHERY)
+", swords = " +skills.get(SkillType.SWORDS)
+", axes = "+skills.get(SkillType.AXES)
+", acrobatics = "+skills.get(SkillType.ACROBATICS)
+", fishing = "+skills.get(SkillType.FISHING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"experience SET "
+" taming = "+skillsXp.get(SkillType.TAMING)
+", mining = "+skillsXp.get(SkillType.MINING)
+", repair = "+skillsXp.get(SkillType.REPAIR)
+", woodcutting = "+skillsXp.get(SkillType.WOODCUTTING)
+", unarmed = "+skillsXp.get(SkillType.UNARMED)
+", herbalism = "+skillsXp.get(SkillType.HERBALISM)
+", excavation = "+skillsXp.get(SkillType.EXCAVATION)
+", archery = " +skillsXp.get(SkillType.ARCHERY)
+", swords = " +skillsXp.get(SkillType.SWORDS)
+", axes = "+skillsXp.get(SkillType.AXES)
+", acrobatics = "+skillsXp.get(SkillType.ACROBATICS)
+", fishing = "+skillsXp.get(SkillType.FISHING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + hud.toString() + "' WHERE user_id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
+ ", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA)
+ ", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+ " WHERE user_id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "skills SET "
+ " taming = " + skills.get(SkillType.TAMING)
+ ", mining = " + skills.get(SkillType.MINING)
+ ", repair = " + skills.get(SkillType.REPAIR)
+ ", woodcutting = " + skills.get(SkillType.WOODCUTTING)
+ ", unarmed = " + skills.get(SkillType.UNARMED)
+ ", herbalism = " + skills.get(SkillType.HERBALISM)
+ ", excavation = " + skills.get(SkillType.EXCAVATION)
+ ", archery = " + skills.get(SkillType.ARCHERY)
+ ", swords = " + skills.get(SkillType.SWORDS)
+ ", axes = " + skills.get(SkillType.AXES)
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
+ ", fishing = " + skills.get(SkillType.FISHING)
+ " WHERE user_id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "experience SET "
+ " taming = " + skillsXp.get(SkillType.TAMING)
+ ", mining = " + skillsXp.get(SkillType.MINING)
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
+ ", woodcutting = " + skillsXp.get(SkillType.WOODCUTTING)
+ ", unarmed = " + skillsXp.get(SkillType.UNARMED)
+ ", herbalism = " + skillsXp.get(SkillType.HERBALISM)
+ ", excavation = " + skillsXp.get(SkillType.EXCAVATION)
+ ", archery = " + skillsXp.get(SkillType.ARCHERY)
+ ", swords = " + skillsXp.get(SkillType.SWORDS)
+ ", axes = " + skillsXp.get(SkillType.AXES)
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
+ " WHERE user_id = " + userid);
}
else {
// otherwise save to flatfile
@@ -362,7 +357,7 @@ public class PlayerProfile {
writer.append(playerName + ":");
writer.append(skills.get(SkillType.MINING) + ":");
writer.append("" + ":");
writer.append(party+":");
writer.append("" + ":");
writer.append(skillsXp.get(SkillType.MINING) + ":");
writer.append(skills.get(SkillType.WOODCUTTING) + ":");
writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
@@ -382,19 +377,19 @@ public class PlayerProfile {
writer.append(skillsXp.get(SkillType.SWORDS) + ":");
writer.append(skillsXp.get(SkillType.AXES) + ":");
writer.append(skillsXp.get(SkillType.ACROBATICS) + ":");
writer.append(""+":");
writer.append("" + ":");
writer.append(skills.get(SkillType.TAMING) + ":");
writer.append(skillsXp.get(SkillType.TAMING) + ":");
//Need to store the DATS of abilities nao
//Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER))+":");
writer.append(hud.toString()+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
writer.append(hud.toString() + ":");
writer.append(skills.get(SkillType.FISHING) + ":");
writer.append(skillsXp.get(SkillType.FISHING) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
@@ -414,73 +409,53 @@ public class PlayerProfile {
}
}
public void resetAllData() {
//This will reset everything to default values and then save the information to FlatFile/MySQL
for (SkillType skillType : SkillType.values()) {
if (skillType != SkillType.ALL) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0);
}
}
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
}
//Misc stuff
party = "";
save();
}
public void addPlayer()
{
public void addPlayer() {
try {
//Open the file to write the player
FileWriter file = new FileWriter(location, true);
BufferedWriter out = new BufferedWriter(file);
//Add the player to the end
out.append(playerName + ":");
out.append(0 + ":"); //mining
out.append(""+":");
out.append(party+":");
out.append(0+":"); //XP
out.append(0+":"); //woodcutting
out.append(0+":"); //woodCuttingXP
out.append(0+":"); //repair
out.append(0+":"); //unarmed
out.append(0+":"); //herbalism
out.append(0+":"); //excavation
out.append(0+":"); //archery
out.append(0+":"); //swords
out.append(0+":"); //axes
out.append(0+":"); //acrobatics
out.append(0+":"); //repairXP
out.append(0+":"); //unarmedXP
out.append(0+":"); //herbalismXP
out.append(0+":"); //excavationXP
out.append(0+":"); //archeryXP
out.append(0+":"); //swordsXP
out.append(0+":"); //axesXP
out.append(0+":"); //acrobaticsXP
out.append(""+":");
out.append(0+":"); //taming
out.append(0+":"); //tamingXP
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(Config.getInstance().defaulthud.toString()+":");//HUD
out.append(0+":"); //Fishing
out.append(0+":"); //FishingXP
out.append(0+":"); //Blast Mining
out.append("" + ":");
out.append("" + ":");
out.append(0 + ":"); //XP
out.append(0 + ":"); //woodcutting
out.append(0 + ":"); //woodCuttingXP
out.append(0 + ":"); //repair
out.append(0 + ":"); //unarmed
out.append(0 + ":"); //herbalism
out.append(0 + ":"); //excavation
out.append(0 + ":"); //archery
out.append(0 + ":"); //swords
out.append(0 + ":"); //axes
out.append(0 + ":"); //acrobatics
out.append(0 + ":"); //repairXP
out.append(0 + ":"); //unarmedXP
out.append(0 + ":"); //herbalismXP
out.append(0 + ":"); //excavationXP
out.append(0 + ":"); //archeryXP
out.append(0 + ":"); //swordsXP
out.append(0 + ":"); //axesXP
out.append(0 + ":"); //acrobaticsXP
out.append("" + ":");
out.append(0 + ":"); //taming
out.append(0 + ":"); //tamingXP
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(SpoutConfig.getInstance().defaulthud.toString() + ":");//HUD
out.append(0 + ":"); //Fishing
out.append(0 +":"); //FishingXP
out.append(0 + ":"); //Blast Mining
//Add more in the same format as the line above
out.newLine();
out.close();
} catch (Exception e) {
@@ -492,10 +467,6 @@ public class PlayerProfile {
* mySQL Stuff
*/
public int getLastLogin() {
return lastlogin;
}
public int getMySQLuserId() {
return userid;
}
@@ -609,18 +580,6 @@ public class PlayerProfile {
partyChatMode = !partyChatMode;
}
/*
* Exploit Prevention
*/
public long getRespawnATS() {
return respawnATS;
}
public void setRespawnATS(long newvalue) {
respawnATS = (int) (newvalue / 1000);
}
/*
* Tools
*/
@@ -905,12 +864,16 @@ public class PlayerProfile {
* Recently Hurt
*/
public long getRecentlyHurt() {
public int getRecentlyHurt() {
return recentlyHurt;
}
public void setRecentlyHurt(long newvalue) {
recentlyHurt = (int) (newvalue / 1000);
public void setRecentlyHurt(int value) {
recentlyHurt = value;
}
public void actualizeRecentlyHurt() {
respawnATS = (int) (System.currentTimeMillis() / 1000);
}
/*
@@ -947,6 +910,18 @@ public class PlayerProfile {
}
}
/*
* Exploit Prevention
*/
public int getRespawnATS() {
return respawnATS;
}
public void actualizeRespawnATS() {
respawnATS = (int) (System.currentTimeMillis() / 1000);
}
/*
* XP Functions
*/
@@ -970,8 +945,6 @@ public class PlayerProfile {
* @param newValue The amount of XP to add
*/
public void addXPOverride(SkillType skillType, int newValue) {
Player player = mcMMO.p.getServer().getPlayer(playerName);
if (skillType.equals(SkillType.ALL)) {
for (SkillType x : SkillType.values()) {
if (x.equals(SkillType.ALL)) {
@@ -1001,18 +974,16 @@ public class PlayerProfile {
}
/**
* Adds XP to the player, this is affected by skill modifiers and XP Rate
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
*
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param newvalue The amount of XP to add
*/
public void addXP(Player player, SkillType skillType, int newValue) {
if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) {
public void addXP(SkillType skillType, int newValue) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
return;
}
xpGainATS = (int) (System.currentTimeMillis() / 1000); //Setup a timestamp of when xp was given
double bonusModifier = 0;
if (inParty()) {
@@ -1039,6 +1010,16 @@ public class PlayerProfile {
}
}
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
xp = xp * 4;
}
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
xp = xp * 3;
}
else if (player.hasPermission("mcmmo.perks.xp.double")) {
xp = xp * 2;
}
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
lastgained = skillType;
@@ -1086,8 +1067,6 @@ public class PlayerProfile {
skills.put(skillType, newValue);
skillsXp.put(skillType, 0);
}
save();
}
/**
@@ -1131,7 +1110,6 @@ public class PlayerProfile {
* @return the power level of the player
*/
public int getPowerLevel() {
Player player = mcMMO.p.getServer().getPlayer(playerName);
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
@@ -1150,15 +1128,12 @@ public class PlayerProfile {
* @return the party bonus multiplier
*/
private double partyModifier(SkillType skillType) {
Player player = getPlayer();
double bonusModifier = 0.0;
for (Player x : Party.getInstance().getOnlineMembers(player)) {
String memberName = x.getName();
if (!memberName.equals(playerName) && Party.getInstance().isPartyLeader(memberName, getParty())) {
if (Misc.isNear(player.getLocation(), x.getLocation(), 25.0)) {
PlayerProfile PartyLeader = Users.getProfile(x);
for (Player member : party.getOnlineMembers()) {
if (party.getLeader().equals(member.getName())) {
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
PlayerProfile PartyLeader = Users.getProfile(member);
int leaderSkill = PartyLeader.getSkillLevel(skillType);
int playerSkill = getSkillLevel(skillType);
@@ -1177,21 +1152,16 @@ public class PlayerProfile {
* Party Stuff
*/
public void acceptInvite() {
party = invite;
invite = "";
public void setInvite(Party invite) {
this.invite = invite;
}
public void modifyInvite(String invitename) {
invite = invitename;
}
public String getInvite() {
public Party getInvite() {
return invite;
}
public boolean hasPartyInvite() {
if (invite != null && !invite.equals("") && !invite.equals("null")) {
if (invite != null) {
return true;
}
else {
@@ -1199,24 +1169,28 @@ public class PlayerProfile {
}
}
public void setParty(String newParty) {
party = newParty;
public void setParty(Party party) {
this.party = party;
}
public String getParty() {
public Party getParty() {
return party;
}
public boolean inParty() {
if (party != null) {
return true;
}
else {
return false;
}
}
public void removeParty() {
party = null;
}
public boolean inParty() {
if (party != null && !party.equals("") && !party.equals("null")) {
return true;
}
else {
return false;
}
public void removeInvite() {
invite = null;
}
}

View File

@@ -2,8 +2,6 @@ package com.gmail.nossr50.datatypes;
import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class Tree {
private TreeNode root = null;

View File

@@ -2,8 +2,6 @@ package com.gmail.nossr50.datatypes;
import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class TreeNode {
TreeNode left = null;
TreeNode right = null;

View File

@@ -2,9 +2,11 @@ package com.gmail.nossr50.datatypes.mods;
public class CustomItem {
protected int itemID;
protected short durability;
public CustomItem(int itemID) {
public CustomItem(int itemID, short durability) {
this.itemID = itemID;
this.durability = durability;
}
public int getItemID() {
@@ -14,4 +16,12 @@ public class CustomItem {
public void setItemID(int itemID) {
this.itemID = itemID;
}
public short getDurability() {
return durability;
}
public void setDurability(short durability) {
this.durability = durability;
}
}

View File

@@ -5,8 +5,8 @@ public class CustomTool extends CustomItem {
private boolean abilityEnabled;
private int tier;
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, int itemID) {
super(itemID);
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
super(itemID, durability);
this.xpMultiplier = xpMultiplier;
this.abilityEnabled = abilityEnabled;
this.tier = tier;

View File

@@ -4,6 +4,7 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;

View File

@@ -12,4 +12,4 @@ public class FakeBlockBreakEvent extends BlockBreakEvent {
public FakeBlockBreakEvent(Block theBlock, Player player) {
super(theBlock, player);
}
}
}

View File

@@ -0,0 +1,16 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.inventory.ItemStack;
/**
* Called when mcMMO damages a block due to a special ability.
*/
public class FakeBlockDamageEvent extends BlockDamageEvent {
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
super(player, block, itemInHand, instaBreak);
}
}

View File

@@ -58,10 +58,11 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}

View File

@@ -2,12 +2,32 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
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;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
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.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.skills.gathering.Excavation;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.gathering.Mining;
@@ -20,24 +40,6 @@ import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
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.getspout.spoutapi.sound.SoundEffect;
public class BlockListener implements Listener {
private final mcMMO plugin;
@@ -58,15 +60,34 @@ public class BlockListener implements Listener {
for (Block b : blocks) {
if (mcMMO.placeStore.isTrue(b)) {
mcMMO.placeStore.setTrue(b.getRelative(direction));
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
mcMMO.placeStore.setFalse(b);
}
}
for (Block b : blocks) {
if (mcMMO.placeStore.isTrue(b.getRelative(direction))) {
if (b.getRelative(direction).hasMetadata("pistonTrack")) {
mcMMO.placeStore.setTrue(b.getRelative(direction));
mcMMO.placeStore.setFalse(b);
b.getRelative(direction).removeMetadata("pistonTrack", plugin);
}
}
}
/**
* Monitor BlockPhysics events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPhysics(BlockPhysicsEvent event) {
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
Material type = event.getChangedType();
if (type == Material.GRAVEL || type == Material.SAND) {
Block fallenBlock = event.getBlock().getRelative(BlockFace.UP);
if (fallenBlock.getType() == type) {
mcMMO.placeStore.setTrue(fallenBlock);
}
}
}
@@ -98,10 +119,10 @@ public class BlockListener implements Listener {
Block block = event.getBlock();
Player player = event.getPlayer();
int id = block.getTypeId();
Material mat = block.getType();
Material type = block.getType();
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) {
if (type.equals(Material.SAND) || type.equals(Material.GRAVEL)) {
for (int y = -1; y + block.getY() >= 0; y--) {
if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
continue;
@@ -116,7 +137,9 @@ public class BlockListener implements Listener {
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockChecks.shouldBeWatched(block)) {
mcMMO.placeStore.setTrue(block);
if (!((type == Material.SAND || type == Material.GRAVEL) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR)) { //Don't wanna track sand that's gonna fall.
mcMMO.placeStore.setTrue(block);
}
}
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
@@ -211,6 +234,26 @@ public class BlockListener implements Listener {
if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) {
mcMMO.placeStore.setFalse(block);
}
//Remove metadata from fallen sand/gravel
Material aboveType = block.getRelative(BlockFace.UP).getType();
if (aboveType == Material.SAND || aboveType == Material.GRAVEL) {
for (int y = 1; block.getY() + y <= block.getWorld().getMaxHeight(); y++) {
Block relative = block.getRelative(0, y, 0);
Material relativeType = relative.getType();
if ((relativeType == Material.SAND || relativeType == Material.GRAVEL) && mcMMO.placeStore.isTrue(relative)) {
mcMMO.placeStore.setFalse(relative);
}
else if (!BlockChecks.shouldBeWatched(relative) && mcMMO.placeStore.isTrue(relative)){
mcMMO.placeStore.setFalse(relative);
}
else {
break;
}
}
}
}
/**
@@ -220,6 +263,11 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
if (event instanceof FakeBlockDamageEvent) {
return;
}
final int LEAF_BLOWER_LEVEL = 100;
Player player = event.getPlayer();
@@ -253,7 +301,7 @@ public class BlockListener implements Listener {
}
/* TREE FELLER SOUNDS */
if (configInstance.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
}
@@ -298,7 +346,7 @@ public class BlockListener implements Listener {
event.setInstaBreak(true);
}
if (configInstance.spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}

View File

@@ -9,6 +9,7 @@ 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;
import org.bukkit.event.Listener;
@@ -30,12 +31,12 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.combat.Archery;
import com.gmail.nossr50.skills.combat.Taming;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.gathering.BlastMining;
import com.gmail.nossr50.skills.misc.Acrobatics;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -61,6 +62,7 @@ public class EntityListener implements Listener {
}
Entity attacker = event.getDamager();
Entity defender = event.getEntity();
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
@@ -68,15 +70,13 @@ public class EntityListener implements Listener {
else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
if (animalTamer instanceof Player) {
attacker = (Player) animalTamer;
if (animalTamer instanceof Entity) {
attacker = (Entity) animalTamer;
}
}
Entity defender = event.getEntity();
if (attacker instanceof Player && defender instanceof Player) {
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
if (PartyManager.getInstance().inSameParty((Player) defender, (Player) attacker)) {
event.setCancelled(true);
return;
}
@@ -84,10 +84,10 @@ public class EntityListener implements Listener {
/* Check for invincibility */
if (defender instanceof LivingEntity) {
LivingEntity livingDefender = (LivingEntity)defender;
LivingEntity livingDefender = (LivingEntity) defender;
if (!Misc.isInvincible(livingDefender, event)) {
Combat.combatChecks(event, plugin);
Combat.combatChecks(event);
}
}
}
@@ -123,22 +123,25 @@ public class EntityListener implements Listener {
}
if (!Misc.isInvincible(player, event)) {
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player) && !player.isInsideVehicle() && !player.getItemInHand().getType().equals(Material.ENDER_PEARL)) {
Acrobatics.acrobaticsCheck(player, event);
if (cause == DamageCause.FALL && !player.isInsideVehicle() && !(player.getItemInHand().getType() == Material.ENDER_PEARL)) {
AcrobaticsManager acroManager = new AcrobaticsManager(player);
acroManager.rollCheck(event);
}
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
BlastMining.demolitionsExpertise(player, event);
}
if (event.getDamage() >= 1) {
PP.setRecentlyHurt(System.currentTimeMillis());
PP.actualizeRecentlyHurt();
}
}
} else if (lEntity instanceof Tameable) {
Tameable pet = (Tameable) lEntity;
AnimalTamer owner = pet.getOwner();
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (pet.getOwner() instanceof Player)) {
Taming.preventDamage(event);
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (owner instanceof Player) && pet instanceof Wolf) {
TamingManager tamingManager = new TamingManager((Player) owner);
tamingManager.preventDamage(event);
}
}
}
@@ -183,8 +186,8 @@ public class EntityListener implements Listener {
if (entity instanceof TNTPrimed) {
int id = entity.getEntityId();
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
if (plugin.tntIsTracked(id)) {
Player player = plugin.getTNTPlayer(id);
if (Permissions.getInstance().biggerBombs(player)) {
BlastMining.biggerBombs(player, event);
@@ -205,10 +208,10 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof TNTPrimed) {
int id = entity.getEntityId();
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
if (plugin.tntIsTracked(id)) {
Player player = plugin.getTNTPlayer(id);
BlastMining.dropProcessing(player, event);
plugin.tntTracker.remove(id);
plugin.removeFromTNTTracker(id);
}
}
}
@@ -313,8 +316,7 @@ public class EntityListener implements Listener {
break;
}
PP.addXP(player, SkillType.TAMING, xp);
Skills.XpCheckSkill(SkillType.TAMING, player);
Skills.xpProcessing(player, PP, SkillType.TAMING, xp);
}
}
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
@@ -10,17 +11,23 @@ import com.gmail.nossr50.util.Hardcore;
import com.gmail.nossr50.util.Permissions;
public class HardcoreListener implements Listener {
@EventHandler()
public void PlayerDeathEvent(PlayerDeathEvent event) {
/**
* Monitor PlayerDeath events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(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);
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
if (player.getKiller() instanceof Player) {
if (Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(player.getKiller(), player);
}
}
Hardcore.invokeStatPenalty(player);
}
}

View File

@@ -1,12 +1,8 @@
package com.gmail.nossr50.listeners;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -22,14 +18,12 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@@ -37,10 +31,12 @@ 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.combat.Taming;
import com.gmail.nossr50.runnables.BleedTimer;
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.taming.TamingManager;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Item;
import com.gmail.nossr50.util.Permissions;
@@ -127,7 +123,7 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) {
Users.addUser(event.getPlayer());
Users.addUser(event.getPlayer()).actualizeRespawnATS();
}
/**
@@ -142,15 +138,12 @@ public class PlayerListener implements Listener {
/* GARBAGE COLLECTION */
//Remove Spout Stuff
if (Config.getInstance().spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
if (mcMMO.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.remove(player);
}
//Bleed it out
BleedTimer.bleedOut(player);
//Schedule PlayerProfile removal 2 minutes after quitting
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
}
/**
@@ -161,23 +154,36 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
//TODO: Locale ALL the things.
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
String prefix = ChatColor.GOLD+"[mcMMO] ";
player.sendMessage(prefix+ChatColor.YELLOW+"Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
if(Config.getInstance().getHardcoreEnabled()) {
if(Config.getInstance().getHardcoreVampirismEnabled()) {
player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore & Vampirism enabled.");
player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"% "+ChatColor.DARK_AQUA+"Vampirism Stat Leech: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreVampirismStatLeechPercentage()+"%");
} else {
player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore enabled.");
player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"%");
String prefix = ChatColor.GOLD + "[mcMMO] ";
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(prefix + ChatColor.YELLOW + "Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
if (Config.getInstance().getHardcoreEnabled()) {
if (Config.getInstance().getHardcoreVampirismEnabled()) {
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore & Vampirism enabled.");
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "% " + ChatColor.DARK_AQUA + "Vampirism Stat Leech: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreVampirismStatLeechPercentage() + "%");
}
else {
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
}
}
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Quadruple XP - Receive 4x XP.");
}
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GREEN+ "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Triple XP - Receive 3x XP.");
}
else if (player.hasPermission("mcmmo.perks.xp.double")) {
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Double XP - Receive 2x XP.");
}
player.sendMessage(ChatColor.GOLD+"[mcMMO] " + ChatColor.GREEN + "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
}
@@ -186,8 +192,11 @@ public class PlayerListener implements Listener {
if (XprateCommand.xpevent) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
Users.getProfile(event.getPlayer()).actualizeRespawnATS();
}
/**
@@ -281,12 +290,16 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
/* CALL OF THE WILD CHECKS */
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
if (inHand.getType().equals(Material.RAW_FISH)) {
Taming.animalSummon(EntityType.OCELOT, player, plugin);
if (player.isSneaking()) {
Material type = inHand.getType();
if (type == Material.RAW_FISH) {
TamingManager tamingManager = new TamingManager(player);
tamingManager.summonOcelot();
}
else if (inHand.getType().equals(Material.BONE)) {
Taming.animalSummon(EntityType.WOLF, player, plugin);
else if (type == Material.BONE) {
TamingManager tamingManager = new TamingManager(player);
tamingManager.summonWolf();
}
}
@@ -308,53 +321,52 @@ public class PlayerListener implements Listener {
PlayerProfile PP = Users.getProfile(player);
if (PP.getPartyChatMode()) {
if (!PP.inParty()) {
Party party = PP.getParty();
if (party == null) {
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());
String partyName = party.getName();
String playerName = player.getName();
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
}
event.setMessage(chatEvent.getMessage());
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + playerName + ChatColor.GREEN + ") ";
Set<Player> intendedRecipients = new HashSet<Player>();
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
for (Player x : Party.getInstance().getOnlineMembers(player)) {
intendedRecipients.add(x);
for (Player member : party.getOnlineMembers()) {
member.sendMessage(prefix + chatEvent.getMessage());
}
ChatColor bracketColor = ChatColor.GREEN;
event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s");
event.getRecipients().retainAll(intendedRecipients);
event.setCancelled(true);
}
else if (PP.getAdminChatMode()) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
String playerName = player.getName();
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
}
event.setMessage(chatEvent.getMessage());
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + playerName + ChatColor.AQUA + "} ";
Set<Player> intendedRecipients = new HashSet<Player>();
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
intendedRecipients.add(x);
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
p.sendMessage(prefix + chatEvent.getMessage());
}
}
ChatColor bracketColor = ChatColor.AQUA;
event.setFormat(bracketColor + "{" + ChatColor.WHITE + "%1$s" + bracketColor + "} %2$s");
event.getRecipients().retainAll(intendedRecipients);
event.setCancelled(true);
}
}
@@ -369,13 +381,13 @@ public class PlayerListener implements Listener {
String command = message.substring(1).split(" ")[0];
String lowerCaseCommand = command.toLowerCase();
if (plugin.aliasMap.containsKey(lowerCaseCommand)) {
if (plugin.commandIsAliased(lowerCaseCommand)) {
//We should find a better way to avoid string replacement where the alias is equals to the command
if (command.equals(plugin.aliasMap.get(lowerCaseCommand))) {
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
return;
}
event.setMessage(message.replace(command, plugin.aliasMap.get(lowerCaseCommand)));
event.setMessage(message.replace(command, plugin.getCommandAlias(lowerCaseCommand)));
}
}
}

View File

@@ -1,48 +0,0 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutInputListener implements Listener {
private mcMMO plugin;
public SpoutInputListener(mcMMO plugin) {
this.plugin = plugin;
}
/**
* Monitor Spout KeyPressed events.
*
* @param event The event to watch
*/
@EventHandler
public void onKeyPressedEvent(KeyPressedEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
return;
}
if (event.getKey() == SpoutStuff.keypress) {
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
else {
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
}
}
}

View File

@@ -3,22 +3,30 @@ package com.gmail.nossr50.listeners;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
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;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutListener implements Listener {
//Why do we have this here? We never use it...
mcMMO plugin = null;
private final mcMMO plugin;
public SpoutListener(mcMMO pluginx) {
plugin = pluginx;
public SpoutListener(mcMMO plugin) {
this.plugin = plugin;
}
/**
@@ -32,15 +40,106 @@ public class SpoutListener implements Listener {
PlayerProfile PPs = Users.getProfile(sPlayer);
//TODO: Add custom titles based on skills
if (Config.getInstance().getShowPowerLevelForSpout()) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl"
+ ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
if (SpoutConfig.getInstance().getShowPowerLevel()) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
}
if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
PPs.toggleSpoutEnabled();
}
}
}
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler
public void onButtonClick(ButtonClickEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PP = Users.getProfile(sPlayer);
if (event.getButton() instanceof ButtonHUDStyle) {
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.remove(sPlayer);
switch (PP.getHUDType()) {
case RETRO:
PP.setHUDType(HUDType.STANDARD);
break;
case STANDARD:
PP.setHUDType(HUDType.SMALL);
break;
case SMALL:
PP.setHUDType(HUDType.DISABLED);
break;
case DISABLED:
PP.setHUDType(HUDType.RETRO);
break;
default:
break;
}
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
}
}
else if (event.getButton() instanceof ButtonEscape) {
sPlayer.getMainScreen().closePopup();
}
else if (event.getButton() instanceof ButtonPartyToggle) {
PP.togglePartyHUD();
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
bpt.updateText(PP);
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
}
}
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler
public void onScreenClose(ScreenCloseEvent event) {
if (event.getScreen() instanceof PopupMMO) {
SpoutStuff.playerScreens.remove(event.getPlayer());
}
}
/**
* Monitor Spout KeyPressed events.
*
* @param event The event to watch
*/
@EventHandler
public void onKeyPressedEvent(KeyPressedEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
return;
}
if (event.getKey() == SpoutStuff.keypress) {
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
else {
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
}
}
}

View File

@@ -1,91 +0,0 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
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;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutScreenListener implements Listener {
//Why do we have this here? We never use it...
mcMMO plugin = null;
public SpoutScreenListener(mcMMO pluginx) {
plugin = pluginx;
}
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler
public void onButtonClick(ButtonClickEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PP = Users.getProfile(sPlayer);
if (event.getButton() instanceof ButtonHUDStyle) {
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.remove(sPlayer);
switch (PP.getHUDType()) {
case RETRO:
PP.setHUDType(HUDType.STANDARD);
break;
case STANDARD:
PP.setHUDType(HUDType.SMALL);
break;
case SMALL:
PP.setHUDType(HUDType.DISABLED);
break;
case DISABLED:
PP.setHUDType(HUDType.RETRO);
break;
default:
break;
}
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
}
}
else if (event.getButton() instanceof ButtonEscape) {
sPlayer.getMainScreen().closePopup();
}
else if (event.getButton() instanceof ButtonPartyToggle) {
PP.togglePartyHUD();
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
bpt.updateText(PP);
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
}
}
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler
public void onScreenClose(ScreenCloseEvent event) {
if (event.getScreen() instanceof PopupMMO) {
SpoutStuff.playerScreens.remove(event.getPlayer());
}
}
}

View File

@@ -1,19 +1,74 @@
package com.gmail.nossr50;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.skills.*;
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 java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import com.gmail.nossr50.commands.general.AddlevelsCommand;
import com.gmail.nossr50.commands.general.AddxpCommand;
import com.gmail.nossr50.commands.general.InspectCommand;
import com.gmail.nossr50.commands.general.McstatsCommand;
import com.gmail.nossr50.commands.general.MmoeditCommand;
import com.gmail.nossr50.commands.general.MmoupdateCommand;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.commands.mc.McabilityCommand;
import com.gmail.nossr50.commands.mc.MccCommand;
import com.gmail.nossr50.commands.mc.McgodCommand;
import com.gmail.nossr50.commands.mc.McmmoCommand;
import com.gmail.nossr50.commands.mc.McrefreshCommand;
import com.gmail.nossr50.commands.mc.McremoveCommand;
import com.gmail.nossr50.commands.mc.MctopCommand;
import com.gmail.nossr50.commands.party.ACommand;
import com.gmail.nossr50.commands.party.AcceptCommand;
import com.gmail.nossr50.commands.party.InviteCommand;
import com.gmail.nossr50.commands.party.PCommand;
import com.gmail.nossr50.commands.party.PartyCommand;
import com.gmail.nossr50.commands.party.PtpCommand;
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
import com.gmail.nossr50.commands.skills.ArcheryCommand;
import com.gmail.nossr50.commands.skills.AxesCommand;
import com.gmail.nossr50.commands.skills.ExcavationCommand;
import com.gmail.nossr50.commands.skills.FishingCommand;
import com.gmail.nossr50.commands.skills.HerbalismCommand;
import com.gmail.nossr50.commands.skills.MiningCommand;
import com.gmail.nossr50.commands.skills.RepairCommand;
import com.gmail.nossr50.commands.skills.SwordsCommand;
import com.gmail.nossr50.commands.skills.TamingCommand;
import com.gmail.nossr50.commands.skills.UnarmedCommand;
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
import com.gmail.nossr50.commands.spout.MchudCommand;
import com.gmail.nossr50.commands.spout.XplockCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.RepairConfigManager;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.config.mods.CustomToolsConfig;
import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.datatypes.PlayerProfile;
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 com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.runnables.SaveTimer;
import com.gmail.nossr50.runnables.SkillMonitor;
import com.gmail.nossr50.runnables.SpoutStart;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
import com.gmail.nossr50.skills.repair.Repairable;
@@ -24,30 +79,6 @@ import com.gmail.nossr50.util.Metrics.Graph;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.HardcoreListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import net.shatteredlands.shatt.backup.ZipLibrary;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
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.Player;
public class mcMMO extends JavaPlugin {
@@ -57,8 +88,8 @@ public class mcMMO extends JavaPlugin {
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<Integer, Player> tntTracker = new HashMap<Integer, Player>();
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
public static File versionFile;
public static Database database;
@@ -68,14 +99,22 @@ public class mcMMO extends JavaPlugin {
public static RepairManager repairManager;
/* Jar Stuff */
public File mcmmo;
public static File mcmmo;
//File Paths
public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory;
public static String mainDirectory;
public static String flatFileDirectory;
public static String usersFile;
public static String leaderboardDirectory;
public static String modDirectory;
//Spout Check
public static boolean spoutEnabled;
/**
* Things to be run when the plugin is enabled.
*/
@Override
public void onEnable() {
p = this;
setupFilePaths();
@@ -159,14 +198,15 @@ public class mcMMO extends JavaPlugin {
Graph graph = metrics.createGraph("Percentage of servers using timings");
if(pm.useTimings()) {
if (pm.useTimings()) {
graph.addPlotter(new Metrics.Plotter("Enabled") {
@Override
public int getValue() {
return 1;
}
});
} else {
}
else {
graph.addPlotter(new Metrics.Plotter("Disabled") {
@Override
public int getValue() {
@@ -184,6 +224,10 @@ public class mcMMO extends JavaPlugin {
// Get our ChunkletManager
placeStore = ChunkletManagerFactory.getChunkletManager();
for (World world : getServer().getWorlds()) {
placeStore.loadWorld(world);
}
}
/**
@@ -198,18 +242,6 @@ public class mcMMO extends JavaPlugin {
modDirectory = mainDirectory + "ModConfigs" + File.separator;
}
/**
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player Player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getPlayerProfile(Player player) {
return Users.getProfile(player);
}
/**
* Get profile of the player by name.
* </br>
@@ -218,31 +250,47 @@ public class mcMMO extends JavaPlugin {
* @param playerName Name of player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getPlayerProfileByName(String playerName) {
return Users.getProfileByName(playerName);
public PlayerProfile getPlayerProfile(String playerName) {
return Users.getProfile(playerName);
}
/**
* Get profile of the offline player.
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player Offline player whose profile to get
* @param player player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getOfflinePlayerProfile(OfflinePlayer player) {
public PlayerProfile getPlayerProfile(OfflinePlayer player) {
return Users.getProfile(player);
}
/**
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player player whose profile to get
* @return the PlayerProfile object
*/
@Deprecated
public PlayerProfile getPlayerProfile(Player player) {
return Users.getProfile(player);
}
/**
* Things to be run when the plugin is disabled.
*/
@Override
public void onDisable() {
//Make sure to save player information if the server shuts down
for (PlayerProfile x : Users.getProfiles().values()) {
x.save();
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
playerProfile.save();
}
PartyManager.getInstance().saveParties();
getServer().getScheduler().cancelTasks(this); //This removes our tasks
//Save our metadata
@@ -366,7 +414,7 @@ public class mcMMO extends JavaPlugin {
}
if (configInstance.getCommandMmoeditEnabled()) {
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
getCommand("mmoedit").setExecutor(new MmoeditCommand());
}
if (configInstance.getCommandInspectEnabled()) {
@@ -387,220 +435,62 @@ public class mcMMO extends JavaPlugin {
getCommand("mchud").setExecutor(new MchudCommand(this));
}
/*
* Boilerplate Custom Config Stuff (Treasures)
*/
private FileConfiguration treasuresConfig = null;
private File treasuresConfigFile = null;
/**
* Reload the Treasures.yml file.
*/
public void reloadTreasuresConfig() {
if (treasuresConfigFile == null) {
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
}
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
if (isInJar("treasures.yml")) {
InputStream defConfigStream = getResource("treasures.yml");
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
treasuresConfig.setDefaults(defConfig);
}
}
/**
* Get the Treasures config information.
* Checks to see if the alias map contains the given key.
*
* @return the configuration object for treasures.yml
* @param command The command to check
* @return true if the command is in the map, false otherwise
*/
public FileConfiguration getTreasuresConfig() {
if (treasuresConfig == null) {
reloadTreasuresConfig();
}
return treasuresConfig;
public boolean commandIsAliased(String command) {
return aliasMap.containsKey(command);
}
/**
* Save the Treasures config informtion.
*/
public void saveTreasuresConfig() {
if (treasuresConfig == null || treasuresConfigFile == null) {
return;
}
try {
treasuresConfig.save(treasuresConfigFile);
}
catch (IOException ex) {
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.
* Get the alias of a given command.
*
* @return the configuration object for tools.yml
* @param command The command to retrieve the alias of
* @return the alias of the command
*/
public FileConfiguration getToolsConfig() {
if (toolsConfig == null) {
reloadToolsConfig();
}
return toolsConfig;
public String getCommandAlias(String command) {
return aliasMap.get(command);
}
/**
* 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.
* Add a set of values to the TNT tracker.
*
* @return the configuration object for armor.yml
* @param tntID The EntityID of the TNT
* @param playerName The name of the detonating player
*/
public FileConfiguration getArmorConfig() {
if (armorConfig == null) {
reloadArmorConfig();
}
return armorConfig;
public void addToTNTTracker(int tntID, String playerName) {
tntTracker.put(tntID, playerName);
}
/**
* 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.
* Check to see if a given TNT Entity is tracked.
*
* @return the configuration object for blocks.yml
* @param tntID The EntityID of the TNT
* @return true if the TNT is being tracked, false otherwise
*/
public FileConfiguration getBlocksConfig() {
if (blocksConfig == null) {
reloadBlocksConfig();
}
return blocksConfig;
public boolean tntIsTracked(int tntID) {
return tntTracker.containsKey(tntID);
}
/**
* Save the Blocks config informtion.
* Get the player who detonated the TNT.
*
* @param tntID The EntityID of the TNT
* @return the Player who detonated it
*/
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 Player getTNTPlayer(int tntID) {
return getServer().getPlayer(tntTracker.get(tntID));
}
public boolean isInJar(String resource) {
InputStream iStream = getResource(resource);
return iStream != null;
/**
* Remove TNT from the tracker after it explodes.
*
* @param tntID The EntityID of the TNT
*/
public void removeFromTNTTracker(int tntID) {
tntTracker.remove(tntID);
}
}

View File

@@ -1,650 +1,65 @@
package com.gmail.nossr50.party;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class Party {
public static String pluginPath;
public static String partyPlayersFile;
public static String partyLocksFile;
public static String partyPasswordsFile;
private List<String> members = new ArrayList<String>();
private String leader;
private String name;
private String password;
private boolean locked;
HashMap<String, HashMap<String, Boolean>> partyPlayers = new HashMap<String, HashMap<String, Boolean>>();
HashMap<String, Boolean> partyLocks = new HashMap<String, Boolean>();
HashMap<String, String> partyPasswords = new HashMap<String, String>();
private static mcMMO plugin;
private static volatile Party instance;
private Party() {
plugin = mcMMO.p;
pluginPath = plugin.getDataFolder().getPath();
partyPlayersFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
partyLocksFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
partyPasswordsFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
new File(pluginPath + File.separator + "FlatFileStuff").mkdir();
loadParties();
public List<String> getMembers() {
return members;
}
public static Party getInstance() {
if (instance == null) {
instance = new Party();
}
return instance;
}
public List<Player> getOnlineMembers() {
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
List<Player> onlineMembers = new ArrayList<Player>();
/**
* Check if two players are in the same party.
*
* @param playera The first player
* @param playerb The second player
* @return true if they are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb){
PlayerProfile PPa = Users.getProfile(playera);
PlayerProfile PPb = Users.getProfile(playerb);
if ((PPa.inParty() && PPb.inParty()) && (PPa.getParty().equals(PPb.getParty()))) {
return true;
}
else {
return false;
}
}
/**
* Get the number of players in this player's party.
*
* @param player The player to check
* @param players A list of players to
* @return the number of players in this player's party
*/
public int partyCount(Player player) {
if (player != null) {
return getAllMembers(player).size();
}
else {
return 0;
}
}
private void informPartyMembers(Player player) {
String playerName = player.getName();
if (player != null) {
for (Player p : getOnlineMembers(player)) {
if (p.getName() != playerName) {
p.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
}
}
/**
* Get a list of all online players in this player's party.
*
* @param player The player to check
* @return all online players in the player's party
*/
public ArrayList<Player> getOnlineMembers(Player player) {
ArrayList<Player> players = new ArrayList<Player>();
if (player != null) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (inSameParty(player, p)) {
players.add(p);
}
for (Player onlinePlayer : onlinePlayers) {
if (members.contains(onlinePlayer.getName())) {
onlineMembers.add(onlinePlayer);
}
}
return players;
return onlineMembers;
}
/**
* Get a list of all online players in this party.
*
* @param partyName The party to check
* @return all online players in this party
*/
public ArrayList<Player> getOnlineMembers(String partyName) {
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : plugin.getServer().getOnlinePlayers()) {
PlayerProfile PP = Users.getProfile(p);
if (PP.inParty()) {
if (PP.getParty().equalsIgnoreCase(partyName)) {
players.add(p);
}
}
}
return players;
}
/**
* Get a list of all players in this player's party.
*
* @param player The player to check
* @return all the players in the player's party
*/
public ArrayList<Player> getAllMembers(Player player) {
ArrayList<Player> players = new ArrayList<Player>();
HashMap<String, PlayerProfile> profiles = Users.getProfiles();
if (player != null) {
for (String name : profiles.keySet()) {
Player otherPlayer = profiles.get(name).getPlayer();
if (otherPlayer != null && inSameParty(otherPlayer, player)) {
players.add(otherPlayer);
}
}
}
return players;
}
/**
* Get a list of all current party names.
*
* @return the list of parties.
*/
public ArrayList<String> getParties() {
String location = plugin.usersFile;
ArrayList<String> parties = new ArrayList<String>();
try {
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
String theparty = null;
//Party
if (character.length > 3) {
theparty = character[3];
}
if (!parties.contains(theparty)) {
parties.add(theparty);
}
}
in.close();
}
catch (Exception e) {
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
return parties;
}
/**
* Notify party members when the party owner changes.
*
* @param newOwnerName The name of the new party owner
*/
private void informPartyMembersOwnerChange(String newOwnerName) {
Player newOwner = plugin.getServer().getPlayer(newOwnerName);
if (newOwner != null) {
for (Player p : getOnlineMembers(newOwner)) {
if (p.getName() != newOwnerName) {
p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale
}
}
}
}
/**
* Notify party members when the a party member quits.
*
* @param player The player that quit
*/
private void informPartyMembersQuit(Player player) {
String playerName = player.getName();
if (player != null) {
for (Player p : getOnlineMembers(player)) {
if (p.getName() != playerName) {
p.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
}
}
/**
* Remove a player from a party.
*
* @param player The player to remove
* @param PP The profile of the player to remove
*/
public void removeFromParty(Player player, PlayerProfile PP) {
String party = PP.getParty();
String playerName = player.getName();
//Stop NPE... hopefully
if (!isParty(party) || !isInParty(player, PP)) {
addToParty(player, PP, party, false, null);
}
informPartyMembersQuit(player);
if (isPartyLeader(playerName, party)) {
if (isPartyLocked(party)) {
unlockParty(party);
}
}
partyPlayers.get(party).remove(playerName);
if (isPartyEmpty(party)) {
deleteParty(party);
}
PP.removeParty();
savePartyFile(partyPlayersFile, partyPlayers);
}
/**
* Add a player to a party.
*
* @param player The player to add to the party
* @param PP The profile of the player to add to the party
* @param newParty The party to add the player to
* @param invite true if the player was invited to this party, false otherwise
* @param password the password for this party, null if there was no password
*/
public void addToParty(Player player, PlayerProfile PP, String newParty, Boolean invite, String password) {
String playerName = player.getName();
//Fix for FFS
newParty = newParty.replace(":", ".");
//Don't care about passwords on invites
if (!invite) {
//Don't care about passwords if it isn't locked
if (isPartyLocked(newParty)) {
if (isPartyPasswordProtected(newParty)) {
if (password == null) {
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
return;
}
else if(!password.equalsIgnoreCase(getPartyPassword(newParty))) {
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
return;
}
}
else {
player.sendMessage("Party is locked."); //TODO: Needs more locale.
return;
}
}
}
else {
PP.acceptInvite();
}
//New party?
if (!isParty(newParty)) {
putNestedEntry(partyPlayers, newParty, playerName, true);
//Get default locking behavior from config?
partyLocks.put(newParty, false);
partyPasswords.put(newParty, null);
saveParties();
}
else {
putNestedEntry(partyPlayers, newParty, playerName, false);
savePartyFile(partyPlayersFile, partyPlayers);
}
PP.setParty(newParty);
informPartyMembers(player);
if (!invite) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{ newParty }));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() }));
}
}
private static <U,V,W> W putNestedEntry(HashMap<U, HashMap<V, W>> nest, U nestKey, V nestedKey, W nestedValue) {
HashMap<V,W> nested = nest.get(nestKey);
if (nested == null) {
nested = new HashMap<V,W>();
nest.put(nestKey, nested);
}
return nested.put(nestedKey, nestedValue);
}
/**
* Lock a party.
*
* @param partyName The party to lock
*/
public void lockParty(String partyName) {
partyLocks.put(partyName, true);
savePartyFile(partyLocksFile, partyLocks);
}
/**
* Unlock a party.
*
* @param partyName The party to unlock
*/
public void unlockParty(String partyName) {
partyLocks.put(partyName, false);
savePartyFile(partyLocksFile, partyLocks);
}
/**
* Delete a party.
*
* @param partyName The party to delete
*/
private void deleteParty(String partyName) {
partyPlayers.remove(partyName);
partyLocks.remove(partyName);
partyPasswords.remove(partyName);
saveParties();
}
/**
* Set the password for a party.
*
* @param partyName The party name
* @param password The new party password
*/
public void setPartyPassword(String partyName, String password) {
if (password.equalsIgnoreCase("\"\"")) { //What's with that password string?
password = null;
}
partyPasswords.put(partyName, password);
savePartyFile(partyPasswordsFile, partyPasswords);
}
/**
* Get the leader of a party.
*
* @param partyName The party name
* @return the leader of the party
*/
public Player getPartyLeader(String partyName) {
Player leader = null;
for (String name : partyPlayers.get(partyName).keySet()) {
if (partyPlayers.get(partyName).get(name)) {
leader = plugin.getServer().getPlayer(name);
break;
}
}
public String getLeader() {
return leader;
}
/**
* Set the leader of a party.
*
* @param partyName The party name
* @param playerName The name of the player to set as leader
*/
public void setPartyLeader(String partyName, String playerName) {
for (String name : partyPlayers.get(partyName).keySet()) {
if (name.equalsIgnoreCase(playerName)) {
partyPlayers.get(partyName).put(playerName, true);
informPartyMembersOwnerChange(playerName);
plugin.getServer().getPlayer(playerName).sendMessage("You are now the party owner."); //TODO: Needs more locale.
continue;
}
if (partyPlayers.get(partyName).get(name)) {
plugin.getServer().getPlayer(name).sendMessage("You are no longer party owner."); //TODO: Needs more locale.
partyPlayers.get(partyName).put(name, false);
}
}
public String getName() {
return name;
}
/**
* Get the password of a party.
*
* @param partyName The party name
* @return The password of this party
*/
public String getPartyPassword(String partyName) {
return partyPasswords.get(partyName);
public String getPassword() {
return password;
}
/**
* Check if a player can invite others to their party.
*
* @param player The player to check
* @param PP The profile of the given player
* @return true if the player can invite, false otherwise
*/
public boolean canInvite(Player player, PlayerProfile PP) {
String party = PP.getParty();
if (isPartyLocked(party) && !isPartyLeader(player.getName(), party)) {
return false;
}
else {
return true;
}
public boolean isLocked() {
return locked;
}
/**
* Check if a string is a valid party name.
*
* @param partyName The party name to check
* @return true if this is a valid party, false otherwise
*/
public boolean isParty(String partyName) {
return partyPlayers.containsKey(partyName);
public void setName(String name) {
this.name = name;
}
/**
* Check if a party is empty.
*
* @param partyName The party to check
* @return true if this party is empty, false otherwise
*/
public boolean isPartyEmpty(String partyName) {
return partyPlayers.get(partyName).isEmpty();
public void setLeader(String leader) {
this.leader = leader;
}
/**
* Check if a player is the party leader.
*
* @param playerName The player name to check
* @param partyName The party name to check
* @return true if the player is the party leader, false otherwise
*/
public boolean isPartyLeader(String playerName, String partyName) {
HashMap<String, Boolean> partyMembers = partyPlayers.get(partyName);
if (partyMembers != null) {
Boolean isLeader = partyMembers.get(playerName);
if (isLeader == null) {
return false;
}
else {
return isLeader;
}
}
else {
return false;
}
public void setPassword(String password) {
this.password = password;
}
/**
* Check if this party is locked.
*
* @param partyName The party to check
* @return true if this party is locked, false otherwise
*/
public boolean isPartyLocked(String partyName) {
Boolean isLocked = partyLocks.get(partyName);
if (isLocked == null) {
return false;
}
else {
return isLocked;
}
}
/**
* Check if this party is password protected.
*
* @param partyName The party to check
* @return true if this party is password protected, false otherwise
*/
public boolean isPartyPasswordProtected(String partyName) {
String password = partyPasswords.get(partyName);
if (password == null) {
return false;
}
else {
return true;
}
}
/**
* Check if a player is in the party reflected by their profile.
*
* @param player The player to check
* @param PP The profile of the player
* @return true if this player is in the right party, false otherwise
*/
public boolean isInParty(Player player, PlayerProfile PP) {
Map<String, Boolean> party = partyPlayers.get(PP.getParty());
if (party != null && party.containsKey(player.getName())) {
return true;
}
else {
return false;
}
}
/**
* Load all party related files.
*/
@SuppressWarnings("unchecked")
public void loadParties() {
if (new File(partyPlayersFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
partyPlayers = (HashMap<String, HashMap<String, Boolean>>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
plugin.getLogger().info("partyPlayersFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if (new File(partyLocksFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
partyLocks = (HashMap<String, Boolean>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
plugin.getLogger().info("partyLocksFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if (new File(partyPasswordsFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
this.partyPasswords = (HashMap<String, String>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
plugin.getLogger().info("partyPasswordsFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
/**
* Save all party-related files.
*/
private void saveParties() {
savePartyFile(partyPlayersFile, partyPlayers);
savePartyFile(partyLocksFile, partyLocks);
savePartyFile(partyPasswordsFile, partyPasswords);
}
/**
* Save a party-related file.
*
* @param fileName The filename to save as
* @param partyData The Hashmap with the party data
*/
private void savePartyFile(String fileName, Object partyData) {
try {
new File(fileName).createNewFile();
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(fileName));
obj.writeObject(partyData);
obj.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
public void setLocked(boolean locked) {
this.locked = locked;
}
}

View File

@@ -0,0 +1,421 @@
package com.gmail.nossr50.party;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class PartyManager {
private static String partiesFilePath;
private static List<Party> parties = new ArrayList<Party>();
private static mcMMO plugin;
private static PartyManager instance;
private PartyManager() {
plugin = mcMMO.p;
partiesFilePath = plugin.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
loadParties();
}
public static PartyManager getInstance() {
if (instance == null) {
instance = new PartyManager();
}
return instance;
}
/**
* Check if two players are in the same party.
*
* @param firstPlayer The first player
* @param secondPlayer The second player
* @return true if they are in the same party, false otherwise
*/
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
if (Users.getProfile(firstPlayer).getParty() == null || Users.getProfile(secondPlayer).getParty() == null
|| !Users.getProfile(firstPlayer).getParty().equals(Users.getProfile(secondPlayer).getParty())) {
return false;
}
return true;
}
/**
* Notify party members when a player joins
*
* @param playerName The name of the player that joins
* @param party The concerned party
*/
private void informPartyMembersJoin(String playerName, Party party) {
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
}
/**
* Notify party members when a party member quits.
*
* @param playerName The name of the player that quits
* @param party The concerned party
*/
private void informPartyMembersQuit(String playerName, Party party) {
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
}
/**
* Get a list of all players in this player's party.
*
* @param player The player to check
* @return all the players in the player's party
*/
public List<String> getAllMembers(Player player) {
Party party = Users.getProfile(player).getParty();
if (party == null) {
return null;
}
return party.getMembers();
}
/**
* Get a list of all online players in this party.
*
* @param partyName The party to check
* @return all online players in this party
*/
public List<Player> getOnlineMembers(String partyName) {
Party party = getParty(partyName);
if (party == null) {
return null;
}
return party.getOnlineMembers();
}
/**
* Get a list of all online players in this party.
*
* @param player The player to check
* @return all online players in this party
*/
public List<Player> getOnlineMembers(Player player) {
return getOnlineMembers(player.getName());
}
/**
* Retrieve a party by its name
*
* @param partyName The party name
* @return the existing party, null otherwise
*/
public Party getParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return party;
}
}
return null;
}
/**
* Retrieve a party by a member name
*
* @param playerName The member name
* @return the existing party, null otherwise
*/
public Party getPlayerParty(String playerName) {
for (Party party : parties) {
if (party.getMembers().contains(playerName)) {
return party;
}
}
return null;
}
/**
* Get a list of all current parties.
*
* @return the list of parties.
*/
public List<Party> getParties() {
return parties;
}
/**
* Remove a player from a party.
*
* @param playerName The name of the player to remove
* @param party The party
*/
public void removeFromParty(String playerName, Party party) {
List<String> members = party.getMembers();
members.remove(playerName);
if (members.isEmpty()) {
parties.remove(party);
}
else {
if (party.getLeader().equals(playerName)) {
party.setLocked(false);
}
informPartyMembersQuit(playerName, party);
}
PlayerProfile playerProfile = Users.getProfile(playerName);
if (playerProfile != null) {
playerProfile.removeParty();
}
}
/**
* Add a player to a party.
*
* @param player The player to add to the party
* @param playerProfile The profile of the player to add to the party
* @param partyName The party to add the player to
* @param password the password for this party, null if there was no password
*/
public void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
partyName = partyName.replace(".", "");
Party party = getParty(partyName);
String playerName = player.getName();
if (party == null) {
party = new Party();
party.setName(partyName);
party.setLeader(playerName);
if (password != null) {
party.setPassword(password);
party.setLocked(true);
}
parties.add(party);
}
else if (!checkJoinability(player, playerProfile, party, password)) {
return;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{party.getName()}));
addToParty(player.getName(), playerProfile, party);
}
/**
* Check if a player can join a party
*
* @param player The player trying to join a party
* @param playerProfile The profile of the player
* @param party The party
* @param password The password provided by the player
* @return true if the player can join the party
*/
private boolean checkJoinability(Player player, PlayerProfile playerProfile, Party party, String password) {
//Don't care about passwords if it isn't locked
if (party.isLocked()) {
String partyPassword = party.getPassword();
if (partyPassword != null) {
if (password == null) {
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
return false;
}
else if (!password.equals(partyPassword)) {
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
return false;
}
}
else {
player.sendMessage("Party is locked."); //TODO: Needs more locale.
return false;
}
}
return true;
}
/**
* Accept a party invitation
*
* @param player The player to add to the party
* @param playerProfile The profile of the player
*/
public void joinInvitedParty(Player player, PlayerProfile playerProfile) {
Party invite = playerProfile.getInvite();
if (!parties.contains(invite)) {
parties.add(invite);
}
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{invite.getName()}));
playerProfile.removeInvite();
addToParty(player.getName(), playerProfile, invite);
}
/**
* Add a player to a party
*
* @param playerName The name of the player to add to a party
* @param playerProfile The profile of the player
* @param party The party
*/
public void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
informPartyMembersJoin(playerName, party);
playerProfile.setParty(party);
party.getMembers().add(playerName);
}
/**
* Get the leader of a party.
*
* @param partyName The party name
* @return the leader of the party
*/
public String getPartyLeader(String partyName) {
Party party = getParty(partyName);
if (party == null) {
return null;
}
return party.getLeader();
}
/**
* Set the leader of a party.
*
* @param playerName The name of the player to set as leader
* @param party The party
*/
public void setPartyLeader(String playerName, Party party) {
String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
member.sendMessage("You are now the party owner."); //TODO: Needs more locale.
}
else if (member.equals(leaderName)) {
member.sendMessage("You are no longer party owner."); //TODO: Needs more locale.
}
else {
member.sendMessage(playerName + " is the new party owner."); //TODO: Needs more Locale.
}
}
party.setLeader(playerName);
}
/**
* Check if a player can invite others to their party.
*
* @param player The player to check
* @param playerProfile The profile of the given player
* @return true if the player can invite
*/
public boolean canInvite(Player player, PlayerProfile playerProfile) {
Party party = playerProfile.getParty();
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
return false;
}
return true;
}
/**
* Check if a string is a valid party name.
*
* @param partyName The party name to check
* @return true if this is a valid party, false otherwise
*/
public boolean isParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return true;
}
}
return false;
}
/**
* Load party file.
*/
private void loadParties() {
File file = new File(partiesFilePath);
if (!file.exists()) {
return;
}
YamlConfiguration partiesFile = new YamlConfiguration();
try {
partiesFile.load(file);
} catch (Exception e) {
e.printStackTrace();
}
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
Party party = new Party();
party.setName(partyName);
party.setLeader(partiesFile.getString(partyName + ".Leader"));
party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.getMembers().addAll(partiesFile.getStringList(partyName + ".Members"));
parties.add(party);
}
}
/**
* Save party file.
*/
public void saveParties() {
File file = new File(partiesFilePath);
if (file.exists()) {
file.delete();
}
YamlConfiguration partiesFile = new YamlConfiguration();
for (Party party : parties) {
String partyName = party.getName();
partiesFile.set(partyName + ".Leader", party.getLeader());
partiesFile.set(partyName + ".Password", party.getPassword());
partiesFile.set(partyName + ".Locked", party.isLocked());
partiesFile.set(partyName + ".Members", party.getMembers());
try {
partiesFile.save(new File(partiesFilePath));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@@ -84,7 +84,7 @@ public class BleedTimer implements Runnable {
/**
* Instantly Bleed out a LivingEntity
*
*
* @param entity LivingEntity to bleed out
*/
public static void bleedOut(LivingEntity entity) {
@@ -96,7 +96,7 @@ public class BleedTimer implements Runnable {
/**
* Remove a LivingEntity from the bleedList if it is in it
*
*
* @param entity LivingEntity to remove
*/
public static void remove(LivingEntity entity) {
@@ -168,7 +168,7 @@ public class BleedTimer implements Runnable {
/**
* Check to see if a LivingEntity is in the bleedList
*
*
* @param entity LivingEntity to check if in the bleedList
* @return true if in the list, false if not
*/

View File

@@ -27,7 +27,7 @@ public class GainXp implements Runnable {
@Override
public void run() {
int health = target.getHealth();
int damage = baseHealth - health;
int damage = baseHealth - health;
//May avoid negative xp, we don't know what other plugins do with the entity health
if (damage <= 0) {
@@ -39,7 +39,6 @@ public class GainXp implements Runnable {
damage += health;
}
PP.addXP(player, skillType, (int) (damage * baseXp));
Skills.XpCheckSkill(skillType, player);
Skills.xpProcessing(player, PP, skillType, (int) (damage * baseXp));
}
}

View File

@@ -1,20 +1,21 @@
package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.util.Users;
public class ProfileSaveTask implements Runnable {
Player player = null;
private PlayerProfile playerProfile;
public ProfileSaveTask(Player player) {
this.player = player;
public ProfileSaveTask(PlayerProfile playerProfile) {
this.playerProfile = playerProfile;
}
@Override
public void run() {
if (player != null) {
Users.getProfileByName(player.getName()).save();
playerProfile.save();
if (!playerProfile.getPlayer().isOnline()) {
Users.getProfiles().remove(playerProfile);
}
}
}

View File

@@ -1,20 +0,0 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.util.Users;
public class RemoveProfileFromMemoryTask implements Runnable {
private String playerName = null;
public RemoveProfileFromMemoryTask(String playerName) {
this.playerName = playerName;
}
@Override
public void run() {
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
if (Users.players.containsKey(playerName.toLowerCase())) {
Users.getProfileByName(playerName.toLowerCase()).save(); //We save here so players don't quit/reconnect to cause lag
Users.removeUserByName(playerName.toLowerCase());
}
}
}

View File

@@ -17,7 +17,7 @@ public class SQLConversionTask implements Runnable {
@Override
public void run() {
String location = plugin.usersFile;
String location = mcMMO.usersFile;
try {
FileReader file = new FileReader(location);

View File

@@ -19,13 +19,13 @@ public class SQLReconnect implements Runnable {
if (!Database.isConnected()) {
Database.connect();
if (Database.isConnected()) {
for (PlayerProfile x : Users.players.values()) {
x.save(); //Save all profiles
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
playerProfile.save(); //Save all profiles
}
Users.players.clear(); //Clear the profiles
for (Player x : plugin.getServer().getOnlinePlayers()) {
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
Users.clearUsers(); //Clear the profiles
for (Player player : plugin.getServer().getOnlinePlayers()) {
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
}
}
}

View File

@@ -1,8 +1,11 @@
package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class SaveTimer implements Runnable {
private final mcMMO plugin;
@@ -15,10 +18,13 @@ public class SaveTimer implements Runnable {
public void run() {
//All player data will be saved periodically through this
int count = 1;
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
for (Player player : plugin.getServer().getOnlinePlayers()) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new ProfileSaveTask(player), count);
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(playerProfile), count);
count++;
}
PartyManager.getInstance().saveParties();
}
}

View File

@@ -4,7 +4,7 @@ import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.spout.SpoutStuff;
public class SpoutStart implements Runnable{
@@ -17,14 +17,15 @@ public class SpoutStart implements Runnable{
@Override
public void run() {
if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) {
Config.getInstance().spoutEnabled = true;
mcMMO.spoutEnabled = true;
}
else {
Config.getInstance().spoutEnabled = false;
mcMMO.spoutEnabled = false;
}
//Spout Stuff
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutConfig.getInstance();
SpoutStuff.setupSpoutConfigs();
SpoutStuff.registerCustomEvent();
SpoutStuff.extractFiles(); //Extract source materials

View File

@@ -0,0 +1,18 @@
package com.gmail.nossr50.skills.acrobatics;
import java.util.Random;
public class Acrobatics {
public static final int DODGE_MAX_BONUS_LEVEL = 800;
public static final int DODGE_XP_MODIFIER = 120;
public static final int FALL_XP_MODIFIER = 120;
public static final int ROLL_MAX_BONUS_LEVEL = 1000;
public static final int ROLL_XP_MODIFIER = 80;
private static Random random = new Random();
public static Random getRandom() {
return random;
}
}

View File

@@ -0,0 +1,61 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
public abstract class AcrobaticsEventHandler {
protected AcrobaticsManager manager;
protected Player player;
protected EntityDamageEvent event;
protected int damage;
protected int skillModifier;
protected int modifiedDamage;
protected AcrobaticsEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
this.event = event;
this.damage = event.getDamage();
}
/**
* Calculate the skill modifier applied for this event.
*/
protected abstract void calculateSkillModifier();
/**
* Calculate the modified damage for this event.
*/
protected abstract void calculateModifiedDamage();
/**
* Modify the damage dealt by this event.
*/
protected abstract void modifyEventDamage();
/**
* Send the ability message for this event.
*/
protected abstract void sendAbilityMessage();
/**
* Process XP gain from this event.
*/
protected abstract void processXPGain(int xp);
/**
* Check to ensure you're not gaining XP after you die.
*
* @param damage The damage to be dealt
* @return true if the damage is fatal, false otherwise
*/
protected boolean isFatal(int damage) {
if (player.getHealth() - damage < 1) {
return true;
}
else {
return false;
}
}
}

View File

@@ -0,0 +1,75 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AcrobaticsManager {
private Player player;
private PlayerProfile profile;
private int skillLevel;
private Permissions permissionInstance = Permissions.getInstance();
public AcrobaticsManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
this.skillLevel = profile.getSkillLevel(SkillType.ACROBATICS);
}
/**
* Check for fall damage reduction.
*
* @param event The event to check
*/
public void rollCheck(EntityDamageEvent event) {
if (!permissionInstance.roll(player)) {
return;
}
RollEventHandler eventHandler = new RollEventHandler(this, event);
if (Acrobatics.getRandom().nextInt(1000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
}
else if (!eventHandler.isFatal(event.getDamage())) {
eventHandler.processXPGain(eventHandler.damage * Acrobatics.FALL_XP_MODIFIER);
}
}
/**
* Check for dodge damage reduction.
*
* @param event The event to check
*/
public void dodgeCheck(EntityDamageEvent event) {
if (!permissionInstance.dodge(player)) {
return;
}
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
}
}
protected Player getPlayer() {
return player;
}
protected PlayerProfile getProfile() {
return profile;
}
protected int getSkillLevel() {
return skillLevel;
}
}

View File

@@ -0,0 +1,48 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.event.entity.EntityDamageEvent;
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.Skills;
public class DodgeEventHandler extends AcrobaticsEventHandler {
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
super(manager, event);
calculateSkillModifier();
calculateModifiedDamage();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
}
protected void calculateModifiedDamage() {
int modifiedDamage = damage / 2;
if (modifiedDamage <= 0) {
modifiedDamage = 1;
}
this.modifiedDamage = modifiedDamage;
}
protected void modifyEventDamage() {
event.setDamage(modifiedDamage);
}
protected void sendAbilityMessage() {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
protected void processXPGain(int xp) {
PlayerProfile profile = manager.getProfile();
if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) {
Skills.xpProcessing(player, profile, SkillType.ACROBATICS, xp);
}
}
}

View File

@@ -0,0 +1,92 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
public class RollEventHandler extends AcrobaticsEventHandler {
private boolean isGraceful;
private int damageThreshold;
protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
super(manager, event);
isGracefulRoll();
calculateSkillModifier();
calculateDamageThreshold();
calculateModifiedDamage();
}
protected void calculateSkillModifier() {
int skillModifer = manager.getSkillLevel();
if (isGraceful) {
skillModifer = skillModifer * 2;
}
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.ROLL_MAX_BONUS_LEVEL);
this.skillModifier = skillModifer;
}
protected void calculateModifiedDamage() {
int modifiedDamage = damage - damageThreshold;
if (modifiedDamage < 0) {
modifiedDamage = 0;
}
this.modifiedDamage = modifiedDamage;
}
protected void modifyEventDamage() {
event.setDamage(modifiedDamage);
if (event.getDamage() == 0) {
event.setCancelled(true);
}
}
protected void sendAbilityMessage() {
if (isGraceful) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
}
}
protected void processXPGain(int xpGain) {
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
}
/**
* Check if this is a graceful roll.
*/
private void isGracefulRoll() {
if (Permissions.getInstance().gracefulRoll(player)) {
this.isGraceful = player.isSneaking();
}
else {
this.isGraceful = false;
}
}
/**
* Calculate the damage threshold for this event.
*/
private void calculateDamageThreshold() {
int damageThreshold = 7;
if (isGraceful) {
damageThreshold = damageThreshold * 2;
}
this.damageThreshold = damageThreshold;
}
}

View File

@@ -0,0 +1,70 @@
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.util.Misc;
public class Archery {
private static Random random = new Random();
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = 1000;
public static final int BONUS_DAMAGE_INCREASE_LEVEL = 50;
public static final double BONUS_DAMAGE_INCREASE_PERCENT = 0.1D;
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = 2.0D;
public static final int DAZE_MAX_BONUS_LEVEL = 1000;
public static final int DAZE_MODIFIER = 4;
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity() == livingEntity) {
trackedEntity.incrementArrowCount();
return;
}
}
//If the entity isn't tracked yet
addToTracker(livingEntity);
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
trackedEntity.incrementArrowCount();
trackedEntities.add(trackedEntity);
}
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}
/**
* Check for arrow retrieval.
*
* @param entity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> it = trackedEntities.iterator() ; it.hasNext() ; ) {
TrackedEntity trackedEntity = it.next();
if (trackedEntity.getLivingEntity() == livingEntity) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
it.remove();
return;
}
}
}
protected static Random getRandom() {
return random;
}
}

View File

@@ -0,0 +1,32 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.event.entity.EntityDamageEvent;
public class ArcheryBonusDamageEventHandler {
private ArcheryManager manager;
private EntityDamageEvent event;
protected double damageBonusPercent;
protected ArcheryBonusDamageEventHandler(ArcheryManager manager, EntityDamageEvent event) {
this.manager = manager;
this.event = event;
}
protected void calculateDamageBonus() {
double damageBonus = ((manager.getSkillLevel() / Archery.BONUS_DAMAGE_INCREASE_LEVEL) * Archery.BONUS_DAMAGE_INCREASE_PERCENT);
if (damageBonus > Archery.BONUS_DAMAGE_MAX_BONUS_PERCENTAGE) {
damageBonus = Archery.BONUS_DAMAGE_MAX_BONUS_PERCENTAGE;
}
this.damageBonusPercent = damageBonus;
}
protected void modifyEventDamage() {
int damage = event.getDamage();
int archeryBonus = (int) (damage * damageBonusPercent);
event.setDamage(damage + archeryBonus);
}
}

View File

@@ -0,0 +1,86 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ArcheryManager {
private Player player;
private PlayerProfile profile;
private int skillLevel;
private Permissions permissionsInstance;
public ArcheryManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
this.permissionsInstance = Permissions.getInstance();
}
/**
* Track arrows fired for later retrieval.
*
* @param livingEntity Entity damaged by the arrow
*/
public void trackArrows(LivingEntity livingEntity) {
if (!permissionsInstance.trackArrows(player)) {
return;
}
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
if (Archery.getRandom().nextInt(1000) < eventHandler.skillModifier) {
eventHandler.addToTracker();
}
}
/**
* Check for Daze.
*
* @param defender Defending player
* @param event The event to modify
*/
public void dazeCheck(Player defender, EntityDamageEvent event) {
if (!permissionsInstance.daze(player)) {
return;
}
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
if (Archery.getRandom().nextInt(2000) < eventHandler.skillModifier) {
eventHandler.handleDazeEffect();
eventHandler.sendAbilityMessages();
}
}
/**
* Handle archery bonus damage.
*
* @param event The event to modify.
*/
public void bonusDamage(EntityDamageEvent event) {
if (!permissionsInstance.archeryBonus(player)) {
return;
}
if (skillLevel >= Archery.BONUS_DAMAGE_INCREASE_LEVEL) {
ArcheryBonusDamageEventHandler eventHandler = new ArcheryBonusDamageEventHandler(this, event);
eventHandler.calculateDamageBonus();
eventHandler.modifyEventDamage();
}
}
protected int getSkillLevel() {
return skillLevel;
}
protected Player getPlayer() {
return player;
}
}

View File

@@ -0,0 +1,27 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.util.Misc;
public class ArrowTrackingEventHandler {
private ArcheryManager manager;
private LivingEntity entity;
protected int skillModifier;
protected ArrowTrackingEventHandler (ArcheryManager manager, LivingEntity entity) {
this.manager = manager;
this.entity = entity;
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.ARROW_TRACKING_MAX_BONUS_LEVEL);
}
protected void addToTracker() {
Archery.incrementTrackerValue(entity);
}
}

View File

@@ -0,0 +1,47 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
public class DazeEventHandler {
private ArcheryManager manager;
private EntityDamageEvent event;
private Player defender;
protected int skillModifier;
protected DazeEventHandler (ArcheryManager manager, EntityDamageEvent event, Player defender) {
this.manager = manager;
this.event = event;
this.defender = defender;
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.DAZE_MAX_BONUS_LEVEL);
}
protected void handleDazeEffect() {
Location location = defender.getLocation();
if (Archery.getRandom().nextInt(10) > 5) {
location.setPitch(90);
}
else {
location.setPitch(-90);
}
defender.teleport(location);
event.setDamage(event.getDamage() + Archery.DAZE_MODIFIER);
}
protected void sendAbilityMessages() {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
manager.getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
}

View File

@@ -0,0 +1,63 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.mcMMO;
public class TrackedEntity {
private LivingEntity livingEntity;
private int arrowCount;
private int previousTicksLived;
public TrackedEntity(LivingEntity livingEntity) {
this.livingEntity = livingEntity;
new CheckTrackedEntityExistence(this);
}
//LivingEntity.isDead() isn't a reliable way to know if an entity is still active
//This method must not be called more than once per server tick
public boolean isActive() {
int currentTicksLived = livingEntity.getTicksLived();
if (currentTicksLived == previousTicksLived) {
return false;
}
else {
previousTicksLived = currentTicksLived;
return true;
}
}
public LivingEntity getLivingEntity() {
return livingEntity;
}
public int getArrowCount() {
return arrowCount;
}
public void incrementArrowCount() {
arrowCount++;
}
private class CheckTrackedEntityExistence implements Runnable {
private TrackedEntity trackedEntity;
private int taskId;
public CheckTrackedEntityExistence(TrackedEntity trackedEntity) {
this.trackedEntity = trackedEntity;
//Check if the entity is still active every 10 minutes
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
}
@Override
public void run() {
if (!trackedEntity.isActive()) {
Archery.removeFromTracker(trackedEntity);
Bukkit.getScheduler().cancelTask(taskId);
}
}
}
}

View File

@@ -1,95 +0,0 @@
package com.gmail.nossr50.skills.combat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class Archery {
private static Random random = new Random();
public static Map<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
/**
* Track arrows fired for later retrieval.
*
* @param entity Entity damaged by the arrow
* @param PPa PlayerProfile of the player firing the arrow
*/
public static void trackArrows(Entity entity, PlayerProfile PPa) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck) {
for (Entry<Entity, Integer> entry : arrowTracker.entrySet()) {
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
entry.setValue(entry.getValue() + 1);
return;
}
}
arrowTracker.put(entity, 1);
}
}
/**
* Check for Daze.
*
* @param defender Defending player
* @param attacker Attacking player
* @param event The event to modify
*/
public static void dazeCheck(Player defender, Player attacker, EntityDamageByEntityEvent event) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
Location location = defender.getLocation();
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(10) > 5) {
location.setPitch(90);
}
else {
location.setPitch(-90);
}
if (random.nextInt(2000) <= skillCheck) {
defender.teleport(location);
event.setDamage(event.getDamage() + 4);
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
}
/**
* Check for arrow retrieval.
*
* @param entity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(Entity entity) {
for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
Entry<Entity, Integer> entry = it.next();
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
it.remove();
return;
}
}
}
}

View File

@@ -14,7 +14,7 @@ import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
@@ -60,7 +60,7 @@ public class Axes {
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner == attacker || Party.getInstance().inSameParty(attacker, owner)) {
if (owner == attacker || PartyManager.getInstance().inSameParty(attacker, owner)) {
return;
}
}

View File

@@ -1,101 +0,0 @@
package com.gmail.nossr50.skills.combat;
import java.util.Random;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.BleedTimer;
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.Users;
public class Swords {
private static Random random = new Random();
/**
* Check for Bleed effect.
*
* @param attacker The attacking player
* @param defender The defending entity
*/
public static void bleedCheck(Player attacker, LivingEntity defender) {
if (defender instanceof Tameable) {
Tameable pet = (Tameable) defender;
if (pet.isTamed()) {
AnimalTamer tamer = pet.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner == attacker || Party.getInstance().inSameParty(attacker, owner)) {
return;
}
}
}
}
final int MAX_BONUS_LEVEL = 750;
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck && !defender.isDead()) {
int bleedTicks = 0;
if (skillLevel >= 750) {
bleedTicks = 3;
}
else {
bleedTicks = 2;
}
BleedTimer.add(defender, bleedTicks);
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
}
/**
* Counter-attack entities.
*
* @param attacker The attacking entity
* @param defender The defending player
* @param damage The amount of damage being countered
*/
public static void counterAttackChecks(Entity attacker, Player defender, int damage) {
if (!(attacker instanceof LivingEntity)) {
return;
}
PlayerProfile PPd = Users.getProfile(defender);
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
final int MAX_BONUS_LEVEL = 600;
final int COUNTER_ATTACK_MODIFIER = 2;
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck) {
Combat.dealDamage((LivingEntity) attacker, damage / COUNTER_ATTACK_MODIFIER);
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}
}
}

View File

@@ -1,287 +0,0 @@
package com.gmail.nossr50.skills.combat;
import java.util.Random;
import org.bukkit.ChatColor;
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.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
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.locale.LocaleLoader;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Taming {
private static Random random = new Random();
/**
* Apply the Fast Food Service ability.
*
* @param PPo The PlayerProfile of the wolf's owner
* @param theWolf The wolf using the ability
* @param damage The damage being absorbed by the wolf
*/
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) {
final int SKILL_ACTIVATION_LEVEL = 50;
final int ACTIVATION_CHANCE = 50;
int health = theWolf.getHealth();
int maxHealth = theWolf.getMaxHealth();
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
if (health < maxHealth) {
if (random.nextInt(100) < ACTIVATION_CHANCE) {
if (health + damage <= maxHealth) {
theWolf.setHealth(health + damage);
}
else {
theWolf.setHealth(maxHealth);
}
}
}
}
}
/**
* Apply the Sharpened Claws ability.
*
* @param PPo The PlayerProfile of the wolf's owner
* @param event The event to modify
*/
public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event) {
final int SKILL_ACTIVATION_LEVEL = 750;
final int SHARPENED_CLAWS_BONUS = 2;
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
event.setDamage(event.getDamage() + SHARPENED_CLAWS_BONUS);
}
}
/**
* Apply the Gore ability.
*
* @param PPo The PlayerProfile of the wolf's owner
* @param event The event to modify
* @param master The wolf's master
*/
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master) {
final int GORE_MULTIPLIER = 2;
if (random.nextInt(1000) <= PPo.getSkillLevel(SkillType.TAMING)) {
Entity entity = event.getEntity();
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
}
BleedTimer.add((LivingEntity) entity, 2);
master.sendMessage(LocaleLoader.getString("Combat.Gore"));
}
}
/**
* Get the name of a tameable animal's owner.
*
* @param beast The animal whose owner's name to get
* @return the name of the animal's owner, or "Offline Master" if the owner is offline
*/
private static String getOwnerName(Tameable beast) {
AnimalTamer tamer = beast.getOwner();
if (tamer instanceof Player) {
return ((Player) tamer).getName();
}
else {
return "Offline Master";
}
}
/**
* Prevent damage to wolves based on various skills.
*
* @param event The event to modify
*/
public static void preventDamage(EntityDamageEvent event) {
final int ENVIRONMENTALLY_AWARE_LEVEL = 100;
final int THICK_FUR_LEVEL = 250;
final int SHOCK_PROOF_LEVEL = 500;
final int THICK_FUR_MODIFIER = 2;
final int SHOCK_PROOF_MODIFIER = 6;
if (!(event.getEntity() instanceof Wolf)) {
return;
}
DamageCause cause = event.getCause();
Wolf wolf = (Wolf) event.getEntity();
Player master = (Player) wolf.getOwner();
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
switch (cause) {
/* Environmentally Aware */
case CONTACT:
case LAVA:
case FIRE:
if (Permissions.getInstance().environmentallyAware(master)) {
if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
if (event.getDamage() >= wolf.getHealth()) {
return;
}
wolf.teleport(master.getLocation());
master.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
}
}
break;
case FALL:
if (Permissions.getInstance().environmentallyAware(master)) {
if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
event.setCancelled(true);
}
}
break;
/* Thick Fur */
case FIRE_TICK:
if (Permissions.getInstance().thickFur(master)) {
if(skillLevel >= THICK_FUR_LEVEL) {
wolf.setFireTicks(0);
}
}
break;
case ENTITY_ATTACK:
case PROJECTILE:
if (Permissions.getInstance().thickFur(master)) {
if (skillLevel >= THICK_FUR_LEVEL) {
event.setDamage(event.getDamage() / THICK_FUR_MODIFIER);
}
}
break;
/* Shock Proof */
case ENTITY_EXPLOSION:
case BLOCK_EXPLOSION:
if (Permissions.getInstance().shockProof(master)) {
if (skillLevel >= SHOCK_PROOF_LEVEL) {
event.setDamage(event.getDamage() / SHOCK_PROOF_MODIFIER);
}
}
break;
default:
break;
}
}
/**
* Summon an animal.
*
* @param type Type of animal to summon
* @param player Player summoning the animal
*/
public static void animalSummon(EntityType type, Player player, mcMMO plugin) {
ItemStack item = player.getItemInHand();
Material summonItem = null;
int summonAmount = 0;
switch (type) {
case WOLF:
summonItem = Material.BONE;
summonAmount = Config.getInstance().getTamingCOTWWolfCost();
break;
case OCELOT:
summonItem = Material.RAW_FISH;
summonAmount = Config.getInstance().getTamingCOTWOcelotCost();
break;
default:
break;
}
if (item.getType().equals(summonItem)) {
if (item.getAmount() >= summonAmount) {
for (Entity x : player.getNearbyEntities(40, 40, 40)) {
if (x.getType().equals(type)) {
switch (type) {
case WOLF:
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf"));
return;
case OCELOT:
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
return;
default:
return;
}
}
}
LivingEntity entity = player.getWorld().spawnCreature(player.getLocation(), type);
entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(plugin, true));
((Tameable) entity).setOwner(player);
if (entity.getType().equals(EntityType.OCELOT)) {
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + random.nextInt(3)));
}
if (entity.getType().equals(EntityType.WOLF)) {
entity.setHealth(entity.getMaxHealth());
}
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(summonItem.getId()));
}
}
}
/**
* Inspect a tameable animal for details.
*
* @param event Event to modify
* @param target Animal to inspect
* @param inspector Player inspecting the animal
*/
public static void beastLore(EntityDamageByEntityEvent event, LivingEntity target, Player inspector) {
if (target instanceof Tameable) {
Tameable beast = (Tameable) target;
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
int health = target.getHealth();
event.setCancelled(true);
if (beast.isTamed()) {
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", new Object[] {getOwnerName(beast)}) + " ");
}
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", new Object[] {health, target.getMaxHealth()}));
inspector.sendMessage(message);
}
}
}

View File

@@ -1,106 +0,0 @@
package com.gmail.nossr50.skills.combat;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Unarmed {
private static Random random = new Random();
/**
* Apply bonus to Unarmed damage.
*
* @param PPa Profile of the attacking player
* @param event The event to modify
*/
public static void unarmedBonus(PlayerProfile PPa, EntityDamageByEntityEvent event) {
final int MAX_BONUS = 8;
int bonus = 3;
bonus += PPa.getSkillLevel(SkillType.UNARMED) / 50; //Add 1 DMG for every 50 skill levels
if (bonus > MAX_BONUS) {
bonus = MAX_BONUS;
}
event.setDamage(event.getDamage() + bonus);
}
/**
* Check for disarm.
*
* @param PPa Profile of the attacking player
* @param defender The defending player
*/
public static void disarmProcCheck(Player attacker, Player defender) {
final int MAX_BONUS_LEVEL = 1000;
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.UNARMED);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
ItemStack inHand = defender.getItemInHand();
if (!inHand.getType().equals(Material.AIR)) {
if (random.nextInt(3000) <= skillCheck && !ironGrip(defender, attacker)) {
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
Misc.dropItem(defender.getLocation(), inHand);
defender.setItemInHand(new ItemStack(Material.AIR));
}
}
}
/**
* Check for arrow deflection.
*
* @param defender The defending player
* @param event The event to modify
*/
public static void deflectCheck(Player defender, EntityDamageByEntityEvent event) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(defender).getSkillLevel(SkillType.UNARMED);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().deflect(defender)) {
event.setCancelled(true);
defender.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
}
}
/**
* Check Iron Grip ability success
*
* @param defender The defending player
* @param attacker The attacking player
* @return true if the defender was not disarmed, false otherwise
*/
private static boolean ironGrip(Player defender, Player attacker) {
final int MAX_BONUS_LEVEL = 1000;
PlayerProfile PPd = Users.getProfile(defender);
int skillLevel = PPd.getSkillLevel(SkillType.UNARMED);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck) {
defender.sendMessage(ChatColor.GREEN + "Your iron grip kept you from being disarmed!"); //TODO: Use locale
attacker.sendMessage(ChatColor.RED + "Your opponent has an iron grip!"); //TODO: Use locale
return true;
}
else {
return false;
}
}
}

View File

@@ -9,6 +9,7 @@ import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageEvent;
@@ -279,7 +280,7 @@ public class BlastMining {
AbilityType ability = AbilityType.BLAST_MINING;
/* Check Cooldown */
if(!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
if (!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
@@ -295,8 +296,9 @@ public class BlastMining {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
/* Create the TNT entity */
// TNTPrimed tnt = (TNTPrimed) player.getWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT);
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
plugin.tntTracker.put(tnt.getEntityId(), player);
plugin.addToTNTTracker(tnt.getEntityId(), player.getName());
tnt.setFuseTicks(0);
/* Disable the original one */

View File

@@ -9,13 +9,8 @@ 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 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.TreasuresConfig;
@@ -24,8 +19,12 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.getspout.spoutapi.sound.SoundEffect;
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;
public class Excavation {
@@ -107,9 +106,7 @@ public class Excavation {
}
}
//Handle XP related tasks
PP.addXP(player, SkillType.EXCAVATION, xp);
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
Skills.xpProcessing(player, PP, SkillType.EXCAVATION, xp);
}
/**
@@ -129,7 +126,7 @@ public class Excavation {
Excavation.excavationProcCheck(block, player);
}
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}

View File

@@ -103,7 +103,7 @@ public class Fishing {
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(player, SkillType.FISHING, treasure.getXp());
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
theCatch.setItemStack(treasure.getDrop());
}
}
@@ -117,8 +117,7 @@ public class Fishing {
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
}
PP.addXP(player, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
Skills.XpCheckSkill(SkillType.FISHING, player);
Skills.xpProcessing(player, PP, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
}
/**
@@ -277,7 +276,7 @@ public class Fishing {
case SHEEP:
Sheep sheep = (Sheep) le;
if (!sheep.isSheared()) {
Wool wool = new Wool();
wool.setColor(sheep.getColor());

View File

@@ -48,10 +48,10 @@ public class Herbalism {
greenTerraConvert(player, block);
}
}
public static void greenTerraConvert(Player player, Block block) {
Material type = block.getType();
if (Misc.blockBreakSimulate(block, player, false)) {
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
@@ -288,8 +288,7 @@ public class Herbalism {
}
}
PP.addXP(player, SkillType.HERBALISM, xp);
Skills.XpCheckSkill(SkillType.HERBALISM, player);
Skills.xpProcessing(player, PP, SkillType.HERBALISM, xp);
}
/**

View File

@@ -12,16 +12,16 @@ import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.sound.SoundEffect;
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.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
public class Mining {
private static Random random = new Random();
@@ -213,7 +213,7 @@ public class Mining {
PlayerProfile PP = Users.getProfile(player);
Material type = block.getType();
int xp = 0;
switch (type) {
case COAL_ORE:
xp += Config.getInstance().getMiningXPCoalOre();
@@ -275,8 +275,7 @@ public class Mining {
break;
}
PP.addXP(player, SkillType.MINING, xp);
Skills.XpCheckSkill(SkillType.MINING, player);
Skills.xpProcessing(player, PP, SkillType.MINING, xp);
}
/**
@@ -332,7 +331,7 @@ public class Mining {
miningBlockCheck(player, block);
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
@@ -377,7 +376,7 @@ public class Mining {
miningBlockCheck(player, block);
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}

View File

@@ -8,9 +8,10 @@ import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import org.bukkit.event.block.BlockBreakEvent;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@@ -28,8 +29,6 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
import org.getspout.spoutapi.sound.SoundEffect;
public class WoodCutting {
private static Random random = new Random();
@@ -67,11 +66,20 @@ public class WoodCutting {
int xp = 0;
ItemStack inHand = player.getItemInHand();
/* Damage the tool */
inHand.setDurability((short) (inHand.getDurability() + durabilityLoss));
/* This is to prevent using wood axes everytime you tree fell */
if ((inHand.getDurability() + durabilityLoss >= inHand.getType().getMaxDurability()) || inHand.getType().equals(Material.AIR)) {
if (ModChecks.isCustomTool(inHand)) {
if (inHand.getDurability() + durabilityLoss >= ModChecks.getToolFromItemStack(inHand).getDurability()) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
int health = player.getHealth();
if (health >= 2) {
Combat.dealDamage(player, random.nextInt(health - 1));
}
return;
}
}
else if ((inHand.getDurability() + durabilityLoss >= inHand.getType().getMaxDurability()) || inHand.getType().equals(Material.AIR)) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
int health = player.getHealth();
@@ -82,20 +90,23 @@ public class WoodCutting {
return;
}
/* Damage the tool */
inHand.setDurability((short) (inHand.getDurability() + durabilityLoss));
//Prepare ItemStacks
ItemStack item = null;
ItemStack oak = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.GENERIC.getData());
ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.REDWOOD.getData());
ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.BIRCH.getData());
ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData());
for (Block x : toBeFelled) {
if (Misc.blockBreakSimulate(x, player, true)) {
if (Config.getInstance().getBlockModsEnabled()) {
CustomBlock block = ModChecks.getCustomBlock(x);
item = block.getItemDrop();
if (ModChecks.isCustomLogBlock(x)) {
CustomBlock block = ModChecks.getCustomBlock(x);
item = block.getItemDrop();
if (!mcMMO.placeStore.isTrue(x)) {
WoodCutting.woodCuttingProcCheck(player, x);
xp = block.getXpGain();
@@ -108,6 +119,9 @@ public class WoodCutting {
Misc.dropItem(x.getLocation(), item);
}
else if (ModChecks.isCustomLeafBlock(x)) {
CustomBlock block = ModChecks.getCustomBlock(x);
item = block.getItemDrop();
final int SAPLING_DROP_CHANCE = 10;
/* Remove the block */
@@ -188,8 +202,7 @@ public class WoodCutting {
}
if (Permissions.getInstance().woodcutting(player)) {
PP.addXP(player, SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
Skills.xpProcessing(player, PP, SkillType.WOODCUTTING, xp);
}
}
@@ -201,7 +214,7 @@ public class WoodCutting {
*/
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) {
Material type = currentBlock.getType();
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
return;
}
@@ -369,8 +382,7 @@ public class WoodCutting {
}
WoodCutting.woodCuttingProcCheck(player, block);
PP.addXP(player, SkillType.WOODCUTTING, xp);
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
Skills.xpProcessing(player, PP, SkillType.WOODCUTTING, xp);
}
/**
@@ -387,7 +399,7 @@ public class WoodCutting {
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
}
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}

View File

@@ -1,129 +0,0 @@
package com.gmail.nossr50.skills.misc;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
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.Skills;
import com.gmail.nossr50.util.Users;
public class Acrobatics {
private static Random random = new Random();
/**
* Check for fall damage reduction.
*
* @param player The player whose fall damage to modify
* @param event The event to check
*/
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
final int ROLL_XP_MODIFIER = 80;
final int FALL_XP_MODIFIER = 120;
final int MAX_BONUS_LEVEL = 1000;
PlayerProfile PP = Users.getProfile(player);
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
boolean gracefulRoll = player.isSneaking();
int damage = event.getDamage();
int health = player.getHealth();
if (!Permissions.getInstance().gracefulRoll(player)) {
gracefulRoll = false;
}
if (gracefulRoll) {
acrovar = acrovar * 2;
}
if ((acrovar > MAX_BONUS_LEVEL || random.nextInt(1000) <= acrovar) && Permissions.getInstance().roll(player)) {
int threshold = 7;
if (gracefulRoll) {
threshold = threshold * 2;
}
int newDamage = damage - threshold;
if (newDamage < 0) {
newDamage = 0;
}
/* Check for death */
if (health - damage >= 1) {
PP.addXP(player, SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
event.setDamage(newDamage);
if (event.getDamage() <= 0) {
event.setCancelled(true);
}
if (gracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
}
}
}
else if (health - damage >= 1) {
PP.addXP(player, SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
}
}
/**
* Check for dodge damage reduction.
*
* @param event The event to check
*/
public static void dodgeChecks(EntityDamageByEntityEvent event) {
final int DODGE_MODIFIER = 120;
final int MAX_BONUS_LEVEL = 800;
Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
int damage = event.getDamage();
/* PARTY CHECK */
if (event.getDamager() instanceof Player) {
Player attacker = (Player) event.getDamager();
if (Party.getInstance().inSameParty(defender, attacker)) {
return;
}
}
if (Permissions.getInstance().acrobatics(defender)) {
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(4000) <= skillCheck && Permissions.getInstance().dodge(defender)) {
defender.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
PPd.addXP(defender, SkillType.ACROBATICS, damage * DODGE_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
int newDamage = damage / 2;
if (newDamage <= 0) {
event.setDamage(1);
}
else {
event.setDamage(newDamage);
}
}
}
}
}

View File

@@ -1,8 +1,8 @@
package com.gmail.nossr50.skills.repair;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@@ -13,13 +13,13 @@ import org.getspout.spoutapi.player.SpoutPlayer;
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.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
public class Repair {
@@ -42,11 +42,10 @@ public class Repair {
dif = (short) (dif * modify);
PP.addXP(player, SkillType.REPAIR, dif * 10);
Skills.XpCheckSkill(SkillType.REPAIR, player);
Skills.xpProcessing(player, PP, SkillType.REPAIR, dif * 10);
//CLANG CLANG
if (configInstance.spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playRepairNoise(player, mcMMO.p);
}
}
@@ -242,7 +241,7 @@ public class Repair {
PlayerProfile PP = Users.getProfile(player);
if (!PP.getPlacedAnvil()) {
if (configInstance.spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) {

View File

@@ -19,10 +19,13 @@ public enum RepairItemType {
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

@@ -24,20 +24,28 @@ public enum RepairMaterialType {
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

@@ -37,7 +37,7 @@ public class SimpleRepairManager implements RepairManager {
@Override
public void registerRepairables(List<Repairable> repairables) {
for(Repairable repairable : repairables) {
for (Repairable repairable : repairables) {
registerRepairable(repairable);
}
}
@@ -67,28 +67,28 @@ public class SimpleRepairManager implements RepairManager {
Repairable repairable = repairables.get(item.getTypeId());
// Permissions checks on material and item types
if(!repairable.getRepairItemType().getPermissions(player)) {
if (!repairable.getRepairItemType().getPermissions(player)) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return;
}
if(!repairable.getRepairMaterialType().getPermissions(player)) {
if (!repairable.getRepairMaterialType().getPermissions(player)) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return;
}
// Level check
if(skillLevel < repairable.getMinimumLevel()) {
if (skillLevel < repairable.getMinimumLevel()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", new Object[] { String.valueOf(repairable.getMinimumLevel()), Misc.prettyItemString(item.getTypeId()) } ));
return;
}
// Check if they have the proper material to repair with
if(!inventory.contains(repairable.getRepairMaterialId())) {
if (!inventory.contains(repairable.getRepairMaterialId())) {
String message = LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(repairable.getRepairMaterialId());
if(repairable.getRepairMaterialMetadata() != (byte) -1) {
if (repairable.getRepairMaterialMetadata() != (byte) -1) {
// TODO: Do something nicer than append the metadata as a :# ?
if(findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) {
if (findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) {
message += ":" + repairable.getRepairMaterialMetadata();
}
}
@@ -97,33 +97,34 @@ public class SimpleRepairManager implements RepairManager {
}
// Do not repair if at full durability
if(startDurability <= 0) {
if (startDurability <= 0) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
return;
}
// Do not repair stacked items
if(item.getAmount() != 1) {
if (item.getAmount() != 1) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
return;
}
// Lets get down to business,
// To defeat, the huns.
int baseRepairAmount = repairable.getBaseRepairDurability();
short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount);
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount); // When I asked for sons?
// We're going to hold onto our repair item location
int repairItemLocation;
if(repairable.getRepairMaterialMetadata() == (byte) -1) {
if (repairable.getRepairMaterialMetadata() == (byte) -1) {
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId());
} else {
}
else {
// Special case for when the repairable has metadata that must be addressed
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata());
}
// This should never happen, but if it does we need to complain loudly about it.
if(repairItemLocation == -1) {
if (repairItemLocation == -1) {
player.sendMessage("mcMMO encountered an error attempting to repair this item!"); // TODO: Locale ?
return;
}
@@ -160,9 +161,10 @@ public class SimpleRepairManager implements RepairManager {
*/
private void removeOneFrom(PlayerInventory inventory, int index) {
ItemStack item = inventory.getItem(index);
if(item.getAmount() > 1) {
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
} else {
}
else {
item = new ItemStack(0);
}
@@ -179,10 +181,12 @@ public class SimpleRepairManager implements RepairManager {
*/
private int findInInventory(PlayerInventory inventory, int itemId) {
int location = inventory.first(itemId);
// VALIDATE
if(inventory.getItem(location).getTypeId() == itemId) {
if (inventory.getItem(location).getTypeId() == itemId) {
return location;
} else {
}
else {
return -1;
}
}
@@ -199,14 +203,22 @@ public class SimpleRepairManager implements RepairManager {
int location = -1;
ItemStack[] contents = inventory.getContents();
for(int i = 0; i < contents.length; i++) {
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
if(item.getTypeId() == itemId) {
if(item.getData().getData() == metadata) {
if (item == null) {
continue;
}
if (item.getTypeId() == itemId) {
if (item.getData().getData() == metadata) {
location = i;
}
}
if(location != -1) break;
if (location != -1) {
break;
}
}
return location;

View File

@@ -0,0 +1,49 @@
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.util.Misc;
public class BleedEventHandler {
private SwordsManager manager;
private int skillLevel;
private LivingEntity defender;
protected int skillModifier;
protected BleedEventHandler(SwordsManager manager, LivingEntity defender) {
this.manager = manager;
this.skillLevel = manager.getSkillLevel();
this.defender = defender;
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(skillLevel, Swords.BLEED_MAX_BONUS_LEVEL);
}
protected void addBleedTicks() {
int bleedTicks;
if (skillLevel >= Swords.BLEED_MAX_BONUS_LEVEL) {
bleedTicks = Swords.MAX_BLEED_TICKS;
}
else {
bleedTicks = Swords.BASE_BLEED_TICKS;
}
BleedTimer.add(defender, bleedTicks);
}
protected void sendAbilityMessages() {
manager.getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
if (defender instanceof Player) {
((Player) defender).sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
}
}
}

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
public class CounterAttackEventHandler {
private SwordsManager manager;
private Player player;
private LivingEntity attacker;
private int damage;
protected int skillModifier;
protected CounterAttackEventHandler(SwordsManager manager, LivingEntity attacker, int damage) {
this.manager = manager;
this.player = manager.getPlayer();
this.attacker = attacker;
this.damage = damage;
}
protected boolean isHoldingSword() {
return ItemChecks.isSword(player.getItemInHand());
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Swords.COUNTER_ATTACK_MAX_BONUS_LEVEL);
}
protected void dealDamage() {
Combat.dealDamage(attacker, damage / Swords.COUNTER_ATTACK_MODIFIER);
}
protected void sendAbilityMessages() {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}

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