mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 01:42:32 +01:00
Compare commits
129 Commits
pr/4925
...
tridentsxb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d38dcb26b | ||
|
|
256dbc14e2 | ||
|
|
f643010f4b | ||
|
|
70b1c23f50 | ||
|
|
29ee91ddfc | ||
|
|
bf1426502d | ||
|
|
d21368f3e6 | ||
|
|
34d4b6f944 | ||
|
|
05bc20a007 | ||
|
|
6e0750b5fc | ||
|
|
ed807342cc | ||
|
|
1de9c2610b | ||
|
|
788e7e433b | ||
|
|
ac4bad5194 | ||
|
|
b57458a08a | ||
|
|
062665ded4 | ||
|
|
9b856f456c | ||
|
|
d33c214266 | ||
|
|
3bda73de2e | ||
|
|
cc5fe92143 | ||
|
|
ef06546721 | ||
|
|
b20beed836 | ||
|
|
3d6b9ba539 | ||
|
|
1c63e34dbb | ||
|
|
86ba265064 | ||
|
|
f837be8e90 | ||
|
|
e958baf720 | ||
|
|
8e1b223288 | ||
|
|
a6276bded8 | ||
|
|
31904ef181 | ||
|
|
a379b90c46 | ||
|
|
7c270feacb | ||
|
|
2bad0a67a6 | ||
|
|
602d47698a | ||
|
|
d044de5350 | ||
|
|
85b88e568a | ||
|
|
fc10243d6f | ||
|
|
8a91791d2d | ||
|
|
4e8262d818 | ||
|
|
5b898049a3 | ||
|
|
6f88c282cf | ||
|
|
21ac44ee61 | ||
|
|
9b9ffbb982 | ||
|
|
537b120ffc | ||
|
|
25f7dd223d | ||
|
|
843e3ace99 | ||
|
|
8a507de8d6 | ||
|
|
7e756c4438 | ||
|
|
4199ea0095 | ||
|
|
73bc12841a | ||
|
|
35be5bc17d | ||
|
|
b7f713a50f | ||
|
|
573d9d014e | ||
|
|
abcf6413f5 | ||
|
|
9e931f880e | ||
|
|
306b8cfac4 | ||
|
|
407b6fb343 | ||
|
|
d8f8d541fc | ||
|
|
64e1d1a9d7 | ||
|
|
0e22583df4 | ||
|
|
1c132ddb12 | ||
|
|
81d184c19e | ||
|
|
8491d0f4e5 | ||
|
|
a2a41e77ea | ||
|
|
8e17090cc7 | ||
|
|
3cb63202a3 | ||
|
|
0bb65e66e8 | ||
|
|
17268ca4ad | ||
|
|
29fffbcc2a | ||
|
|
a8257f3d6e | ||
|
|
85ad0ddd17 | ||
|
|
4e81d4ddb6 | ||
|
|
704e24d58b | ||
|
|
450d09e9e4 | ||
|
|
5dc95b1fca | ||
|
|
148647709a | ||
|
|
cf245b02a5 | ||
|
|
9e450adb0b | ||
|
|
e057dfc482 | ||
|
|
790ac99aa4 | ||
|
|
934ba24b17 | ||
|
|
0bfb3b23b6 | ||
|
|
5aaa749907 | ||
|
|
6f6f76532e | ||
|
|
86fdafef08 | ||
|
|
11c29c8299 | ||
|
|
d7099a69d8 | ||
|
|
4d8a57d119 | ||
|
|
9e5c9ec567 | ||
|
|
17137f3a08 | ||
|
|
642a351bb5 | ||
|
|
daada1a643 | ||
|
|
0e9e1f5133 | ||
|
|
3b0b3d7eb0 | ||
|
|
2ae70dddaa | ||
|
|
6d5e38bec2 | ||
|
|
9a0c9f36a8 | ||
|
|
58432ce80e | ||
|
|
1d950be7e4 | ||
|
|
8ca6ef5782 | ||
|
|
9038abac8f | ||
|
|
0f1bfc4141 | ||
|
|
ae5ee8957c | ||
|
|
d80c275abb | ||
|
|
916a747f88 | ||
|
|
ea2e2bdc9a | ||
|
|
03f1733387 | ||
|
|
df7c9e0b1c | ||
|
|
2020fdd4ea | ||
|
|
2c64eadafa | ||
|
|
93eba8da2b | ||
|
|
a82b899eb6 | ||
|
|
8112973dbe | ||
|
|
f390e6a78a | ||
|
|
3ca06f2518 | ||
|
|
515d58f04f | ||
|
|
9eade9abc7 | ||
|
|
e0cf66c421 | ||
|
|
49a1a8916b | ||
|
|
c46f2534b8 | ||
|
|
5ed415e453 | ||
|
|
7543d8be12 | ||
|
|
cf6af4630d | ||
|
|
bb167b00eb | ||
|
|
d578b7322a | ||
|
|
86ee5944bc | ||
|
|
ae82571c56 | ||
|
|
5cd1419b21 | ||
|
|
ea448dfa47 |
105
Changelog.txt
105
Changelog.txt
@@ -1,3 +1,108 @@
|
||||
Version 2.2.000
|
||||
//TODO: Add level up milestone processing hooks
|
||||
//TODO: Verify fishing durability change is removed
|
||||
|
||||
Removed the mcimport command as its useless (was for mod configs)
|
||||
mcMMO-API is now the library used for mcMMO API
|
||||
Parts of the API have been migrated to mcMMO-API
|
||||
(API) mcMMO makes use of jmal (Java Minecraft Abstraction Library) for some abstraction now
|
||||
(API) Added skill register
|
||||
(API) Skill hierarchy is now defined by Skill in mcMMO-API, and mcMMO needs a skill to be registered to be aware of it
|
||||
(API) A lot of changes to the API, I'll be including a document with the release of this update to explain the finer details
|
||||
When using commands that require typing a skill name, locale names are now always checked
|
||||
When using commands that require typing a skill name, it is now legal to provide the skills fully qualified identifier
|
||||
|
||||
Codebase Stuff
|
||||
Many places that passed type Player now passes type McMMOPlayer instead
|
||||
|
||||
New Skill - Tridents
|
||||
New Skill - Crossbows
|
||||
|
||||
New config file named 'tridents.yml'
|
||||
|
||||
New command /tridents - Skill Info for Tridents
|
||||
New command /crossbows - Skill Info for Crossbows
|
||||
|
||||
Added Sub-Skill named Multi Tasking to Tridents
|
||||
Added Sub-Skill named Tridents Limit Break to Tridents
|
||||
|
||||
Added Sub-Skill named Super Shotgun to Crossbows
|
||||
Added Sub-Skill named Crossbows Limit Break to Crossbows
|
||||
|
||||
Permission node descriptions had mentions of ability changed to sub-skill and other minor corrections
|
||||
mcMMO will now register arrows shot from the offhand as being from either Archery or Crossbows (before mcMMO ignored offhand Archery)
|
||||
|
||||
(These permissions are all included in the mcmmo.defaults node)
|
||||
New permission node 'mcmmo.commands.tridents'
|
||||
New permission node 'mcmmo.skills.tridents'
|
||||
New permission node 'mcmmo.ability.tridents.all'
|
||||
New permission node 'mcmmo.ability.tridents.multitasking'
|
||||
New permission node 'mcmmo.ability.tridents.tridentslimitbreak'
|
||||
|
||||
New permission node 'mcmmo.commands.crossbows'
|
||||
New permission node 'mcmmo.skills.crossbows'
|
||||
New permission node 'mcmmo.ability.crossbows.all'
|
||||
New permission node 'mcmmo.ability.crossbows.crossbowslimitbreak'
|
||||
New permission node 'mcmmo.ability.crossbows.coneofdeath'
|
||||
|
||||
The Party system has some new features, and a lot of bad features were removed completely, read the notes
|
||||
Parties can no longer have passwords (see notes)
|
||||
Parties can no longer be locked (see notes)
|
||||
Parties no longer have item share (see notes)
|
||||
Party alliances are gone (see notes)
|
||||
Parties are always private (see notes)
|
||||
Party members can be promoted to Officer by the Party Leader (officers are mini-party leaders)
|
||||
Added Party Officer chat, only other officers (including the party leader) can read and participate
|
||||
Added the following party subcommands: promote, demote
|
||||
Removed the following party subcommands: join, lock, unlock, password, alliance, item share
|
||||
|
||||
Added permission node 'mcmmo.chat.officerpartychat'
|
||||
|
||||
The following permission nodes were removed because their related feature was removed
|
||||
Removed permission node 'mcmmo.commands.party.unlock'
|
||||
Removed permission node 'mcmmo.commands.party.alliance'
|
||||
Removed permission node 'mcmmo.commands.party.password'
|
||||
Removed permission node 'mcmmo.commands.party.itemshare'
|
||||
|
||||
The following permission nodes were removed because permissions for these commands don't make sense, if you want to disable party commands just negate 'mcmmo.commands.party'
|
||||
Removed permission node 'mcmmo.commands.party.quit'
|
||||
Removed permission node 'mcmmo.commands.party.kick'
|
||||
|
||||
Added new locale string 'Overhaul.Name.Tridents'
|
||||
Added new locale string 'Tridents.SubSkill.TridentsLimitBreak.Name'
|
||||
Added new locale string 'Tridents.SubSkill.TridentsLimitBreak.Description'
|
||||
Added new locale string 'Tridents.SubSkill.TridentsLimitBreak.Stat'
|
||||
|
||||
Added new locale string 'Overhaul.Name.Crossbows'
|
||||
Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Name'
|
||||
Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Description'
|
||||
Added new locale string 'Crossbows.SubSkill.CrossbowsLimitBreak.Stat'
|
||||
|
||||
Added new locale string 'Commands.MissingProfile'
|
||||
Removed locale string 'Commands.Offline'
|
||||
|
||||
|
||||
Player Power Levels no longer need to pass permission checks when summing skills
|
||||
Minor improvements to how player data is serialized
|
||||
SMP mod settings removed from config.yml (this is a legacy feature and didn't really do anything anymore)
|
||||
Refactored & Optimized a bunch of code involving player and party data
|
||||
|
||||
Added XP bar settings for Tridents & Crossbows to experience.yml
|
||||
Changed some debug level logging to info level for convenience
|
||||
|
||||
Database Changes
|
||||
XP Bar settings (set by /mmoxpbar command) are now saved
|
||||
Players can now be marked as exempt from leadboards
|
||||
Party Chat Spy toggle is now saved
|
||||
(FlatFile) Fixed a bug where last login was not being saved
|
||||
Schema updated for the new skills and supers and things mentioned above
|
||||
|
||||
|
||||
Notes:
|
||||
These are the first new skills that I've written for mcMMO in about 9 years, I'll be listening closely to feedback and tweaking them often.
|
||||
Parties got unnecessarily complex in my absence, I have removed many party features in order to simplify parties and bring them closer to my vision. I have also added new features which should improve parties where it matters.
|
||||
About the removed party features, all the features I removed I consider poor quality features and I don't think they belong in mcMMO. Feel free to yell at me in discord if you disagree.
|
||||
I don't know what genius decided to make parties public by default, when I found out that parties had been changed to such a system I could barely contain my disgust. Parties are back to being private, you get invited by a party leader or party officer. That is the only way to join a party.
|
||||
Version 2.1.196
|
||||
Crossbows can now be fished up with enchantments
|
||||
|
||||
|
||||
39
pom.xml
39
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.196-SNAPSHOT</version>
|
||||
<version>2.2.000-ALPHA-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
@@ -143,6 +143,9 @@
|
||||
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
|
||||
<include>co.aikar:acf-bukkit</include>
|
||||
<include>com.neetgames:mcMMO-API</include>
|
||||
<!-- <include>com.neetgames:jmal</include>-->
|
||||
<include>com.neetgames:NEET-lib</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<!-- <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>-->
|
||||
@@ -155,6 +158,10 @@
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.adventure</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.neetgames.neetlib</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.neetlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.acf</shadedPattern> <!-- Replace this -->
|
||||
@@ -200,6 +207,10 @@
|
||||
</extensions>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>neet-games</id>
|
||||
<url>https://nexus.neetgames.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
@@ -220,8 +231,10 @@
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
<!-- ... -->
|
||||
<!-- ... -->
|
||||
<repository> <!-- for development builds -->
|
||||
<id>sonatype-oss</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<!-- <dependencyManagement>-->
|
||||
<!-- <dependencies>-->
|
||||
@@ -235,6 +248,26 @@
|
||||
<!-- </dependencies>-->
|
||||
<!-- </dependencyManagement>-->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.neetgames</groupId>
|
||||
<artifactId>mcMMO-API</artifactId>
|
||||
<version>0.01.00-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neetgames</groupId>
|
||||
<artifactId>jmal-core</artifactId>
|
||||
<version>0.01.00-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neetgames</groupId>
|
||||
<artifactId>jmal-bukkit</artifactId>
|
||||
<version>0.01.00-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neetgames</groupId>
|
||||
<artifactId>NEET-lib</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.seeseemelk</groupId>
|
||||
<artifactId>MockBukkit-v1.16</artifactId>
|
||||
|
||||
@@ -1,142 +1,142 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class ChatAPI {
|
||||
private ChatAPI() {}
|
||||
|
||||
//package com.gmail.nossr50.api;
|
||||
//
|
||||
//import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
//import com.gmail.nossr50.mcMMO;
|
||||
//import com.gmail.nossr50.util.player.UserManager;
|
||||
//import org.bukkit.entity.Player;
|
||||
//
|
||||
//public final class ChatAPI {
|
||||
// private ChatAPI() {}
|
||||
//
|
||||
//// /**
|
||||
//// * Send a message to all members of a party
|
||||
//// * </br>
|
||||
//// * This function is designed for API usage.
|
||||
//// *
|
||||
//// * @param plugin The plugin sending the message
|
||||
//// * @param sender The name of the sender
|
||||
//// * @param displayName The display name of the sender
|
||||
//// * @param party The name of the party to send to
|
||||
//// * @param message The message to send
|
||||
//// */
|
||||
//// public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
//// getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
//// }
|
||||
////
|
||||
//// /**
|
||||
//// * Send a message to all members of a party
|
||||
//// * </br>
|
||||
//// * This function is designed for API usage.
|
||||
//// *
|
||||
//// * @param plugin The plugin sending the message
|
||||
//// * @param sender The name of the sender to display in the chat
|
||||
//// * @param party The name of the party to send to
|
||||
//// * @param message The message to send
|
||||
//// */
|
||||
//// public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
//// getPartyChatManager(plugin, party).handleChat(sender, message);
|
||||
//// }
|
||||
////
|
||||
//// /**
|
||||
//// * Send a message to administrators
|
||||
//// * </br>
|
||||
//// * This function is designed for API usage.
|
||||
//// *
|
||||
//// * @param plugin The plugin sending the message
|
||||
//// * @param sender The name of the sender
|
||||
//// * @param displayName The display name of the sender
|
||||
//// * @param message The message to send
|
||||
//// */
|
||||
//// public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
//// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, displayName, message);
|
||||
//// }
|
||||
////
|
||||
//// /**
|
||||
//// * Send a message to administrators
|
||||
//// * </br>
|
||||
//// * This function is designed for API usage.
|
||||
//// *
|
||||
//// * @param plugin The plugin sending the message
|
||||
//// * @param sender The name of the sender to display in the chat
|
||||
//// * @param message The message to send
|
||||
//// */
|
||||
//// public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
//// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, message);
|
||||
//// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to all members of a party
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// * Check if a player is currently talking in party chat.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender
|
||||
// * @param displayName The display name of the sender
|
||||
// * @param party The name of the party to send to
|
||||
// * @param message The message to send
|
||||
// * @param player The player to check
|
||||
// * @return true if the player is using party chat, false otherwise
|
||||
// */
|
||||
// public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
// getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
// public static boolean isUsingPartyChat(Player player) {
|
||||
// return UserManager.getPlayer(player).getChatChannel() == ChatChannel.PARTY;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to all members of a party
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// * Check if a player is currently talking in party chat.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender to display in the chat
|
||||
// * @param party The name of the party to send to
|
||||
// * @param message The message to send
|
||||
// * @param playerName The name of the player to check
|
||||
// * @return true if the player is using party chat, false otherwise
|
||||
// */
|
||||
// public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
// getPartyChatManager(plugin, party).handleChat(sender, message);
|
||||
// public static boolean isUsingPartyChat(String playerName) {
|
||||
// return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.PARTY;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to administrators
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// * Check if a player is currently talking in admin chat.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender
|
||||
// * @param displayName The display name of the sender
|
||||
// * @param message The message to send
|
||||
// * @param player The player to check
|
||||
// * @return true if the player is using admin chat, false otherwise
|
||||
// */
|
||||
// public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, displayName, message);
|
||||
// public static boolean isUsingAdminChat(Player player) {
|
||||
// return UserManager.getPlayer(player).getChatChannel() == ChatChannel.ADMIN;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to administrators
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// * Check if a player is currently talking in admin chat.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender to display in the chat
|
||||
// * @param message The message to send
|
||||
// * @param playerName The name of the player to check
|
||||
// * @return true if the player is using admin chat, false otherwise
|
||||
// */
|
||||
// public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, message);
|
||||
// public static boolean isUsingAdminChat(String playerName) {
|
||||
// return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.ADMIN;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(Player player) {
|
||||
return UserManager.getPlayer(player).getChatChannel() == ChatChannel.PARTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(String playerName) {
|
||||
return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.PARTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(Player player) {
|
||||
return UserManager.getPlayer(player).getChatChannel() == ChatChannel.ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(String playerName) {
|
||||
return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the party chat mode of a player.
|
||||
*
|
||||
* @param player The player to toggle party chat on.
|
||||
*/
|
||||
public static void togglePartyChat(Player player) {
|
||||
mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.PARTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the party chat mode of a player.
|
||||
*
|
||||
* @param playerName The name of the player to toggle party chat on.
|
||||
*/
|
||||
public static void togglePartyChat(String playerName) {
|
||||
mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.PARTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the admin chat mode of a player.
|
||||
*
|
||||
* @param player The player to toggle admin chat on.
|
||||
*/
|
||||
public static void toggleAdminChat(Player player) {
|
||||
mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the admin chat mode of a player.
|
||||
*
|
||||
* @param playerName The name of the player to toggle party chat on.
|
||||
*/
|
||||
public static void toggleAdminChat(String playerName) {
|
||||
mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.ADMIN);
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * Toggle the party chat mode of a player.
|
||||
// *
|
||||
// * @param player The player to toggle party chat on.
|
||||
// */
|
||||
// public static void togglePartyChat(Player player) {
|
||||
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.PARTY);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Toggle the party chat mode of a player.
|
||||
// *
|
||||
// * @param playerName The name of the player to toggle party chat on.
|
||||
// */
|
||||
// public static void togglePartyChat(String playerName) {
|
||||
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.PARTY);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Toggle the admin chat mode of a player.
|
||||
// *
|
||||
// * @param player The player to toggle admin chat on.
|
||||
// */
|
||||
// public static void toggleAdminChat(Player player) {
|
||||
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.ADMIN);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Toggle the admin chat mode of a player.
|
||||
// *
|
||||
// * @param playerName The name of the player to toggle party chat on.
|
||||
// */
|
||||
// public static void toggleAdminChat(String playerName) {
|
||||
// mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.ADMIN);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
public enum ItemSpawnReason {
|
||||
ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob
|
||||
EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this
|
||||
FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this
|
||||
FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake
|
||||
HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck
|
||||
BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining
|
||||
BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining
|
||||
BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills
|
||||
UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon
|
||||
SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form
|
||||
SALVAGE_MATERIALS, //When you salvage an item and get materials back
|
||||
TREE_FELLER_DISPLACED_BLOCK,
|
||||
BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc
|
||||
}
|
||||
//package com.gmail.nossr50.api;
|
||||
//
|
||||
//public enum ItemSpawnReason {
|
||||
// ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob
|
||||
// EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this
|
||||
// FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this
|
||||
// FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake
|
||||
// HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck
|
||||
// BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining
|
||||
// BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining
|
||||
// BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills
|
||||
// UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon
|
||||
// SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form
|
||||
// SALVAGE_MATERIALS, //When you salvage an item and get materials back
|
||||
// TREE_FELLER_DISPLACED_BLOCK,
|
||||
// BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc
|
||||
//}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IncompleteNamespacedKeyRegister extends RuntimeException {
|
||||
private static final long serialVersionUID = -6905157273569301219L;
|
||||
|
||||
public IncompleteNamespacedKeyRegister(@NotNull String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidFormulaTypeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 3368670229490121886L;
|
||||
|
||||
public InvalidFormulaTypeException() {
|
||||
super("That is not a valid FormulaType.");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidPlayerException extends RuntimeException {
|
||||
private static final long serialVersionUID = 907213002618581385L;
|
||||
|
||||
public InvalidPlayerException() {
|
||||
super("That player does not exist in the database.");
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidSkillException extends RuntimeException {
|
||||
private static final long serialVersionUID = 942705284195791157L;
|
||||
|
||||
public InvalidSkillException() {
|
||||
super("That is not a valid skill.");
|
||||
}
|
||||
|
||||
public InvalidSkillException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidXPGainReasonException extends RuntimeException {
|
||||
private static final long serialVersionUID = 4427052841957931157L;
|
||||
|
||||
public InvalidXPGainReasonException() {
|
||||
super("That is not a valid XPGainReason.");
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPlayerNotFoundException extends RuntimeException {
|
||||
private static final long serialVersionUID = 761917904993202836L;
|
||||
|
||||
public McMMOPlayerNotFoundException(@NotNull Player player) {
|
||||
super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet! : " + player.getName() + " " + player.getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ import com.gmail.nossr50.chat.mailer.AdminChatMailer;
|
||||
import com.gmail.nossr50.chat.mailer.PartyChatMailer;
|
||||
import com.gmail.nossr50.config.ChatConfig;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@@ -45,7 +45,7 @@ public class ChatManager {
|
||||
* @param rawMessage the raw message from the player as it was typed
|
||||
* @param isAsync whether or not this is getting processed via async
|
||||
*/
|
||||
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String rawMessage, boolean isAsync) {
|
||||
public void processPlayerMessage(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull String rawMessage, boolean isAsync) {
|
||||
processPlayerMessage(mmoPlayer, mmoPlayer.getChatChannel(), rawMessage, isAsync);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ChatManager {
|
||||
* @param args the raw command arguments from the player
|
||||
* @param chatChannel target channel
|
||||
*/
|
||||
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String[] args, @NotNull ChatChannel chatChannel) {
|
||||
public void processPlayerMessage(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull String[] args, @NotNull ChatChannel chatChannel) {
|
||||
String chatMessageWithoutCommand = buildChatMessage(args);
|
||||
|
||||
//Commands are never async
|
||||
@@ -71,7 +71,7 @@ public class ChatManager {
|
||||
* @param rawMessage raw chat message as it was typed
|
||||
* @param isAsync whether or not this is getting processed via async
|
||||
*/
|
||||
private void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel chatChannel, @NotNull String rawMessage, boolean isAsync) {
|
||||
private void processPlayerMessage(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull ChatChannel chatChannel, @NotNull String rawMessage, boolean isAsync) {
|
||||
switch (chatChannel) {
|
||||
case ADMIN:
|
||||
adminChatMailer.processChatMessage(mmoPlayer.getPlayerAuthor(), rawMessage, isAsync, Permissions.colorChat(mmoPlayer.getPlayer()));
|
||||
@@ -119,19 +119,19 @@ public class ChatManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the chat channel of a {@link McMMOPlayer}
|
||||
* Change the chat channel of a {@link OnlineMMOPlayer}
|
||||
* Targeting the channel a player is already in will remove that player from the chat channel
|
||||
* @param mmoPlayer target player
|
||||
* @param targetChatChannel target chat channel
|
||||
*/
|
||||
public void setOrToggleChatChannel(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel targetChatChannel) {
|
||||
public void setOrToggleChatChannel(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull ChatChannel targetChatChannel) {
|
||||
if(targetChatChannel == mmoPlayer.getChatChannel()) {
|
||||
//Disabled message
|
||||
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.Off", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||
Misc.adaptPlayer(mmoPlayer).sendMessage(LocaleLoader.getString("Chat.Channel.Off", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||
mmoPlayer.setChatMode(ChatChannel.NONE);
|
||||
} else {
|
||||
mmoPlayer.setChatMode(targetChatChannel);
|
||||
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.On", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||
Misc.adaptPlayer(mmoPlayer).sendMessage(LocaleLoader.getString("Chat.Channel.On", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,10 +159,10 @@ public class ChatManager {
|
||||
* @param mmoPlayer target player
|
||||
* @return true if the player can send messages to that chat channel
|
||||
*/
|
||||
public boolean isMessageAllowed(@NotNull McMMOPlayer mmoPlayer) {
|
||||
public boolean isMessageAllowed(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
switch (mmoPlayer.getChatChannel()) {
|
||||
case ADMIN:
|
||||
if(mmoPlayer.getPlayer().isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
|
||||
if(Misc.adaptPlayer(mmoPlayer).isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -25,7 +24,7 @@ public class SamePartyPredicate<T extends CommandSender> implements Predicate<T>
|
||||
} else {
|
||||
if(t instanceof Player) {
|
||||
Player player = (Player) t;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mcMMOPlayer = UserManager.queryPlayer(player);
|
||||
if(mcMMOPlayer != null) {
|
||||
return mcMMOPlayer.getParty() == party;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.gmail.nossr50.chat.author.Author;
|
||||
import com.gmail.nossr50.chat.message.ChatMessage;
|
||||
import com.gmail.nossr50.chat.message.PartyChatMessage;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.text.TextUtils;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.gmail.nossr50.chat.message;
|
||||
|
||||
import com.gmail.nossr50.chat.author.Author;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.base.Objects;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -61,7 +61,7 @@ public class PartyChatMessage extends AbstractChatMessage {
|
||||
*/
|
||||
private void messagePartyChatSpies(@NotNull TextComponent spyMessage) {
|
||||
//Find the people with permissions
|
||||
for(McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
for(OnlineMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
//Check for toggled players
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class McabilityCommand extends ToggleCommand {
|
||||
public class AbilityToggleCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcabilityOthers(sender);
|
||||
@@ -1,336 +0,0 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ModConfigType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class McImportCommand implements CommandExecutor {
|
||||
int fileAmount;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
importModConfig();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean importModConfig() {
|
||||
String importFilePath = mcMMO.getModDirectory() + File.separator + "import";
|
||||
File importFile = new File(importFilePath, "import.log");
|
||||
mcMMO.p.getLogger().info("Starting import of mod materials...");
|
||||
fileAmount = 0;
|
||||
|
||||
HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<>();
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
try {
|
||||
// Open the file
|
||||
in = new BufferedReader(new FileReader(importFile));
|
||||
|
||||
String line;
|
||||
String materialName;
|
||||
String modName;
|
||||
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] split1 = line.split("material ");
|
||||
|
||||
if (split1.length != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] split2 = split1[1].split(" with");
|
||||
|
||||
if (split2.length != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
materialName = split2[0];
|
||||
|
||||
// Categorise each material under a mod config type
|
||||
ModConfigType type = ModConfigType.getModConfigType(materialName);
|
||||
|
||||
if (!materialNames.containsKey(type)) {
|
||||
materialNames.put(type, new ArrayList<>());
|
||||
}
|
||||
|
||||
materialNames.get(type).add(materialName);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)");
|
||||
mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log");
|
||||
return false;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
}
|
||||
|
||||
createOutput(materialNames);
|
||||
|
||||
mcMMO.p.getLogger().info("Import finished! Created " + fileAmount + " files!");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createOutput(HashMap<ModConfigType, ArrayList<String>> materialNames) {
|
||||
for (ModConfigType modConfigType : materialNames.keySet()) {
|
||||
HashMap<String, ArrayList<String>> materialNamesType = new HashMap<>();
|
||||
|
||||
for (String materialName : materialNames.get(modConfigType)) {
|
||||
String modName = Misc.getModName(materialName);
|
||||
|
||||
if (!materialNamesType.containsKey(modName)) {
|
||||
materialNamesType.put(modName, new ArrayList<>());
|
||||
}
|
||||
|
||||
materialNamesType.get(modName).add(materialName);
|
||||
}
|
||||
|
||||
createOutput(modConfigType, materialNamesType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void tryClose(Closeable c) {
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
c.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createOutput(ModConfigType modConfigType, HashMap<String, ArrayList<String>> materialNames) {
|
||||
File outputFilePath = new File(mcMMO.getModDirectory() + File.separator + "output");
|
||||
if (!outputFilePath.exists() && !outputFilePath.mkdirs()) {
|
||||
mcMMO.p.getLogger().severe("Could not create output directory! " + outputFilePath.getAbsolutePath());
|
||||
}
|
||||
|
||||
FileWriter out = null;
|
||||
String type = modConfigType.name().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
for (String modName : materialNames.keySet()) {
|
||||
File outputFile = new File(outputFilePath, modName + "." + type + ".yml");
|
||||
mcMMO.p.getLogger().info("Creating " + outputFile.getName());
|
||||
try {
|
||||
if (outputFile.exists() && !outputFile.delete()) {
|
||||
mcMMO.p.getLogger().severe("Not able to delete old output file! " + outputFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (!outputFile.createNewFile()) {
|
||||
mcMMO.p.getLogger().severe("Could not create output file! " + outputFile.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
|
||||
StringBuilder writer = new StringBuilder();
|
||||
HashMap<String, ArrayList<String>> configSections = getConfigSections(modConfigType, modName, materialNames);
|
||||
|
||||
if (configSections == null) {
|
||||
mcMMO.p.getLogger().severe("Something went wrong!! type is " + type);
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the file, go through each skill and write all the materials
|
||||
for (String configSection : configSections.keySet()) {
|
||||
if (configSection.equals("UNIDENTIFIED")) {
|
||||
writer.append("# This isn't a valid config section and all materials in this category need to be").append("\r\n");
|
||||
writer.append("# copy and pasted to a valid section of this config file.").append("\r\n");
|
||||
}
|
||||
writer.append(configSection).append(":").append("\r\n");
|
||||
|
||||
for (String line : configSections.get(configSection)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
|
||||
writer.append("\r\n");
|
||||
}
|
||||
|
||||
out = new FileWriter(outputFile);
|
||||
out.write(writer.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} finally {
|
||||
tryClose(out);
|
||||
fileAmount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, ArrayList<String>> getConfigSections(ModConfigType type, String modName, HashMap<String, ArrayList<String>> materialNames) {
|
||||
switch (type) {
|
||||
case BLOCKS:
|
||||
return getConfigSectionsBlocks(modName, materialNames);
|
||||
case TOOLS:
|
||||
return getConfigSectionsTools(modName, materialNames);
|
||||
case ARMOR:
|
||||
return getConfigSectionsArmor(modName, materialNames);
|
||||
case UNKNOWN:
|
||||
return getConfigSectionsUnknown(modName, materialNames);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private HashMap<String, ArrayList<String>> getConfigSectionsBlocks(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
||||
|
||||
// Go through all the materials and categorise them under a skill
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
String skillName = "UNIDENTIFIED";
|
||||
if (materialName.contains("ORE")) {
|
||||
skillName = "Mining";
|
||||
}
|
||||
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
|
||||
skillName = "Woodcutting";
|
||||
}
|
||||
else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
|
||||
skillName = "Herbalism";
|
||||
}
|
||||
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
|
||||
skillName = "Excavation";
|
||||
}
|
||||
|
||||
if (!configSections.containsKey(skillName)) {
|
||||
configSections.put(skillName, new ArrayList<>());
|
||||
}
|
||||
|
||||
ArrayList<String> skillContents = configSections.get(skillName);
|
||||
skillContents.add(" " + materialName + "|0:");
|
||||
skillContents.add(" " + " " + "XP_Gain: 99");
|
||||
skillContents.add(" " + " " + "Double_Drops_Enabled: true");
|
||||
|
||||
if (skillName.equals("Mining")) {
|
||||
skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
|
||||
}
|
||||
else if (skillName.equals("Woodcutting")) {
|
||||
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
|
||||
}
|
||||
}
|
||||
|
||||
return configSections;
|
||||
}
|
||||
|
||||
private HashMap<String, ArrayList<String>> getConfigSectionsTools(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
||||
|
||||
// Go through all the materials and categorise them under a tool type
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
String toolType = "UNIDENTIFIED";
|
||||
if (materialName.contains("PICKAXE")) {
|
||||
toolType = "Pickaxes";
|
||||
}
|
||||
else if (materialName.contains("AXE")) {
|
||||
toolType = "Axes";
|
||||
}
|
||||
else if (materialName.contains("BOW")) {
|
||||
toolType = "Bows";
|
||||
}
|
||||
else if (materialName.contains("HOE")) {
|
||||
toolType = "Hoes";
|
||||
}
|
||||
else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
|
||||
toolType = "Shovels";
|
||||
}
|
||||
else if (materialName.contains("SWORD")) {
|
||||
toolType = "Swords";
|
||||
}
|
||||
|
||||
if (!configSections.containsKey(toolType)) {
|
||||
configSections.put(toolType, new ArrayList<>());
|
||||
}
|
||||
|
||||
ArrayList<String> skillContents = configSections.get(toolType);
|
||||
skillContents.add(" " + materialName + ":");
|
||||
skillContents.add(" " + " " + "XP_Modifier: 1.0");
|
||||
skillContents.add(" " + " " + "Tier: 1");
|
||||
skillContents.add(" " + " " + "Ability_Enabled: true");
|
||||
addRepairableLines(materialName, skillContents);
|
||||
}
|
||||
|
||||
return configSections;
|
||||
}
|
||||
|
||||
private HashMap<String, ArrayList<String>> getConfigSectionsArmor(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
||||
|
||||
// Go through all the materials and categorise them under an armor type
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
String toolType = "UNIDENTIFIED";
|
||||
if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
|
||||
toolType = "Boots";
|
||||
}
|
||||
else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
|
||||
toolType = "Chestplates";
|
||||
}
|
||||
else if (materialName.contains("HELM") || materialName.contains("HAT")) {
|
||||
toolType = "Helmets";
|
||||
}
|
||||
else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
|
||||
toolType = "Leggings";
|
||||
}
|
||||
|
||||
if (!configSections.containsKey(toolType)) {
|
||||
configSections.put(toolType, new ArrayList<>());
|
||||
}
|
||||
|
||||
ArrayList<String> skillContents = configSections.get(toolType);
|
||||
skillContents.add(" " + materialName + ":");
|
||||
addRepairableLines(materialName, skillContents);
|
||||
}
|
||||
|
||||
return configSections;
|
||||
}
|
||||
|
||||
private void addRepairableLines(String materialName, ArrayList<String> skillContents) {
|
||||
skillContents.add(" " + " " + "Repairable: true");
|
||||
skillContents.add(" " + " " + "Repair_Material: REPAIR_MATERIAL_NAME");
|
||||
skillContents.add(" " + " " + "Repair_Material_Data_Value: 0");
|
||||
skillContents.add(" " + " " + "Repair_Material_Quantity: 9");
|
||||
skillContents.add(" " + " " + "Repair_Material_Pretty_Name: Repair Item Name");
|
||||
skillContents.add(" " + " " + "Repair_MinimumLevel: 0");
|
||||
skillContents.add(" " + " " + "Repair_XpMultiplier: 1.0");
|
||||
|
||||
Material material = Material.matchMaterial(materialName);
|
||||
short durability = (material == null) ? (short) 9999 : material.getMaxDurability();
|
||||
skillContents.add(" " + " " + "Durability: " + ((durability > 0) ? durability : (short) 9999));
|
||||
}
|
||||
|
||||
private HashMap<String, ArrayList<String>> getConfigSectionsUnknown(String modName, HashMap<String, ArrayList<String>> materialNames) {
|
||||
HashMap<String, ArrayList<String>> configSections = new HashMap<>();
|
||||
|
||||
// Go through all the materials and print them
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
String configKey = "UNIDENTIFIED";
|
||||
|
||||
if (!configSections.containsKey(configKey)) {
|
||||
configSections.put(configKey, new ArrayList<>());
|
||||
}
|
||||
|
||||
ArrayList<String> skillContents = configSections.get(configKey);
|
||||
skillContents.add(" " + materialName);
|
||||
}
|
||||
|
||||
return configSections;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
PlayerProfile profile = oldDatabase.loadPlayerProfile(player);
|
||||
|
||||
if (profile.isLoaded()) {
|
||||
mcMMO.getDatabaseManager().saveUser(profile);
|
||||
mcMMO.getDatabaseManager().saveUser(profile.getPlayerData());
|
||||
}
|
||||
|
||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class McremoveCommand implements TabExecutor {
|
||||
public class RemoveCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
@@ -9,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
profile.addLevels(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
profile.scheduleAsyncSave();
|
||||
UserManager.getPlayerSaveHandler().scheduleAsyncSave(profile.getPlayerData());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
}
|
||||
else {
|
||||
profile.addXp(skill, value);
|
||||
profile.scheduleAsyncSave();
|
||||
UserManager.getPlayerSaveHandler().scheduleAsyncSave(profile.getPlayerData());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -31,7 +32,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
profile.modifySkill(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
profile.scheduleAsyncSave();
|
||||
UserManager.getPlayerSaveHandler().scheduleAsyncSave(profile.getPlayerData());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
@@ -27,7 +26,7 @@ import java.util.List;
|
||||
* This class mirrors the structure of ExperienceCommand, except the
|
||||
* value/quantity argument is removed.
|
||||
*/
|
||||
public class SkillresetCommand implements TabExecutor {
|
||||
public class SkillResetCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
PrimarySkillType skill;
|
||||
@@ -126,7 +125,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (player == null) {
|
||||
profile.scheduleAsyncSave();
|
||||
UserManager.getPlayerSaveHandler().scheduleAsyncSave(profile.getPlayerData());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -38,23 +36,19 @@ public class PartyCommand implements TabExecutor {
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private final CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private final CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
private final CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||
private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
|
||||
private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private final CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private final CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
private final CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||
private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
private final CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private final CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private final CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private final CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||
private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class PartyItemShareCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party party = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase(Locale.ENGLISH));
|
||||
|
||||
if (mode == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
handleChangingShareMode(party, mode);
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
boolean toggle;
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[2])) {
|
||||
toggle = true;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[2])) {
|
||||
toggle = false;
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase(Locale.ENGLISH)), toggle);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChangingShareMode(Party party, ShareMode mode) {
|
||||
party.setItemShareMode(mode);
|
||||
|
||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(changeModeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
|
||||
party.setSharingDrops(type, toggle);
|
||||
|
||||
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(toggleMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyJoinCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (!mcMMOTarget.inParty()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
Party targetParty = mcMMOTarget.getParty();
|
||||
|
||||
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String password = getPassword(args);
|
||||
|
||||
// Make sure party passwords match
|
||||
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyName = targetParty.getName();
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(PartyManager.isPartyFull(player, targetParty))
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
|
||||
PartyManager.addToParty(mcMMOPlayer, targetParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String getPassword(String[] args) {
|
||||
if (args.length == 3) {
|
||||
return args[2];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyLockCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("lock")) {
|
||||
togglePartyLock(sender, true);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
togglePartyLock(sender, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("lock")) {
|
||||
sendUsageStrings(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
togglePartyLock(sender, true);
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
togglePartyLock(sender, false);
|
||||
}
|
||||
else {
|
||||
sendUsageStrings(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sendUsageStrings(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendUsageStrings(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
|
||||
}
|
||||
|
||||
private void togglePartyLock(CommandSender sender, boolean lock) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (lock == party.isLocked()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
|
||||
return;
|
||||
}
|
||||
|
||||
party.setLocked(lock);
|
||||
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
public enum PartySubcommandType {
|
||||
public enum PartySubCommandType {
|
||||
JOIN,
|
||||
ACCEPT,
|
||||
CREATE,
|
||||
@@ -8,21 +8,18 @@ public enum PartySubcommandType {
|
||||
INFO,
|
||||
QUIT,
|
||||
XPSHARE,
|
||||
ITEMSHARE,
|
||||
INVITE,
|
||||
KICK,
|
||||
DISBAND,
|
||||
OWNER,
|
||||
LOCK,
|
||||
UNLOCK,
|
||||
PASSWORD,
|
||||
RENAME,
|
||||
TELEPORT,
|
||||
CHAT,
|
||||
ALLIANCE;
|
||||
PROMOTE,
|
||||
DEMOTE;
|
||||
|
||||
public static PartySubcommandType getSubcommand(String commandName) {
|
||||
for (PartySubcommandType command : values()) {
|
||||
public static PartySubCommandType getSubcommand(String commandName) {
|
||||
for (PartySubCommandType command : values()) {
|
||||
if (command.name().equalsIgnoreCase(commandName)) {
|
||||
return command;
|
||||
}
|
||||
@@ -39,14 +36,8 @@ public enum PartySubcommandType {
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
return XPSHARE;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
|
||||
return ITEMSHARE;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("ally")) {
|
||||
return ALLIANCE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyAllianceAcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.hasPartyAllianceInvite()) {
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getParty().getAlly() != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.acceptAllianceInvite(mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartyAllianceCommand implements TabExecutor {
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
private Party targetParty;
|
||||
|
||||
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
|
||||
|
||||
private final CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
|
||||
private final CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
|
||||
private final CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (playerParty.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerParty.getAlly() == null) {
|
||||
printUsage();
|
||||
return true;
|
||||
}
|
||||
|
||||
targetParty = playerParty.getAlly();
|
||||
|
||||
displayPartyHeader();
|
||||
displayMemberInfo(mcMMOPlayer);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
if (playerParty.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("invite")) {
|
||||
return partyAllianceInviteCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("accept")) {
|
||||
return partyAllianceAcceptCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("disband")) {
|
||||
return partyAllianceDisbandCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (playerParty.getAlly() == null) {
|
||||
printUsage();
|
||||
return true;
|
||||
}
|
||||
|
||||
targetParty = playerParty.getAlly();
|
||||
|
||||
displayPartyHeader();
|
||||
displayMemberInfo(mcMMOPlayer);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean printUsage() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.1"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void displayPartyHeader() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName()));
|
||||
}
|
||||
|
||||
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
|
||||
player.sendMessage(playerParty.createMembersList(player));
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
|
||||
player.sendMessage(targetParty.createMembersList(player));
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyAllianceDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getAlly() == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.disbandAlliance(player, party, party.getAlly());
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyAllianceInviteCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 3) {
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (player.equals(target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (playerParty.getAlly() != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOTarget.setPartyAllianceInvite(playerParty);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1"));
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.skills.crossbows.CrossbowsManager;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CrossbowsCommand extends SkillCommand {
|
||||
public CrossbowsCommand() {
|
||||
super(PrimarySkillType.CROSSBOWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(@NotNull OnlineMMOPlayer mmoPlayer, float skillValue) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<String> statsDisplay(@NotNull OnlineMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
CrossbowsManager crossbowsManager = ((McMMOPlayer) (mmoPlayer)).getCrossbowManager();
|
||||
|
||||
if(canUseSubskill(mmoPlayer, SubSkillType.CROSSBOWS_SUPER_SHOTGUN)) {
|
||||
String additionalArrowCount = String.valueOf(crossbowsManager.getSuperShotgunAdditionalArrowCount());
|
||||
messages.add(getStatMessage(SubSkillType.CROSSBOWS_SUPER_SHOTGUN, additionalArrowCount));
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Component> getTextComponents(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.CROSSBOWS);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TridentsCommand extends SkillCommand {
|
||||
public TridentsCommand() {
|
||||
super(PrimarySkillType.TRIDENTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(@NotNull OnlineMMOPlayer mmoPlayer, float skillValue) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<String> statsDisplay(@NotNull OnlineMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Component> getTextComponents(@NotNull Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.TRIDENTS);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
/* GENERAL */
|
||||
|
||||
public boolean canApplyLimitBreakPVE() { return config.getBoolean("Skills.General.LimitBreak.AllowPVE", false); }
|
||||
public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); }
|
||||
public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 0); }
|
||||
|
||||
public boolean allowPlayerTips() {
|
||||
return config.getBoolean("Feedback.PlayerTips", true);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.neetgames.mcmmo.MobHealthBarType;
|
||||
import com.neetgames.mcmmo.database.PoolIdentifier;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -174,7 +174,6 @@ public class GeneralConfig extends AutoUpdateConfigLoader {
|
||||
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||
|
||||
|
||||
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
||||
public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
|
||||
|
||||
@@ -184,12 +183,12 @@ public class GeneralConfig extends AutoUpdateConfigLoader {
|
||||
public boolean getMobHealthbarEnabled() { return config.getBoolean("Mob_Healthbar.Enabled", true); }
|
||||
|
||||
/* Mob Healthbar */
|
||||
public MobHealthbarType getMobHealthbarDefault() {
|
||||
public MobHealthBarType getMobHealthbarDefault() {
|
||||
try {
|
||||
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase(Locale.ENGLISH).trim());
|
||||
return MobHealthBarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase(Locale.ENGLISH).trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return MobHealthbarType.HEARTS;
|
||||
return MobHealthBarType.HEARTS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,12 +281,6 @@ public class GeneralConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
public int getHardcoreVampirismLevelThreshold() { return config.getInt("Hardcore.Vampirism.Level_Threshold", 0); }
|
||||
|
||||
/* SMP Mods */
|
||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
|
||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
|
||||
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
|
||||
@@ -473,8 +466,8 @@ public class GeneralConfig extends AutoUpdateConfigLoader {
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
public int getLevelCap(PrimarySkillType skill) {
|
||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
|
||||
public int getLevelCap(@NotNull PrimarySkillType primarySkillType) {
|
||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(primarySkillType.toString()) + ".Level_Cap", 0);
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
@@ -488,7 +481,7 @@ public class GeneralConfig extends AutoUpdateConfigLoader {
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
||||
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
||||
|
||||
|
||||
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
||||
|
||||
public boolean broadcastEventMessages() { return config.getBoolean("General.EventBroadcasts", true);}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -329,6 +330,21 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
|
||||
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
|
||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
|
||||
public boolean isExperienceBarEnabled(@NotNull PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.getRawSkillName())+".Enable", true);}
|
||||
|
||||
public BarColor getExperienceBarColor(@NotNull PrimarySkillType primarySkillType)
|
||||
{
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.getRawSkillName())+".Color");
|
||||
|
||||
for(BarColor barColor : BarColor.values())
|
||||
{
|
||||
if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
return barColor;
|
||||
}
|
||||
|
||||
//In case the value is invalid
|
||||
return BarColor.WHITE;
|
||||
}
|
||||
|
||||
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
|
||||
{
|
||||
@@ -344,8 +360,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return BarColor.WHITE;
|
||||
}
|
||||
|
||||
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
|
||||
{
|
||||
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
|
||||
|
||||
for(BarStyle barStyle : BarStyle.values())
|
||||
@@ -358,6 +373,19 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return BarStyle.SOLID;
|
||||
}
|
||||
|
||||
public BarStyle getExperienceBarStyle(@NotNull PrimarySkillType primarySkillType) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.getRawSkillName())+".BarStyle");
|
||||
|
||||
for(BarStyle barStyle : BarStyle.values())
|
||||
{
|
||||
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
|
||||
return barStyle;
|
||||
}
|
||||
|
||||
//In case the value is invalid
|
||||
return BarStyle.SOLID;
|
||||
}
|
||||
|
||||
/* Acrobatics */
|
||||
public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PotionConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
mcMMO.p.getLogger().info("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.gmail.nossr50.database;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.MMODataSnapshot;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerData;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -47,10 +49,17 @@ public interface DatabaseManager {
|
||||
/**
|
||||
* Save a user to the database.
|
||||
*
|
||||
* @param profile The profile of the player to save
|
||||
* @param playerData target player data
|
||||
* @return true if successful, false on failure
|
||||
*/
|
||||
boolean saveUser(PlayerProfile profile);
|
||||
boolean saveUser(@NotNull PlayerData playerData);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataSnapshot target data snapshot
|
||||
* @return true if successful, false on failure
|
||||
*/
|
||||
boolean saveUser(@NotNull MMODataSnapshot dataSnapshot);
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
|
||||
@@ -16,14 +16,14 @@ public class DatabaseManagerFactory {
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.debug("Could not create custom database manager");
|
||||
mcMMO.p.getLogger().info("Could not create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
mcMMO.p.debug("Failed to create custom database manager");
|
||||
mcMMO.p.getLogger().info("Failed to create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
mcMMO.p.debug("Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||
mcMMO.p.getLogger().info("Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||
}
|
||||
|
||||
return mcMMO.p.getGeneralConfig().getUseMySQL() ? new SQLDatabaseManager() : new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
public class FlatFileMappings {
|
||||
|
||||
|
||||
//Used to map out the split data in the FFDB
|
||||
public static int USERNAME = 0;
|
||||
public static int SKILLS_MINING = 1;
|
||||
public static int EXP_MINING = 4;
|
||||
public static int SKILLS_WOODCUTTING = 5;
|
||||
public static int EXP_WOODCUTTING = 6;
|
||||
public static int SKILLS_REPAIR = 7;
|
||||
public static int SKILLS_UNARMED = 8;
|
||||
public static int SKILLS_HERBALISM = 9;
|
||||
public static int SKILLS_EXCAVATION = 10;
|
||||
public static int SKILLS_ARCHERY = 11;
|
||||
public static int SKILLS_SWORDS = 12;
|
||||
public static int SKILLS_AXES = 13;
|
||||
public static int SKILLS_ACROBATICS = 14;
|
||||
public static int EXP_REPAIR = 15;
|
||||
public static int EXP_UNARMED = 16;
|
||||
public static int EXP_HERBALISM = 17;
|
||||
public static int EXP_EXCAVATION = 18;
|
||||
public static int EXP_ARCHERY = 19;
|
||||
public static int EXP_SWORDS = 20;
|
||||
public static int EXP_AXES = 21;
|
||||
public static int EXP_ACROBATICS = 22;
|
||||
public static int SKILLS_TAMING = 24;
|
||||
public static int EXP_TAMING = 25;
|
||||
public static int COOLDOWN_BERSERK = 26;
|
||||
public static int COOLDOWN_GIGA_DRILL_BREAKER = 27;
|
||||
public static int COOLDOWN_TREE_FELLER = 28;
|
||||
public static int COOLDOWN_GREEN_TERRA = 29;
|
||||
public static int COOLDOWN_SERRATED_STRIKES = 30;
|
||||
public static int COOLDOWN_SKULL_SPLITTER = 31;
|
||||
public static int COOLDOWN_SUPER_BREAKER = 32;
|
||||
public static int SKILLS_FISHING = 34;
|
||||
public static int EXP_FISHING = 35;
|
||||
public static int COOLDOWN_BLAST_MINING = 36;
|
||||
public static int LAST_LOGIN = 37;
|
||||
public static int HEALTHBAR = 38;
|
||||
public static int SKILLS_ALCHEMY = 39;
|
||||
public static int EXP_ALCHEMY = 40;
|
||||
public static int UUID_INDEX = 41;
|
||||
public static int SCOREBOARD_TIPS = 42;
|
||||
public static int COOLDOWN_CHIMAERA_WING = 43;
|
||||
public static int SKILLS_TRIDENTS = 44;
|
||||
public static int EXP_TRIDENTS = 45;
|
||||
public static int SKILLS_CROSSBOWS = 46;
|
||||
public static int EXP_CROSSBOWS = 47;
|
||||
public static int BARSTATE_ACROBATICS = 48;
|
||||
public static int BARSTATE_ALCHEMY = 49;
|
||||
public static int BARSTATE_ARCHERY = 50;
|
||||
public static int BARSTATE_AXES = 51;
|
||||
public static int BARSTATE_EXCAVATION = 52;
|
||||
public static int BARSTATE_FISHING = 53;
|
||||
public static int BARSTATE_HERBALISM = 54;
|
||||
public static int BARSTATE_MINING = 55;
|
||||
public static int BARSTATE_REPAIR = 56;
|
||||
public static int BARSTATE_SALVAGE = 57;
|
||||
public static int BARSTATE_SMELTING = 58;
|
||||
public static int BARSTATE_SWORDS = 59;
|
||||
public static int BARSTATE_TAMING = 60;
|
||||
public static int BARSTATE_UNARMED = 61;
|
||||
public static int BARSTATE_WOODCUTTING = 62;
|
||||
public static int BARSTATE_TRIDENTS = 63;
|
||||
public static int BARSTATE_CROSSBOWS = 64;
|
||||
public static int COOLDOWN_ARCHERY_SUPER_1 = 65;
|
||||
public static int COOLDOWN_CROSSBOWS_SUPER_1 = 66;
|
||||
public static int COOLDOWN_TRIDENTS_SUPER_1 = 67;
|
||||
public static int CHATSPY_TOGGLE = 68;
|
||||
public static int LEADERBOARD_IGNORED = 69;
|
||||
|
||||
//TODO: Always update this
|
||||
public final static int LENGTH_OF_SPLIT_DATA_ARRAY = 69;
|
||||
|
||||
}
|
||||
@@ -1,18 +1,25 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.datatypes.player.MMODataBuilder;
|
||||
import com.gmail.nossr50.datatypes.player.MMODataSnapshot;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerData;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.player.UniqueDataType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.neetgames.mcmmo.MobHealthBarType;
|
||||
import com.neetgames.mcmmo.UniqueDataType;
|
||||
import com.neetgames.mcmmo.database.PoolIdentifier;
|
||||
import com.neetgames.mcmmo.exceptions.InvalidSkillException;
|
||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -143,7 +150,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "taming = 0 AND mining = 0 AND woodcutting = 0 AND repair = 0 "
|
||||
+ "AND unarmed = 0 AND herbalism = 0 AND excavation = 0 AND "
|
||||
+ "archery = 0 AND swords = 0 AND axes = 0 AND acrobatics = 0 "
|
||||
+ "AND fishing = 0 AND alchemy = 0;");
|
||||
+ "AND fishing = 0 AND alchemy = 0 AND tridents = 0 AND crossbows = 0;");
|
||||
|
||||
statement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "experience`.`user_id` = `s`.`user_id`)");
|
||||
statement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "huds`.`user_id` = `s`.`user_id`)");
|
||||
@@ -193,7 +200,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
|
||||
}
|
||||
|
||||
public boolean removeUser(String playerName, UUID uuid) {
|
||||
public boolean removeUser(@NotNull String playerName, @Nullable UUID uuid) {
|
||||
boolean success = false;
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
@@ -234,7 +241,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
cachedUserIDs.remove(uuid);
|
||||
}
|
||||
|
||||
public boolean saveUser(PlayerProfile profile) {
|
||||
public boolean saveUser(@NotNull MMODataSnapshot dataSnapshot) {
|
||||
boolean success = true;
|
||||
PreparedStatement statement = null;
|
||||
Connection connection = null;
|
||||
@@ -242,22 +249,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.SAVE);
|
||||
|
||||
int id = getUserID(connection, profile.getPlayerName(), profile.getUniqueId());
|
||||
int id = getUserID(connection, dataSnapshot.getPlayerName(), dataSnapshot.getPlayerUUID());
|
||||
|
||||
if (id == -1) {
|
||||
id = newUser(connection, profile.getPlayerName(), profile.getUniqueId());
|
||||
if (id == -1) {
|
||||
mcMMO.p.getLogger().severe("Failed to create new account for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (id == -1) {
|
||||
// id = newUser(connection, dataSnapshot.getPlayerName(), dataSnapshot.getPlayerUUID());
|
||||
// if (id == -1) {
|
||||
// mcMMO.p.getLogger().severe("Failed to create new account for " + dataSnapshot.getPlayerName());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET lastlogin = UNIX_TIMESTAMP() WHERE id = ?");
|
||||
statement.setInt(1, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update last login for " + profile.getPlayerName());
|
||||
mcMMO.p.getLogger().severe("Failed to update last login for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -265,29 +272,31 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
|
||||
+ ", fishing = ?, alchemy = ?, total = ? WHERE user_id = ?");
|
||||
statement.setInt(1, profile.getSkillLevel(PrimarySkillType.TAMING));
|
||||
statement.setInt(2, profile.getSkillLevel(PrimarySkillType.MINING));
|
||||
statement.setInt(3, profile.getSkillLevel(PrimarySkillType.REPAIR));
|
||||
statement.setInt(4, profile.getSkillLevel(PrimarySkillType.WOODCUTTING));
|
||||
statement.setInt(5, profile.getSkillLevel(PrimarySkillType.UNARMED));
|
||||
statement.setInt(6, profile.getSkillLevel(PrimarySkillType.HERBALISM));
|
||||
statement.setInt(7, profile.getSkillLevel(PrimarySkillType.EXCAVATION));
|
||||
statement.setInt(8, profile.getSkillLevel(PrimarySkillType.ARCHERY));
|
||||
statement.setInt(9, profile.getSkillLevel(PrimarySkillType.SWORDS));
|
||||
statement.setInt(10, profile.getSkillLevel(PrimarySkillType.AXES));
|
||||
statement.setInt(11, profile.getSkillLevel(PrimarySkillType.ACROBATICS));
|
||||
statement.setInt(12, profile.getSkillLevel(PrimarySkillType.FISHING));
|
||||
statement.setInt(13, profile.getSkillLevel(PrimarySkillType.ALCHEMY));
|
||||
+ ", fishing = ?, alchemy = ?, tridents = ?, crossbows = ?, total = ? WHERE user_id = ?");
|
||||
statement.setInt(1, dataSnapshot.getSkillLevel(PrimarySkillType.TAMING));
|
||||
statement.setInt(2, dataSnapshot.getSkillLevel(PrimarySkillType.MINING));
|
||||
statement.setInt(3, dataSnapshot.getSkillLevel(PrimarySkillType.REPAIR));
|
||||
statement.setInt(4, dataSnapshot.getSkillLevel(PrimarySkillType.WOODCUTTING));
|
||||
statement.setInt(5, dataSnapshot.getSkillLevel(PrimarySkillType.UNARMED));
|
||||
statement.setInt(6, dataSnapshot.getSkillLevel(PrimarySkillType.HERBALISM));
|
||||
statement.setInt(7, dataSnapshot.getSkillLevel(PrimarySkillType.EXCAVATION));
|
||||
statement.setInt(8, dataSnapshot.getSkillLevel(PrimarySkillType.ARCHERY));
|
||||
statement.setInt(9, dataSnapshot.getSkillLevel(PrimarySkillType.SWORDS));
|
||||
statement.setInt(10, dataSnapshot.getSkillLevel(PrimarySkillType.AXES));
|
||||
statement.setInt(11, dataSnapshot.getSkillLevel(PrimarySkillType.ACROBATICS));
|
||||
statement.setInt(12, dataSnapshot.getSkillLevel(PrimarySkillType.FISHING));
|
||||
statement.setInt(13, dataSnapshot.getSkillLevel(PrimarySkillType.ALCHEMY));
|
||||
statement.setInt(14, dataSnapshot.getSkillLevel(PrimarySkillType.TRIDENTS));
|
||||
statement.setInt(15, dataSnapshot.getSkillLevel(PrimarySkillType.CROSSBOWS));
|
||||
int total = 0;
|
||||
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS)
|
||||
total += profile.getSkillLevel(primarySkillType);
|
||||
statement.setInt(14, total);
|
||||
statement.setInt(15, id);
|
||||
for (PrimarySkillType primarySkillType : SkillTools.getNonChildSkills())
|
||||
total += dataSnapshot.getSkillLevel(primarySkillType);
|
||||
statement.setInt(16, total);
|
||||
statement.setInt(17, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update skills for " + profile.getPlayerName());
|
||||
mcMMO.p.getLogger().severe("Failed to update skills for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -295,59 +304,112 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
|
||||
+ ", fishing = ?, alchemy = ? WHERE user_id = ?");
|
||||
statement.setInt(1, profile.getSkillXpLevel(PrimarySkillType.TAMING));
|
||||
statement.setInt(2, profile.getSkillXpLevel(PrimarySkillType.MINING));
|
||||
statement.setInt(3, profile.getSkillXpLevel(PrimarySkillType.REPAIR));
|
||||
statement.setInt(4, profile.getSkillXpLevel(PrimarySkillType.WOODCUTTING));
|
||||
statement.setInt(5, profile.getSkillXpLevel(PrimarySkillType.UNARMED));
|
||||
statement.setInt(6, profile.getSkillXpLevel(PrimarySkillType.HERBALISM));
|
||||
statement.setInt(7, profile.getSkillXpLevel(PrimarySkillType.EXCAVATION));
|
||||
statement.setInt(8, profile.getSkillXpLevel(PrimarySkillType.ARCHERY));
|
||||
statement.setInt(9, profile.getSkillXpLevel(PrimarySkillType.SWORDS));
|
||||
statement.setInt(10, profile.getSkillXpLevel(PrimarySkillType.AXES));
|
||||
statement.setInt(11, profile.getSkillXpLevel(PrimarySkillType.ACROBATICS));
|
||||
statement.setInt(12, profile.getSkillXpLevel(PrimarySkillType.FISHING));
|
||||
statement.setInt(13, profile.getSkillXpLevel(PrimarySkillType.ALCHEMY));
|
||||
statement.setInt(14, id);
|
||||
+ ", fishing = ?, alchemy = ?, tridents = ?, crossbows = ?, WHERE user_id = ?");
|
||||
statement.setInt(1, dataSnapshot.getSkillXpLevel(PrimarySkillType.TAMING));
|
||||
statement.setInt(2, dataSnapshot.getSkillXpLevel(PrimarySkillType.MINING));
|
||||
statement.setInt(3, dataSnapshot.getSkillXpLevel(PrimarySkillType.REPAIR));
|
||||
statement.setInt(4, dataSnapshot.getSkillXpLevel(PrimarySkillType.WOODCUTTING));
|
||||
statement.setInt(5, dataSnapshot.getSkillXpLevel(PrimarySkillType.UNARMED));
|
||||
statement.setInt(6, dataSnapshot.getSkillXpLevel(PrimarySkillType.HERBALISM));
|
||||
statement.setInt(7, dataSnapshot.getSkillXpLevel(PrimarySkillType.EXCAVATION));
|
||||
statement.setInt(8, dataSnapshot.getSkillXpLevel(PrimarySkillType.ARCHERY));
|
||||
statement.setInt(9, dataSnapshot.getSkillXpLevel(PrimarySkillType.SWORDS));
|
||||
statement.setInt(10, dataSnapshot.getSkillXpLevel(PrimarySkillType.AXES));
|
||||
statement.setInt(11, dataSnapshot.getSkillXpLevel(PrimarySkillType.ACROBATICS));
|
||||
statement.setInt(12, dataSnapshot.getSkillXpLevel(PrimarySkillType.FISHING));
|
||||
statement.setInt(13, dataSnapshot.getSkillXpLevel(PrimarySkillType.ALCHEMY));
|
||||
statement.setInt(14, dataSnapshot.getSkillXpLevel(PrimarySkillType.TRIDENTS));
|
||||
statement.setInt(15, dataSnapshot.getSkillXpLevel(PrimarySkillType.CROSSBOWS));
|
||||
statement.setInt(16, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update experience for " + profile.getPlayerName());
|
||||
mcMMO.p.getLogger().severe("Failed to update experience for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
||||
+ ", herbalism = ?, excavation = ?, swords = ?"
|
||||
+ ", axes = ?, blast_mining = ?, chimaera_wing = ? WHERE user_id = ?");
|
||||
statement.setLong(1, profile.getAbilityDATS(SuperAbilityType.SUPER_BREAKER));
|
||||
statement.setLong(2, profile.getAbilityDATS(SuperAbilityType.TREE_FELLER));
|
||||
statement.setLong(3, profile.getAbilityDATS(SuperAbilityType.BERSERK));
|
||||
statement.setLong(4, profile.getAbilityDATS(SuperAbilityType.GREEN_TERRA));
|
||||
statement.setLong(5, profile.getAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER));
|
||||
statement.setLong(6, profile.getAbilityDATS(SuperAbilityType.SERRATED_STRIKES));
|
||||
statement.setLong(7, profile.getAbilityDATS(SuperAbilityType.SKULL_SPLITTER));
|
||||
statement.setLong(8, profile.getAbilityDATS(SuperAbilityType.BLAST_MINING));
|
||||
statement.setLong(9, profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS));
|
||||
statement.setInt(10, id);
|
||||
+ ", axes = ?, blast_mining = ?, chimaera_wing = ?, archery = ?, tridents = ?, crossbows = ? WHERE user_id = ?");
|
||||
statement.setLong(1, dataSnapshot.getAbilityDATS(SuperAbilityType.SUPER_BREAKER));
|
||||
statement.setLong(2, dataSnapshot.getAbilityDATS(SuperAbilityType.TREE_FELLER));
|
||||
statement.setLong(3, dataSnapshot.getAbilityDATS(SuperAbilityType.BERSERK));
|
||||
statement.setLong(4, dataSnapshot.getAbilityDATS(SuperAbilityType.GREEN_TERRA));
|
||||
statement.setLong(5, dataSnapshot.getAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER));
|
||||
statement.setLong(6, dataSnapshot.getAbilityDATS(SuperAbilityType.SERRATED_STRIKES));
|
||||
statement.setLong(7, dataSnapshot.getAbilityDATS(SuperAbilityType.SKULL_SPLITTER));
|
||||
statement.setLong(8, dataSnapshot.getAbilityDATS(SuperAbilityType.BLAST_MINING));
|
||||
statement.setLong(9, dataSnapshot.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS));
|
||||
statement.setLong(10, dataSnapshot.getAbilityDATS(SuperAbilityType.ARCHERY_SUPER));
|
||||
statement.setLong(11, dataSnapshot.getAbilityDATS(SuperAbilityType.TRIDENT_SUPER));
|
||||
statement.setLong(12, dataSnapshot.getAbilityDATS(SuperAbilityType.SUPER_SHOTGUN));
|
||||
statement.setInt(13, id);
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName());
|
||||
mcMMO.p.getLogger().severe("Failed to update cooldowns for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?");
|
||||
statement.setString(1, MobHealthbarType.HEARTS.name());
|
||||
statement.setInt(2, profile.getScoreboardTipsShown());
|
||||
statement.setInt(2, dataSnapshot.getScoreboardTipsShown());
|
||||
statement.setInt(3, id);
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName());
|
||||
mcMMO.p.getLogger().severe("Failed to update hud settings for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
//XP BAR STUFF
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "xpbar SET "
|
||||
+ " view_taming = ?, view_mining = ?, view_repair = ?, view_woodcutting = ?"
|
||||
+ ", view_unarmed = ?, view_herbalism = ?, view_excavation = ?"
|
||||
+ ", view_archery = ?, view_swords = ?, view_axes = ?, view_acrobatics = ?"
|
||||
+ ", view_fishing = ?, view_alchemy = ?, view_salvage = ?, view_smelting = ?, view_tridents = ?, view_crossbows = ? WHERE user_id = ?");
|
||||
statement.setString(1, dataSnapshot.getBarStateMap().get(PrimarySkillType.TAMING).toString());
|
||||
statement.setString(2, dataSnapshot.getBarStateMap().get(PrimarySkillType.MINING).toString());
|
||||
statement.setString(3, dataSnapshot.getBarStateMap().get(PrimarySkillType.REPAIR).toString());
|
||||
statement.setString(4, dataSnapshot.getBarStateMap().get(PrimarySkillType.WOODCUTTING).toString());
|
||||
statement.setString(5, dataSnapshot.getBarStateMap().get(PrimarySkillType.UNARMED).toString());
|
||||
statement.setString(6, dataSnapshot.getBarStateMap().get(PrimarySkillType.HERBALISM).toString());
|
||||
statement.setString(7, dataSnapshot.getBarStateMap().get(PrimarySkillType.EXCAVATION).toString());
|
||||
statement.setString(8, dataSnapshot.getBarStateMap().get(PrimarySkillType.ARCHERY).toString());
|
||||
statement.setString(9, dataSnapshot.getBarStateMap().get(PrimarySkillType.SWORDS).toString());
|
||||
statement.setString(10, dataSnapshot.getBarStateMap().get(PrimarySkillType.AXES).toString());
|
||||
statement.setString(11, dataSnapshot.getBarStateMap().get(PrimarySkillType.ACROBATICS).toString());
|
||||
statement.setString(12, dataSnapshot.getBarStateMap().get(PrimarySkillType.FISHING).toString());
|
||||
statement.setString(13, dataSnapshot.getBarStateMap().get(PrimarySkillType.ALCHEMY).toString());
|
||||
statement.setString(14, dataSnapshot.getBarStateMap().get(PrimarySkillType.SALVAGE).toString());
|
||||
statement.setString(15, dataSnapshot.getBarStateMap().get(PrimarySkillType.SMELTING).toString());
|
||||
statement.setString(16, dataSnapshot.getBarStateMap().get(PrimarySkillType.TRIDENTS).toString());
|
||||
statement.setString(17, dataSnapshot.getBarStateMap().get(PrimarySkillType.CROSSBOWS).toString());
|
||||
statement.setInt(18, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update XP bar views for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//TOGGLES
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "toggle SET "
|
||||
+ " chatspy = ?, rankless = ? WHERE user_id = ?");
|
||||
statement.setBoolean(1, dataSnapshot.getPartyChatSpying());
|
||||
statement.setBoolean(2, dataSnapshot.isLeaderBoardExcluded());
|
||||
statement.setInt(3, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update user toggles for " + dataSnapshot.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
@@ -360,24 +422,26 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return success;
|
||||
}
|
||||
|
||||
public @NotNull List<PlayerStat> readLeaderboard(@Nullable PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException {
|
||||
public @NotNull List<PlayerStat> readLeaderboard(@Nullable PrimarySkillType primarySkillType, int pageNumber, int statsPerPage) throws InvalidSkillException {
|
||||
List<PlayerStat> stats = new ArrayList<>();
|
||||
|
||||
//Fix for a plugin that people are using that is throwing SQL errors
|
||||
if(skill != null && SkillTools.isChildSkill(skill)) {
|
||||
if(primarySkillType != null && SkillTools.isChildSkill(primarySkillType)) {
|
||||
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
|
||||
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
|
||||
}
|
||||
|
||||
|
||||
String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(Locale.ENGLISH);
|
||||
String query = primarySkillType == null ? ALL_QUERY_VERSION : primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement statement = null;
|
||||
Connection connection = null;
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement("SELECT " + query + ", user FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
|
||||
statement = connection.prepareStatement("SELECT " + query + ", user FROM " + tablePrefix + "users JOIN " + tablePrefix
|
||||
+ "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY "
|
||||
+ query + " DESC, user LIMIT ?, ?");
|
||||
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
|
||||
statement.setInt(2, statsPerPage);
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -404,7 +468,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public Map<PrimarySkillType, Integer> readRank(String playerName) {
|
||||
public @NotNull Map<PrimarySkillType, Integer> readRank(@NotNull String playerName) {
|
||||
Map<PrimarySkillType, Integer> skills = new HashMap<>();
|
||||
|
||||
ResultSet resultSet = null;
|
||||
@@ -413,8 +477,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
|
||||
String skillName = primarySkillType.name().toLowerCase(Locale.ENGLISH);
|
||||
for (PrimarySkillType primarySkillType : SkillTools.getNonChildSkills()) {
|
||||
String skillName = primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||
// Get count of all users with higher skill level than player
|
||||
String sql = "SELECT COUNT(*) AS 'rank' FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
@@ -600,13 +664,17 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
throw new RuntimeException("Error looking up player, both UUID and playerName are null and one must not be.");
|
||||
}
|
||||
|
||||
return loadPlayerProfile(null, playerName, uuid);
|
||||
}
|
||||
|
||||
private @Nullable PlayerData loadPlayerProfile(@Nullable Player player, @NotNull String playerName, @Nullable UUID playerUUID) {
|
||||
PreparedStatement statement = null;
|
||||
Connection connection = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.LOAD);
|
||||
int id = getUserID(connection, playerName, uuid);
|
||||
int id = getUserID(connection, playerName, playerUUID);
|
||||
|
||||
if (id == -1) {
|
||||
// There is no such user
|
||||
@@ -615,25 +683,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
// There is such a user
|
||||
writeMissingRows(connection, id);
|
||||
|
||||
statement = connection.prepareStatement(
|
||||
"SELECT "
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid, u.user "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
|
||||
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
|
||||
+ "WHERE u.id = ?");
|
||||
statement = getUserData(connection);
|
||||
statement.setInt(1, id);
|
||||
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
try {
|
||||
PlayerProfile profile = loadFromResult(playerName, resultSet);
|
||||
PlayerData mmoPlayerData = loadFromResult(playerName, resultSet);
|
||||
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
@@ -641,7 +698,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (playerName != null
|
||||
&& !playerName.isEmpty()
|
||||
&& !playerName.equalsIgnoreCase(name)
|
||||
&& uuid != null) {
|
||||
&& playerUUID != null) {
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ? "
|
||||
@@ -655,13 +712,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "SET user = ?, uuid = ? "
|
||||
+ "WHERE id = ?");
|
||||
statement.setString(1, playerName);
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.setString(2, playerUUID.toString());
|
||||
statement.setInt(3, id);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
}
|
||||
|
||||
return profile;
|
||||
return mmoPlayerData;
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
@@ -689,18 +746,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement(
|
||||
"SELECT "
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
|
||||
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
|
||||
+ "WHERE u.user = ?");
|
||||
statement = getUserData(connection);
|
||||
List<String> usernames = getStoredUsers();
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
@@ -709,7 +755,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
resultSet = statement.executeQuery();
|
||||
resultSet.next();
|
||||
destination.saveUser(loadFromResult(playerName, resultSet));
|
||||
//TODO: Optimize, probably needless to make a snapshot here, brain tired
|
||||
PlayerData mmoPlayerData = loadFromResult(playerName, resultSet);
|
||||
MMODataSnapshot mmoDataSnapshot = UserManager.createPlayerDataSnapshot(mmoPlayerData);
|
||||
destination.saveUser(mmoDataSnapshot);
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
@@ -731,7 +780,27 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
}
|
||||
|
||||
public boolean saveUserUUID(String userName, UUID uuid) {
|
||||
private @NotNull PreparedStatement getUserData(@NotNull Connection connection) throws SQLException {
|
||||
return connection.prepareStatement(
|
||||
"SELECT "
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, s.tridents, s.crossbows, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, e.tridents, e.crossbows, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, c.tridents, c.crossbows, "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid "
|
||||
+ "x.view_taming, x.view_mining, x.view_repair, x.view_woodcutting, x.view_unarmed, x.view_herbalism, x.view_excavation, x.view_archery, x.view_swords, x.view_axes, x.view_acrobatics, x.view_salvage, x.view_smelting, x.view_tridents, x.view_crossbows, "
|
||||
+ "t.chatspy, t.rankless, "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
|
||||
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
|
||||
+ "JOIN " + tablePrefix + "xpbar x ON (u.id = x.user_id) "
|
||||
+ "JOIN " + tablePrefix + "toggle t ON (u.id = t.user_id) "
|
||||
+ "WHERE u.user = ?");
|
||||
}
|
||||
|
||||
|
||||
public boolean saveUserUUID(@NotNull String userName, @NotNull UUID uuid) {
|
||||
PreparedStatement statement = null;
|
||||
Connection connection = null;
|
||||
|
||||
@@ -755,47 +824,47 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs) {
|
||||
PreparedStatement statement = null;
|
||||
int count = 0;
|
||||
// public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs) {
|
||||
// PreparedStatement statement = null;
|
||||
// int count = 0;
|
||||
//
|
||||
// Connection connection = null;
|
||||
//
|
||||
// try {
|
||||
// connection = getConnection(PoolIdentifier.MISC);
|
||||
// statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?");
|
||||
//
|
||||
// for (Map.Entry<String, UUID> entry : fetchedUUIDs.entrySet()) {
|
||||
// statement.setString(1, entry.getValue().toString());
|
||||
// statement.setString(2, entry.getKey());
|
||||
//
|
||||
// statement.addBatch();
|
||||
//
|
||||
// count++;
|
||||
//
|
||||
// if ((count % 500) == 0) {
|
||||
// statement.executeBatch();
|
||||
// count = 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (count != 0) {
|
||||
// statement.executeBatch();
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// catch (SQLException ex) {
|
||||
// printErrors(ex);
|
||||
// return false;
|
||||
// }
|
||||
// finally {
|
||||
// tryClose(statement);
|
||||
// tryClose(connection);
|
||||
// }
|
||||
// }
|
||||
|
||||
Connection connection = null;
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?");
|
||||
|
||||
for (Map.Entry<String, UUID> entry : fetchedUUIDs.entrySet()) {
|
||||
statement.setString(1, entry.getValue().toString());
|
||||
statement.setString(2, entry.getKey());
|
||||
|
||||
statement.addBatch();
|
||||
|
||||
count++;
|
||||
|
||||
if ((count % 500) == 0) {
|
||||
statement.executeBatch();
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != 0) {
|
||||
statement.executeBatch();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getStoredUsers() {
|
||||
public @NotNull List<String> getStoredUsers() {
|
||||
ArrayList<String> users = new ArrayList<>();
|
||||
|
||||
Statement statement = null;
|
||||
@@ -887,6 +956,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`chimaera_wing` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`tridents` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`crossbows` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
|
||||
tryClose(createStatement);
|
||||
@@ -901,20 +972,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
createStatement = connection.createStatement();
|
||||
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`total` int(10) unsigned NOT NULL DEFAULT "+totalLevel+","
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`tridents` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`total` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
|
||||
tryClose(createStatement);
|
||||
@@ -940,6 +1013,55 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`tridents` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
tryClose(createStatement);
|
||||
}
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
|
||||
//Toggle Table
|
||||
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "toggle");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
createStatement = connection.createStatement();
|
||||
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "toggle` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`chatspy` bit NOT NULL DEFAULT '0',"
|
||||
+ "`rankless` bit NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
tryClose(createStatement);
|
||||
}
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
|
||||
//XP Bar Table
|
||||
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "xpbar");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
createStatement = connection.createStatement();
|
||||
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "xpbar` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`view_taming` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_mining` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_woodcutting` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_repair` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_unarmed` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_herbalism` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_excavation` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_archery` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_swords` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_axes` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_acrobatics` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_salvage` varchar(40) NOT NULL DEFAULT 'DISABLED',"
|
||||
+ "`view_smelting` varchar(40) NOT NULL DEFAULT 'DISABLED',"
|
||||
+ "`view_tridents` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "`view_crossbows` varchar(40) NOT NULL DEFAULT 'NORMAL',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
|
||||
tryClose(createStatement);
|
||||
@@ -952,10 +1074,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getTruncateSkills()) {
|
||||
for (PrimarySkillType skill : SkillTools.NON_CHILD_SKILLS) {
|
||||
int cap = mcMMO.p.getSkillTools().getLevelCap(skill);
|
||||
for (PrimarySkillType primarySkillType : SkillTools.getNonChildSkills()) {
|
||||
int cap = mcMMO.p.getSkillTools().getLevelCap(primarySkillType);
|
||||
if (cap != Integer.MAX_VALUE) {
|
||||
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `" + skill.name().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
||||
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `"
|
||||
+ primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `"
|
||||
+ primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
||||
statement.executeUpdate();
|
||||
tryClose(statement);
|
||||
}
|
||||
@@ -968,6 +1092,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "huds`.`user_id` = `u`.`id`)");
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "cooldowns` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "cooldowns`.`user_id` = `u`.`id`)");
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "skills` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "skills`.`user_id` = `u`.`id`)");
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "toggle` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "skills`.`user_id` = `u`.`id`)");
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "xpbar` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "skills`.`user_id` = `u`.`id`)");
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
@@ -1007,7 +1133,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
*/
|
||||
private void checkDatabaseStructure(Connection connection, UpgradeType upgrade) {
|
||||
if (!mcMMO.getUpgradeManager().shouldUpgrade(upgrade)) {
|
||||
mcMMO.p.debug("Skipping " + upgrade.name() + " upgrade (unneeded)");
|
||||
mcMMO.p.getLogger().info("Skipping " + upgrade.name() + " upgrade (unneeded)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1048,7 +1174,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
case ADD_UUIDS:
|
||||
checkUpgradeAddUUIDs(statement);
|
||||
return;
|
||||
|
||||
case ADD_SCOREBOARD_TIPS:
|
||||
checkUpgradeAddScoreboardTips(statement);
|
||||
return;
|
||||
@@ -1068,6 +1193,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
updateCharacterSet(statement);
|
||||
break;
|
||||
|
||||
case ADD_SQL_2_2:
|
||||
checkUpgradeAddTridentsAndCrossbowsSQL(statement);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1124,11 +1252,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
UUID uuid;
|
||||
int scoreboardTipsShown;
|
||||
|
||||
final int parentSkills = 15, allSkills = 17, cooldownCount = 17, toggleCount = 2, otherCount = 4;
|
||||
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query
|
||||
// changes (a new skill is added)
|
||||
final int OFFSET_XP = 13;
|
||||
final int OFFSET_DATS = 26;
|
||||
final int OFFSET_OTHER = 39;
|
||||
final int OFFSET_EXPERIENCE = OFFSET_SKILLS + parentSkills;
|
||||
final int OFFSET_COOLDOWNS = OFFSET_EXPERIENCE + parentSkills;
|
||||
final int OFFSET_OTHER = OFFSET_COOLDOWNS + cooldownCount;
|
||||
final int OFFSET_XPBAR = OFFSET_OTHER + otherCount;
|
||||
final int OFFSET_TOGGLE = OFFSET_XPBAR + allSkills;
|
||||
|
||||
skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1));
|
||||
skills.put(PrimarySkillType.MINING, result.getInt(OFFSET_SKILLS + 2));
|
||||
@@ -1143,34 +1274,42 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skills.put(PrimarySkillType.ACROBATICS, result.getInt(OFFSET_SKILLS + 11));
|
||||
skills.put(PrimarySkillType.FISHING, result.getInt(OFFSET_SKILLS + 12));
|
||||
skills.put(PrimarySkillType.ALCHEMY, result.getInt(OFFSET_SKILLS + 13));
|
||||
skills.put(PrimarySkillType.TRIDENTS, result.getInt(OFFSET_SKILLS + 14));
|
||||
skills.put(PrimarySkillType.CROSSBOWS, result.getInt(OFFSET_SKILLS + 15));
|
||||
|
||||
skillsXp.put(PrimarySkillType.TAMING, result.getFloat(OFFSET_XP + 1));
|
||||
skillsXp.put(PrimarySkillType.MINING, result.getFloat(OFFSET_XP + 2));
|
||||
skillsXp.put(PrimarySkillType.REPAIR, result.getFloat(OFFSET_XP + 3));
|
||||
skillsXp.put(PrimarySkillType.WOODCUTTING, result.getFloat(OFFSET_XP + 4));
|
||||
skillsXp.put(PrimarySkillType.UNARMED, result.getFloat(OFFSET_XP + 5));
|
||||
skillsXp.put(PrimarySkillType.HERBALISM, result.getFloat(OFFSET_XP + 6));
|
||||
skillsXp.put(PrimarySkillType.EXCAVATION, result.getFloat(OFFSET_XP + 7));
|
||||
skillsXp.put(PrimarySkillType.ARCHERY, result.getFloat(OFFSET_XP + 8));
|
||||
skillsXp.put(PrimarySkillType.SWORDS, result.getFloat(OFFSET_XP + 9));
|
||||
skillsXp.put(PrimarySkillType.AXES, result.getFloat(OFFSET_XP + 10));
|
||||
skillsXp.put(PrimarySkillType.ACROBATICS, result.getFloat(OFFSET_XP + 11));
|
||||
skillsXp.put(PrimarySkillType.FISHING, result.getFloat(OFFSET_XP + 12));
|
||||
skillsXp.put(PrimarySkillType.ALCHEMY, result.getFloat(OFFSET_XP + 13));
|
||||
skillsXp.put(PrimarySkillType.TAMING, result.getFloat(OFFSET_EXPERIENCE + 1));
|
||||
skillsXp.put(PrimarySkillType.MINING, result.getFloat(OFFSET_EXPERIENCE + 2));
|
||||
skillsXp.put(PrimarySkillType.REPAIR, result.getFloat(OFFSET_EXPERIENCE + 3));
|
||||
skillsXp.put(PrimarySkillType.WOODCUTTING, result.getFloat(OFFSET_EXPERIENCE + 4));
|
||||
skillsXp.put(PrimarySkillType.UNARMED, result.getFloat(OFFSET_EXPERIENCE + 5));
|
||||
skillsXp.put(PrimarySkillType.HERBALISM, result.getFloat(OFFSET_EXPERIENCE + 6));
|
||||
skillsXp.put(PrimarySkillType.EXCAVATION, result.getFloat(OFFSET_EXPERIENCE + 7));
|
||||
skillsXp.put(PrimarySkillType.ARCHERY, result.getFloat(OFFSET_EXPERIENCE + 8));
|
||||
skillsXp.put(PrimarySkillType.SWORDS, result.getFloat(OFFSET_EXPERIENCE + 9));
|
||||
skillsXp.put(PrimarySkillType.AXES, result.getFloat(OFFSET_EXPERIENCE + 10));
|
||||
skillsXp.put(PrimarySkillType.ACROBATICS, result.getFloat(OFFSET_EXPERIENCE + 11));
|
||||
skillsXp.put(PrimarySkillType.FISHING, result.getFloat(OFFSET_EXPERIENCE + 12));
|
||||
skillsXp.put(PrimarySkillType.ALCHEMY, result.getFloat(OFFSET_EXPERIENCE + 13));
|
||||
skillsXp.put(PrimarySkillType.TRIDENTS, result.getFloat(OFFSET_EXPERIENCE + 14));
|
||||
skillsXp.put(PrimarySkillType.CROSSBOWS, result.getFloat(OFFSET_EXPERIENCE + 15));
|
||||
|
||||
// Taming - Unused - result.getInt(OFFSET_DATS + 1)
|
||||
skillsDATS.put(SuperAbilityType.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2));
|
||||
// Repair - Unused - result.getInt(OFFSET_DATS + 3)
|
||||
skillsDATS.put(SuperAbilityType.TREE_FELLER, result.getInt(OFFSET_DATS + 4));
|
||||
skillsDATS.put(SuperAbilityType.BERSERK, result.getInt(OFFSET_DATS + 5));
|
||||
skillsDATS.put(SuperAbilityType.GREEN_TERRA, result.getInt(OFFSET_DATS + 6));
|
||||
skillsDATS.put(SuperAbilityType.GIGA_DRILL_BREAKER, result.getInt(OFFSET_DATS + 7));
|
||||
// Archery - Unused - result.getInt(OFFSET_DATS + 8)
|
||||
skillsDATS.put(SuperAbilityType.SERRATED_STRIKES, result.getInt(OFFSET_DATS + 9));
|
||||
skillsDATS.put(SuperAbilityType.SKULL_SPLITTER, result.getInt(OFFSET_DATS + 10));
|
||||
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
|
||||
skillsDATS.put(SuperAbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
||||
uniqueData.put(UniqueDataType.CHIMAERA_WING_DATS, result.getInt(OFFSET_DATS + 13));
|
||||
// Taming - Unused - result.getInt(OFFSET_COOLDOWNS + 1)
|
||||
skillsDATS.put(SuperAbilityType.SUPER_BREAKER, result.getInt(OFFSET_COOLDOWNS + 2));
|
||||
// Repair - Unused - result.getInt(OFFSET_COOLDOWNS + 3)
|
||||
skillsDATS.put(SuperAbilityType.TREE_FELLER, result.getInt(OFFSET_COOLDOWNS + 4));
|
||||
skillsDATS.put(SuperAbilityType.BERSERK, result.getInt(OFFSET_COOLDOWNS + 5));
|
||||
skillsDATS.put(SuperAbilityType.GREEN_TERRA, result.getInt(OFFSET_COOLDOWNS + 6));
|
||||
skillsDATS.put(SuperAbilityType.GIGA_DRILL_BREAKER, result.getInt(OFFSET_COOLDOWNS + 7));
|
||||
skillsDATS.put(SuperAbilityType.ARCHERY_SUPER, result.getInt(OFFSET_COOLDOWNS + 8));
|
||||
skillsDATS.put(SuperAbilityType.SERRATED_STRIKES, result.getInt(OFFSET_COOLDOWNS + 9));
|
||||
skillsDATS.put(SuperAbilityType.SKULL_SPLITTER, result.getInt(OFFSET_COOLDOWNS + 10));
|
||||
// Acrobatics - Unused - result.getInt(OFFSET_COOLDOWNS + 11)
|
||||
skillsDATS.put(SuperAbilityType.BLAST_MINING, result.getInt(OFFSET_COOLDOWNS + 12));
|
||||
uniqueData.put(UniqueDataType.CHIMAERA_WING_DATS, result.getInt(OFFSET_COOLDOWNS + 13));
|
||||
skillsDATS.put(SuperAbilityType.TRIDENT_SUPER, result.getInt(OFFSET_COOLDOWNS + 14));
|
||||
skillsDATS.put(SuperAbilityType.SUPER_SHOTGUN, result.getInt(OFFSET_COOLDOWNS + 15));
|
||||
|
||||
//
|
||||
|
||||
try {
|
||||
scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);
|
||||
@@ -1183,7 +1322,52 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3));
|
||||
}
|
||||
catch (Exception e) {
|
||||
uuid = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
//XPBAR
|
||||
xpBarStateMap.put(PrimarySkillType.TAMING, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 1)));
|
||||
xpBarStateMap.put(PrimarySkillType.MINING, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 2)));
|
||||
xpBarStateMap.put(PrimarySkillType.REPAIR, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 3)));
|
||||
xpBarStateMap.put(PrimarySkillType.WOODCUTTING, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 4)));
|
||||
xpBarStateMap.put(PrimarySkillType.UNARMED, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 5)));
|
||||
xpBarStateMap.put(PrimarySkillType.HERBALISM, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 6)));
|
||||
xpBarStateMap.put(PrimarySkillType.EXCAVATION, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 7)));
|
||||
xpBarStateMap.put(PrimarySkillType.ARCHERY, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 8)));
|
||||
xpBarStateMap.put(PrimarySkillType.SWORDS, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 9)));
|
||||
xpBarStateMap.put(PrimarySkillType.AXES, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 10)));
|
||||
xpBarStateMap.put(PrimarySkillType.ACROBATICS, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 11)));
|
||||
xpBarStateMap.put(PrimarySkillType.FISHING, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 12)));
|
||||
xpBarStateMap.put(PrimarySkillType.ALCHEMY, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 13)));
|
||||
xpBarStateMap.put(PrimarySkillType.SALVAGE, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 14)));
|
||||
xpBarStateMap.put(PrimarySkillType.SMELTING, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 15)));
|
||||
xpBarStateMap.put(PrimarySkillType.TRIDENTS, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 16)));
|
||||
xpBarStateMap.put(PrimarySkillType.CROSSBOWS, SkillUtils.asBarState(result.getString(OFFSET_XPBAR + 17)));
|
||||
|
||||
//TOGGLE
|
||||
boolean chatSpy = result.getBoolean(OFFSET_TOGGLE+1);
|
||||
boolean rankLess = result.getBoolean(OFFSET_TOGGLE+2);
|
||||
|
||||
//Build
|
||||
MMODataBuilder mmoDataBuilder = new MMODataBuilder();
|
||||
mmoDataBuilder.setSkillLevelValues(skills)
|
||||
.setSkillExperienceValues(skillsXp)
|
||||
.setAbilityDeactivationTimestamps(skillsDATS)
|
||||
.setUniquePlayerData(uniqueData)
|
||||
.setBarStateMap(xpBarStateMap)
|
||||
.setPlayerUUID(uuid)
|
||||
.setPlayerName(playerName)
|
||||
.setPartyChatSpying(chatSpy)
|
||||
.setLastLogin(0) //TODO: Program this in properly
|
||||
.setScoreboardTipsShown(scoreboardTipsShown)
|
||||
.setLeaderBoardExemption(rankLess);
|
||||
|
||||
|
||||
try {
|
||||
return mmoDataBuilder.build();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
return new PlayerProfile(playerName, uuid, skills, skillsXp, skillsDATS, scoreboardTipsShown, uniqueData, null);
|
||||
@@ -1201,7 +1385,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
|
||||
public DatabaseType getDatabaseType() {
|
||||
public @NotNull DatabaseType getDatabaseType() {
|
||||
return DatabaseType.SQL;
|
||||
}
|
||||
|
||||
@@ -1228,6 +1412,23 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddTridentsAndCrossbowsSQL(final Statement statement) throws SQLException {
|
||||
try {
|
||||
statement.executeQuery("SELECT 'tridents' FROM `" + tablePrefix +"cooldowns` LIMIT 1");
|
||||
} catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating SQL DB tables for 2.2 Update....");
|
||||
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `tridents` int(10) NOT NULL DEFAULT '0'");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `crossbows` int(10) NOT NULL DEFAULT '0'");
|
||||
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `tridents` int(10) NOT NULL DEFAULT '0'");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `crossbows` int(10) NOT NULL DEFAULT '0'");
|
||||
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `tridents` int(10) NOT NULL DEFAULT '0'");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `crossbows` int(10) NOT NULL DEFAULT '0'");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddAlchemy(final Statement statement) throws SQLException {
|
||||
try {
|
||||
statement.executeQuery("SELECT `alchemy` FROM `" + tablePrefix + "skills` LIMIT 1");
|
||||
@@ -1303,11 +1504,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet = statement.executeQuery("SHOW INDEX FROM `" + tablePrefix + "skills` WHERE `Key_name` LIKE 'idx\\_%'");
|
||||
resultSet.last();
|
||||
|
||||
if (resultSet.getRow() != SkillTools.NON_CHILD_SKILLS.size()) {
|
||||
if (resultSet.getRow() != SkillTools.getNonChildSkills().size()) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
|
||||
for (PrimarySkillType skill : SkillTools.NON_CHILD_SKILLS) {
|
||||
String skill_name = skill.name().toLowerCase(Locale.ENGLISH);
|
||||
for (PrimarySkillType primarySkillType : SkillTools.getNonChildSkills()) {
|
||||
String skill_name = primarySkillType.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
try {
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_" + skill_name + "` (`" + skill_name + "`) USING BTREE");
|
||||
@@ -1571,7 +1772,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
mcMMO.p.debug("Releasing connection pool resource...");
|
||||
mcMMO.p.getLogger().info("Releasing connection pool resource...");
|
||||
miscPool.close();
|
||||
loadPool.close();
|
||||
savePool.close();
|
||||
@@ -1664,4 +1865,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
" CHARACTER SET utf8mb4\n" +
|
||||
" COLLATE utf8mb4_unicode_ci;";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCache(@NotNull UUID uuid) {
|
||||
cachedUserIDs.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum MobHealthbarType {
|
||||
HEARTS,
|
||||
BAR,
|
||||
DISABLED
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public enum UpgradeType {
|
||||
DROP_NAME_UNIQUENESS,
|
||||
ADD_SKILL_TOTAL,
|
||||
ADD_UNIQUE_PLAYER_DATA,
|
||||
ADD_SQL_2_2,
|
||||
FIX_SPELLING_NETHERITE_SALVAGE,
|
||||
FIX_SPELLING_NETHERITE_REPAIR,
|
||||
FIX_NETHERITE_SALVAGE_QUANTITIES,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
import com.neetgames.mcmmo.experience.ExperienceProcessor;
|
||||
|
||||
//TODO: T&C Write implementation, this should be the exact same way OnlineExperienceProcessor handles stuff but without sending player messages or sounds and stuff like that
|
||||
//TODO: Is this needed? Maybe just make OnlineExperienceProcessor handle both in a clean way
|
||||
public class OfflineExperienceProcessor implements ExperienceProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerData;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.experience.ExperienceUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.neetgames.mcmmo.exceptions.UnknownSkillException;
|
||||
import com.neetgames.mcmmo.experience.ExperienceProcessor;
|
||||
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||
import com.neetgames.mcmmo.experience.XPGainSource;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class OnlineExperienceProcessor implements ExperienceProcessor {
|
||||
|
||||
private boolean isUsingUnarmed = false; //Gross but it works
|
||||
|
||||
private final @NotNull Player playerRef;
|
||||
private final @NotNull PlayerData mmoPlayerData;
|
||||
|
||||
public OnlineExperienceProcessor(@NotNull Player playerRef, @NotNull PlayerData playerData) {
|
||||
this.playerRef = playerRef;
|
||||
this.mmoPlayerData = playerData;
|
||||
}
|
||||
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
Map<PrimarySkillType, Integer> primarySkillTypeLevelMap = mmoPlayerData.getSkillLevelMap();
|
||||
|
||||
for (PrimarySkillType primarySkillType : primarySkillTypeLevelMap.keySet()) {
|
||||
powerLevel += primarySkillTypeLevelMap.get(primarySkillType);
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
public float getSkillXpLevelRaw(@NotNull PrimarySkillType primarySkillType) {
|
||||
return mmoPlayerData.getSkillsExperienceMap().get(primarySkillType);
|
||||
}
|
||||
|
||||
public int getSkillXpValue(@NotNull PrimarySkillType primarySkillType) {
|
||||
if(primarySkillType.isChildSkill()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.floor(getSkillXpLevelRaw(primarySkillType));
|
||||
}
|
||||
|
||||
public void setSkillXpValue(@NotNull PrimarySkillType primarySkillType, float xpLevel) {
|
||||
if (primarySkillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mmoPlayerData.getSkillsExperienceMap().put(primarySkillType, xpLevel);
|
||||
}
|
||||
|
||||
public float levelUp(@NotNull PrimarySkillType primarySkillType) {
|
||||
float xpRemoved = getExperienceToNextLevel(primarySkillType);
|
||||
|
||||
setSkillLevel(primarySkillType, getSkillLevel(primarySkillType) + 1);
|
||||
setSkillXpValue(primarySkillType, getSkillXpValue(primarySkillType) - xpRemoved);
|
||||
|
||||
return xpRemoved;
|
||||
}
|
||||
|
||||
public boolean hasReachedLevelCap(@NotNull PrimarySkillType primarySkillType) {
|
||||
if(hasReachedPowerLevelCap())
|
||||
return true;
|
||||
|
||||
return getSkillLevel(primarySkillType) >= Config.getInstance().getLevelCap(primarySkillType);
|
||||
}
|
||||
|
||||
public boolean hasReachedPowerLevelCap() {
|
||||
return this.getPowerLevel() >= Config.getInstance().getPowerLevelCap();
|
||||
}
|
||||
|
||||
public void beginXpGain(@NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||
if (xp <= 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||
Set<RootSkill> parentSkills = FamilyTree.getParentSkills(primarySkillType);
|
||||
float splitXp = xp / parentSkills.size();
|
||||
|
||||
for (RootSkill parentSkill : parentSkills) {
|
||||
beginXpGain(parentSkill, splitXp, xpGainReason, xpGainSource);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: The logic here is so stupid... rewrite later
|
||||
|
||||
// Return if the experience has been shared
|
||||
if (mmoPlayer.getParty() != null && ShareHandler.handleXpShare(xp, mmoPlayer, mmoPlayer.getParty(), primarySkillType, ShareHandler.getSharedXpGainReason(xpGainReason))) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginUnsharedXpGain(primarySkillType, xp, xpGainReason, xpGainSource);
|
||||
}
|
||||
|
||||
public void beginUnsharedXpGain(@NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||
if(Misc.adaptPlayer(mmoPlayer).getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
ExperienceUtils.applyXpGain(mmoPlayer, primarySkillType, modifyXpGain(primarySkillType, xp), xpGainReason, xpGainSource);
|
||||
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
if (!Config.getInstance().getPartyXpNearMembersNeeded() || !mcMMO.getPartyManager().getNearMembers(mmoPlayer).isEmpty()) {
|
||||
party.getPartyExperienceManager().applyXpGain(modifyXpGain(primarySkillType, xp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||
return PrimarySkillType.isChildSkill(primarySkillType) ? getChildSkillLevel(primarySkillType) : getSkillLevel(primarySkillType);
|
||||
}
|
||||
|
||||
public int getExperienceToNextLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||
if(PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? getPowerLevel() : getSkillLevel(primarySkillType);
|
||||
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
|
||||
|
||||
return mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType);
|
||||
}
|
||||
|
||||
public int getChildSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||
Set<RootSkill> parents = FamilyTree.getParentSkills(primarySkillType);
|
||||
int sum = 0;
|
||||
|
||||
for (RootSkill parentIdentity : parents) {
|
||||
sum += getSkillLevel(parentIdentity);
|
||||
}
|
||||
|
||||
return sum / parents.size();
|
||||
}
|
||||
|
||||
public void removeXp(@NotNull PrimarySkillType skill, int xp) {
|
||||
if (skill.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSkillXpValue(skill, getSkillXpValue(skill) - xp);
|
||||
}
|
||||
|
||||
public void removeXp(PrimarySkillType skill, float xp) {
|
||||
if (skill.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSkillXpValue(skill, getSkillXpValue(skill) - xp);
|
||||
}
|
||||
|
||||
public void setSkillLevel(@NotNull PrimarySkillType primarySkillType, int level) {
|
||||
if (primarySkillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Don't allow levels to be negative
|
||||
if(level < 0)
|
||||
level = 0;
|
||||
|
||||
setSkillLevel(primarySkillType, level);
|
||||
setSkillXpValue(primarySkillType, 0F);
|
||||
}
|
||||
|
||||
public void addLevels(@NotNull PrimarySkillType primarySkillType, int levels) {
|
||||
setSkillLevel(primarySkillType, getSkillLevel(primarySkillType) + levels);
|
||||
}
|
||||
|
||||
public void addXp(@NotNull PrimarySkillType primarySkillType, float xp) {
|
||||
if (primarySkillType.isChildSkill()) {
|
||||
Set<RootSkill> parentSkills = FamilyTree.getParents(primarySkillType);
|
||||
float dividedXP = (xp / parentSkills.size());
|
||||
|
||||
for (RootSkill parentSkill : parentSkills) {
|
||||
setSkillXpValue(parentSkill, getSkillXpValue(parentSkill) + dividedXP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setSkillXpValue(primarySkillType, getSkillXpValue(primarySkillType) + xp);
|
||||
}
|
||||
}
|
||||
|
||||
public float getRegisteredXpGain(@NotNull PrimarySkillType primarySkillType) {
|
||||
float xp = 0F;
|
||||
|
||||
if (get(primarySkillType) != null) { //??
|
||||
xp = rollingSkillsXp.get(primarySkillType);
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
||||
public void registerXpGain(@NotNull PrimarySkillType primarySkillType, float xp) {
|
||||
gainedSkillsXp.add(new SkillXpGain(primarySkillType, xp));
|
||||
rollingSkillsXp.put(primarySkillType, getRegisteredXpGain(primarySkillType) + xp);
|
||||
}
|
||||
|
||||
public void purgeExpiredXpGains() {
|
||||
SkillXpGain gain;
|
||||
while ((gain = gainedSkillsXp.poll()) != null) {
|
||||
rollingSkillsXp.put(gain.getSkill(), getRegisteredXpGain(gain.getSkill()) - gain.getXp());
|
||||
}
|
||||
}
|
||||
|
||||
private float modifyXpGain(@NotNull PrimarySkillType primarySkillType, float xp) {
|
||||
if ((primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
xp = (float) (xp / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
|
||||
return PerksUtils.handleXpPerks(Misc.adaptPlayer(mmoPlayer), xp, primarySkillType);
|
||||
}
|
||||
|
||||
public double getProgressInCurrentSkillLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException
|
||||
{
|
||||
if(PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||
return 1.0D;
|
||||
}
|
||||
|
||||
double currentXP = getSkillXpValue(primarySkillType);
|
||||
double maxXP = getExperienceToNextLevel(primarySkillType);
|
||||
|
||||
return (currentXP / maxXP);
|
||||
}
|
||||
|
||||
public void setUsingUnarmed(boolean bool) {
|
||||
isUsingUnarmed = bool;
|
||||
}
|
||||
|
||||
public void applyXpGain(@NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||
//Only check for permissions if the player is online, otherwise just assume a command is being executed by an admin or some other means and add the XP
|
||||
if (!Permissions.skillEnabled(mmoPlayer.getPlayer(), PrimarySkillType.getSkill(primarySkillType))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PrimarySkillType.isChildSkill(primarySkillType)) {
|
||||
Set<RootSkill> parentSkills = FamilyTree.getParentSkills(primarySkillType);
|
||||
|
||||
for (RootSkill parentSkill : parentSkills) {
|
||||
applyXpGain(parentSkill, xp / parentSkills.size(), xpGainReason, xpGainSource);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EventUtils.handleXpGainEvent(Misc.adaptPlayer(mmoPlayer), primarySkillType, xp, xpGainReason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setUsingUnarmed(primarySkillType == PrimarySkillType.UNARMED);
|
||||
updateLevelStats(primarySkillType, xpGainReason, xpGainSource);
|
||||
}
|
||||
|
||||
public void processPostXpEvent(@NotNull PrimarySkillType primarySkillType, @NotNull XPGainSource xpGainSource)
|
||||
{
|
||||
/*
|
||||
* Everything in this method requires an online player, so if they aren't online we don't waste our time
|
||||
*/
|
||||
if(mmoPlayer == null)
|
||||
return;
|
||||
|
||||
//Check if they've reached the power level cap just now
|
||||
if(hasReachedPowerLevelCap()) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.PowerLevel", String.valueOf(Config.getInstance().getPowerLevelCap()));
|
||||
} else if(hasReachedLevelCap(primarySkillType)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.Skill", String.valueOf(Config.getInstance().getLevelCap(primarySkillType)), primarySkillType.getRawSkillName());
|
||||
}
|
||||
|
||||
//Updates from Party sources
|
||||
if(xpGainSource == XPGainSource.PARTY_MEMBERS && !ExperienceConfig.getInstance().isPartyExperienceBarsEnabled())
|
||||
return;
|
||||
|
||||
//Updates from passive sources (Alchemy, Smelting, etc...)
|
||||
if(xpGainSource == XPGainSource.PASSIVE && !ExperienceConfig.getInstance().isPassiveGainsExperienceBarsEnabled())
|
||||
return;
|
||||
|
||||
mmoPlayer.updateXPBar(primarySkillType);
|
||||
}
|
||||
|
||||
public void updateLevelStats(@NotNull PrimarySkillType primarySkillType, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
|
||||
if(hasReachedLevelCap(primarySkillType))
|
||||
return;
|
||||
|
||||
if (getSkillXpLevelRaw(primarySkillType) < getExperienceToNextLevel(primarySkillType)) {
|
||||
processPostXpEvent(primarySkillType, xpGainSource);
|
||||
return;
|
||||
}
|
||||
|
||||
int levelsGained = 0;
|
||||
float xpRemoved = 0;
|
||||
|
||||
while (getSkillXpLevelRaw(primarySkillType) >= getExperienceToNextLevel(primarySkillType)) {
|
||||
if (hasReachedLevelCap(primarySkillType)) {
|
||||
setSkillXpValue(primarySkillType, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
xpRemoved += levelUp(primarySkillType);
|
||||
levelsGained++;
|
||||
}
|
||||
|
||||
if (EventUtils.tryLevelChangeEvent(Misc.adaptPlayer(mmoPlayer), primarySkillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getLevelUpSoundsEnabled()) {
|
||||
SoundManager.sendSound(Misc.adaptPlayer(mmoPlayer), Misc.adaptPlayer(mmoPlayer).getLocation(), SoundType.LEVEL_UP);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if the player unlocked any new skills
|
||||
*/
|
||||
|
||||
NotificationManager.sendPlayerLevelUpNotification(mmoPlayer, primarySkillType, levelsGained, getSkillLevel(primarySkillType));
|
||||
|
||||
//UPDATE XP BARS
|
||||
processPostXpEvent(primarySkillType, xpGainSource);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
public enum XPGainReason {
|
||||
PVP,
|
||||
PVE,
|
||||
VAMPIRISM,
|
||||
SHARED_PVP,
|
||||
SHARED_PVE,
|
||||
COMMAND,
|
||||
UNKNOWN;
|
||||
|
||||
public static XPGainReason getXPGainReason(String reason) {
|
||||
for (XPGainReason type : values()) {
|
||||
if (type.name().equalsIgnoreCase(reason)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
public enum XPGainSource {
|
||||
SELF,
|
||||
VAMPIRISM, //From Vampirism kills
|
||||
PASSIVE, //Smelting, Brewing, etc...
|
||||
PARTY_MEMBERS, //From other members of a party
|
||||
COMMAND,
|
||||
CUSTOM, //Outside Sources
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gmail.nossr50.datatypes.meta;
|
||||
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ProjectileOriginMeta extends FixedMetadataValue {
|
||||
/**
|
||||
* Initializes a FixedMetadataValue with an Object
|
||||
*
|
||||
* @param owningPlugin the {@link Plugin} that created this metadata value
|
||||
* @param value the value assigned to this metadata value
|
||||
*/
|
||||
public ProjectileOriginMeta(@NotNull Plugin owningPlugin, int value) {
|
||||
super(owningPlugin, value);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum ItemShareType {
|
||||
LOOT,
|
||||
MINING,
|
||||
HERBALISM,
|
||||
WOODCUTTING,
|
||||
MISC;
|
||||
|
||||
public static ItemShareType getShareType(ItemStack itemStack) {
|
||||
if (ItemUtils.isMobDrop(itemStack)) {
|
||||
return LOOT;
|
||||
}
|
||||
else if (ItemUtils.isMiningDrop(itemStack)) {
|
||||
return MINING;
|
||||
}
|
||||
else if (ItemUtils.isHerbalismDrop(itemStack)) {
|
||||
return HERBALISM;
|
||||
}
|
||||
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
|
||||
return WOODCUTTING;
|
||||
}
|
||||
else if (ItemUtils.isMiscDrop(itemStack)) {
|
||||
return MISC;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLocaleString() {
|
||||
return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyLeader {
|
||||
private final UUID uuid;
|
||||
private final String playerName;
|
||||
|
||||
public PartyLeader(UUID uuid, String playerName) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public enum ShareMode {
|
||||
NONE,
|
||||
EQUAL,
|
||||
RANDOM;
|
||||
|
||||
public static ShareMode getShareMode(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (string.equalsIgnoreCase("even")) {
|
||||
return EQUAL;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(string)) {
|
||||
return NONE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.OfflineExperienceProcessor;
|
||||
import com.gmail.nossr50.datatypes.experience.OnlineExperienceProcessor;
|
||||
import com.neetgames.mcmmo.experience.ExperienceProcessor;
|
||||
import com.neetgames.mcmmo.player.MMOPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class AbstractMMOPlayer implements MMOPlayer {
|
||||
/* All of the persistent data for a player that gets saved and loaded from DB */
|
||||
protected final @NotNull PlayerData playerData; //All persistent data is kept here
|
||||
protected @Nullable Player player = null;
|
||||
|
||||
/* Managers */
|
||||
protected final @Nullable ExperienceProcessor experienceProcessor;
|
||||
protected final @NotNull CooldownManager cooldownManager;
|
||||
protected boolean isLoaded;
|
||||
|
||||
/**
|
||||
* Init for online players
|
||||
* This will be used for existing data
|
||||
*
|
||||
* @param playerData player data
|
||||
*/
|
||||
public AbstractMMOPlayer(@Nullable Player player, @NotNull PlayerData playerData, boolean isLoaded) {
|
||||
this.playerData = playerData;
|
||||
|
||||
if(player != null)
|
||||
this.player = player;
|
||||
|
||||
this.isLoaded = isLoaded;
|
||||
|
||||
if(isLoaded) {
|
||||
if(player != null && player.isOnline()) {
|
||||
//Online Player
|
||||
this.experienceProcessor = new OnlineExperienceProcessor(player, playerData);
|
||||
} else {
|
||||
//Offline Player
|
||||
this.experienceProcessor = new OfflineExperienceProcessor(player, playerData);
|
||||
}
|
||||
} else {
|
||||
//Invalid Player (no loaded data) so experience operations are pointless
|
||||
this.experienceProcessor = null;
|
||||
}
|
||||
|
||||
this.cooldownManager = new CooldownManager(playerData);
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
public void setLoaded(boolean loaded) {
|
||||
isLoaded = loaded;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.neetgames.mcmmo.UniqueDataType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CooldownManager {
|
||||
private final @NotNull PlayerData playerDataRef;
|
||||
|
||||
public CooldownManager(@NotNull PlayerData playerDataRef) {
|
||||
this.playerDataRef = playerDataRef;
|
||||
}
|
||||
|
||||
/*
|
||||
* Teleportation cooldown & warmup
|
||||
*/
|
||||
|
||||
public int getChimeraWingLastUse() {
|
||||
return (int) playerDataRef.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS);
|
||||
}
|
||||
|
||||
public void actualizeChimeraWingLastUse() {
|
||||
playerDataRef.setChimaeraWingDATS((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR));
|
||||
}
|
||||
|
||||
public @Nullable Location getTeleportCommenceLocation() {
|
||||
return teleportCommence;
|
||||
}
|
||||
|
||||
public void setTeleportCommenceLocation(Location location) {
|
||||
teleportCommence = location;
|
||||
}
|
||||
|
||||
public void actualizeTeleportCommenceLocation(Player player) {
|
||||
teleportCommence = player.getLocation();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.neetgames.mcmmo.UniqueDataType;
|
||||
import com.neetgames.mcmmo.exceptions.UnexpectedValueException;
|
||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||
import org.apache.commons.lang.NullArgumentException;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MMODataBuilder {
|
||||
|
||||
/* Player Stuff */
|
||||
private @Nullable String playerName;
|
||||
private @Nullable UUID playerUUID;
|
||||
|
||||
/* Records */
|
||||
private long lastLogin;
|
||||
|
||||
/* Skill Data */
|
||||
private @Nullable Map<PrimarySkillType, Integer> skillLevelValues;
|
||||
private @Nullable Map<PrimarySkillType, Float> skillExperienceValues;
|
||||
private @Nullable Map<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
||||
private @Nullable Map<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
private @Nullable Map<PrimarySkillType, SkillBossBarState> barStateMap;
|
||||
|
||||
/* Special Flags */
|
||||
private boolean partyChatSpying;
|
||||
private boolean leaderBoardExemption = false;
|
||||
|
||||
/* Scoreboards */
|
||||
private int scoreboardTipsShown;
|
||||
|
||||
public @NotNull PlayerData buildNewPlayerData(@NotNull Player player) {
|
||||
/*
|
||||
* New Profile with default values
|
||||
*/
|
||||
return buildNewPlayerData(player.getUniqueId(), player.getName());
|
||||
}
|
||||
|
||||
public @Nullable PlayerData buildNewPlayerData(@NotNull OfflinePlayer offlinePlayer) {
|
||||
if(offlinePlayer.getName() != null)
|
||||
return buildNewPlayerData(offlinePlayer.getUniqueId(), offlinePlayer.getName());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public @NotNull PlayerData buildNewPlayerData(@Nullable UUID playerUUID, @NotNull String playerName) {
|
||||
/*
|
||||
* New Profile with default values
|
||||
*/
|
||||
return new PlayerData(playerUUID, playerName);
|
||||
}
|
||||
|
||||
public PlayerData build() throws UnexpectedValueException, NullPointerException, NullArgumentException {
|
||||
if(playerUUID == null)
|
||||
throw new NullArgumentException("playerUUID");
|
||||
|
||||
if(playerName == null)
|
||||
throw new NullArgumentException("player name");
|
||||
|
||||
if(skillLevelValues == null)
|
||||
throw new NullArgumentException("skillLevelValues");
|
||||
|
||||
validateSkillLevelMapEntries(skillLevelValues);
|
||||
|
||||
if(skillExperienceValues == null)
|
||||
throw new NullArgumentException("skillExperienceValues");
|
||||
|
||||
validateExperienceValueMapEntries(skillExperienceValues);
|
||||
|
||||
if(abilityDeactivationTimestamps == null)
|
||||
throw new NullArgumentException("abilityDeactivationTimestamps");
|
||||
|
||||
validateAbilityCooldownMapEntries(abilityDeactivationTimestamps);
|
||||
|
||||
if(uniquePlayerData == null)
|
||||
throw new NullArgumentException("uniquePlayerData");
|
||||
|
||||
validateUniquePlayerDataMapEntries(uniquePlayerData);
|
||||
|
||||
if(barStateMap == null)
|
||||
throw new NullArgumentException("barStateMap");
|
||||
|
||||
validateBarStateMapEntries(barStateMap);
|
||||
|
||||
return new PlayerData(playerUUID, playerName, partyChatSpying, skillLevelValues,
|
||||
skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData,
|
||||
barStateMap, scoreboardTipsShown, lastLogin, leaderBoardExemption);
|
||||
}
|
||||
|
||||
private void validateBarStateMapEntries(@NotNull Map<PrimarySkillType, SkillBossBarState> map) {
|
||||
Map<PrimarySkillType, SkillBossBarState> barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap();
|
||||
|
||||
for(PrimarySkillType key : PrimarySkillType.values()) {
|
||||
map.putIfAbsent(key, barMapDefaults.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
private void validateExperienceValueMapEntries(@NotNull Map<PrimarySkillType, Float> map) {
|
||||
for(PrimarySkillType key : PrimarySkillType.values()) {
|
||||
if(key.isChildSkill())
|
||||
continue;
|
||||
|
||||
map.putIfAbsent(key, 0F);
|
||||
|
||||
if(map.get(key) < 0F) {
|
||||
mcMMO.p.getLogger().severe("found negative value for map entry of " + key.toString() + " for player " + playerName + " , resetting to 0");
|
||||
map.put(key, 0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateUniquePlayerDataMapEntries(@NotNull Map<UniqueDataType, Integer> map) {
|
||||
for(UniqueDataType key : UniqueDataType.values()) {
|
||||
map.putIfAbsent(key, 0);
|
||||
|
||||
if(map.get(key) < 0) {
|
||||
mcMMO.p.getLogger().severe("found negative value for map entry of " + key.toString() + " for player " + playerName + " , resetting to 0");
|
||||
map.put(key, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateAbilityCooldownMapEntries(@NotNull Map<SuperAbilityType, Integer> map) {
|
||||
for(SuperAbilityType key : SuperAbilityType.values()) {
|
||||
map.putIfAbsent(key, 0);
|
||||
|
||||
if(map.get(key) < 0) {
|
||||
mcMMO.p.getLogger().severe("found negative value for map entry of " + key.toString() + " for player " + playerName + " , resetting to 0");
|
||||
map.put(key, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSkillLevelMapEntries(@NotNull Map<PrimarySkillType, Integer> map) {
|
||||
for(PrimarySkillType key : PrimarySkillType.values()) {
|
||||
|
||||
if(key.isChildSkill())
|
||||
continue;
|
||||
|
||||
map.putIfAbsent(key, 0);
|
||||
|
||||
if(map.get(key) < 0) {
|
||||
mcMMO.p.getLogger().severe("found negative value for map entry of " + key.toString() + " for player " + playerName + " , resetting to 0");
|
||||
map.put(key, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setPlayerName(@NotNull String playerName) {
|
||||
this.playerName = playerName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setPlayerUUID(@NotNull UUID playerUUID) {
|
||||
this.playerUUID = playerUUID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setLastLogin(long lastLogin) {
|
||||
this.lastLogin = lastLogin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Map<PrimarySkillType, Integer> getSkillLevelValues() {
|
||||
return skillLevelValues;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setSkillLevelValues(@NotNull Map<PrimarySkillType, Integer> skillLevelValues) {
|
||||
this.skillLevelValues = skillLevelValues;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Map<PrimarySkillType, Float> getSkillExperienceValues() {
|
||||
return skillExperienceValues;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setSkillExperienceValues(@NotNull Map<PrimarySkillType, Float> skillExperienceValues) {
|
||||
this.skillExperienceValues = skillExperienceValues;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Map<SuperAbilityType, Integer> getAbilityDeactivationTimestamps() {
|
||||
return abilityDeactivationTimestamps;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setAbilityDeactivationTimestamps(@NotNull Map<SuperAbilityType, Integer> abilityDeactivationTimestamps) {
|
||||
this.abilityDeactivationTimestamps = abilityDeactivationTimestamps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Map<UniqueDataType, Integer> getUniquePlayerData() {
|
||||
return uniquePlayerData;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setUniquePlayerData(@NotNull Map<UniqueDataType, Integer> uniquePlayerData) {
|
||||
this.uniquePlayerData = uniquePlayerData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @Nullable Map<PrimarySkillType, SkillBossBarState> getBarStateMap() {
|
||||
return barStateMap;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setBarStateMap(@NotNull Map<PrimarySkillType, SkillBossBarState> barStateMap) {
|
||||
this.barStateMap = barStateMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setPartyChatSpying(boolean partyChatSpying) {
|
||||
this.partyChatSpying = partyChatSpying;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getScoreboardTipsShown() {
|
||||
return scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public @NotNull MMODataBuilder setScoreboardTipsShown(int scoreboardTipsShown) {
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPartyChatSpying() {
|
||||
return partyChatSpying;
|
||||
}
|
||||
|
||||
public void setLeaderBoardExemption(boolean bool) {
|
||||
leaderBoardExemption = bool;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.neetgames.mcmmo.UniqueDataType;
|
||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MMODataSnapshot {
|
||||
/* Save Attempts */
|
||||
private int saveAttempts = 0;
|
||||
|
||||
/* Player Stuff */
|
||||
private final @NotNull String playerName;
|
||||
private final @NotNull UUID playerUUID;
|
||||
|
||||
/* Records */
|
||||
private final long lastLogin;
|
||||
|
||||
/* Skill Data */
|
||||
private final @NotNull ImmutableMap<PrimarySkillType, Integer> skillLevelValues;
|
||||
private final @NotNull ImmutableMap<PrimarySkillType, Float> skillExperienceValues;
|
||||
private final @NotNull ImmutableMap<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
||||
private final @NotNull ImmutableMap<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
private final @NotNull ImmutableMap<PrimarySkillType, SkillBossBarState> barStateMap;
|
||||
|
||||
/* Special Flags */
|
||||
private final boolean partyChatSpying;
|
||||
private final boolean leaderBoardExclusion;
|
||||
|
||||
/* Scoreboards */
|
||||
private final int scoreboardTipsShown;
|
||||
|
||||
|
||||
public MMODataSnapshot(@NotNull PlayerData mmoPlayerData) {
|
||||
playerName = mmoPlayerData.getPlayerName();
|
||||
playerUUID = mmoPlayerData.getPlayerUUID();
|
||||
lastLogin = mmoPlayerData.getLastLogin();
|
||||
|
||||
skillLevelValues = ImmutableMap.copyOf(mmoPlayerData.getSkillLevelsMap());
|
||||
skillExperienceValues = ImmutableMap.copyOf(mmoPlayerData.getSkillsExperienceMap());
|
||||
abilityDeactivationTimestamps = ImmutableMap.copyOf(mmoPlayerData.getAbilityDeactivationTimestamps());
|
||||
uniquePlayerData = ImmutableMap.copyOf(mmoPlayerData.getUniquePlayerData());
|
||||
barStateMap = ImmutableMap.copyOf(mmoPlayerData.getBarStateMap());
|
||||
|
||||
partyChatSpying = mmoPlayerData.isPartyChatSpying();
|
||||
leaderBoardExclusion = mmoPlayerData.isLeaderBoardExcluded();
|
||||
|
||||
scoreboardTipsShown = mmoPlayerData.getScoreboardTipsShown();
|
||||
}
|
||||
|
||||
public @NotNull String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public @NotNull UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public @NotNull Long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
|
||||
public @NotNull ImmutableMap<PrimarySkillType, Integer> getSkillLevelValues() {
|
||||
return skillLevelValues;
|
||||
}
|
||||
|
||||
public @NotNull ImmutableMap<PrimarySkillType, Float> getSkillExperienceValues() {
|
||||
return skillExperienceValues;
|
||||
}
|
||||
|
||||
public @NotNull ImmutableMap<SuperAbilityType, Integer> getAbilityDeactivationTimestamps() {
|
||||
return abilityDeactivationTimestamps;
|
||||
}
|
||||
|
||||
public @NotNull ImmutableMap<UniqueDataType, Integer> getUniquePlayerData() {
|
||||
return uniquePlayerData;
|
||||
}
|
||||
|
||||
public @NotNull ImmutableMap<PrimarySkillType, SkillBossBarState> getBarStateMap() {
|
||||
return barStateMap;
|
||||
}
|
||||
|
||||
public @NotNull Boolean getPartyChatSpying() {
|
||||
return partyChatSpying;
|
||||
}
|
||||
|
||||
public @NotNull Integer getScoreboardTipsShown() {
|
||||
return scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||
return skillLevelValues.getOrDefault(primarySkillType, 0);
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||
return (skillExperienceValues.getOrDefault(primarySkillType, 0F)).intValue();
|
||||
}
|
||||
|
||||
public long getAbilityDATS(@NotNull SuperAbilityType superAbilityType) {
|
||||
return abilityDeactivationTimestamps.getOrDefault(superAbilityType, 0);
|
||||
}
|
||||
|
||||
public long getUniqueData(@NotNull UniqueDataType uniqueDataType) {
|
||||
return uniquePlayerData.getOrDefault(uniqueDataType, 0);
|
||||
}
|
||||
|
||||
public boolean isLeaderBoardExcluded() {
|
||||
return leaderBoardExclusion;
|
||||
}
|
||||
|
||||
public int getSaveAttempts() {
|
||||
return saveAttempts;
|
||||
}
|
||||
|
||||
public void setSaveAttempts(int saveAttempts) {
|
||||
this.saveAttempts = saveAttempts;
|
||||
}
|
||||
|
||||
public void incrementSaveAttempts() {
|
||||
this.saveAttempts += 1;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
345
src/main/java/com/gmail/nossr50/datatypes/player/PlayerData.java
Normal file
345
src/main/java/com/gmail/nossr50/datatypes/player/PlayerData.java
Normal file
@@ -0,0 +1,345 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.validation.NonNullRule;
|
||||
import com.gmail.nossr50.datatypes.validation.PositiveIntegerRule;
|
||||
import com.gmail.nossr50.datatypes.validation.Validator;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.neetgames.mcmmo.UniqueDataType;
|
||||
import com.neetgames.mcmmo.exceptions.UnexpectedValueException;
|
||||
import com.neetgames.mcmmo.skill.SkillBossBarState;
|
||||
import org.apache.commons.lang.NullArgumentException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
/* Player Stuff */
|
||||
private @NotNull String playerName;
|
||||
private final @Nullable UUID playerUUID; //TODO: T&C See if this is ever actually null, and if it is maybe we shouldn't allow it to be
|
||||
|
||||
/* Records */
|
||||
private long lastLogin;
|
||||
|
||||
/* Skill Data */
|
||||
private final @NotNull Map<PrimarySkillType, Integer> skillLevelValues;
|
||||
private final @NotNull Map<PrimarySkillType, Float> skillExperienceValues;
|
||||
private final @NotNull Map<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
|
||||
private final @NotNull Map<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
private final @NotNull Map<PrimarySkillType, SkillBossBarState> barStateMap;
|
||||
|
||||
/* Special Flags */
|
||||
private boolean partyChatSpying;
|
||||
private boolean leaderBoardExclusion;
|
||||
|
||||
/* Scoreboards */
|
||||
private int scoreboardTipsShown;
|
||||
|
||||
private int lastUpdateHash;
|
||||
|
||||
/**
|
||||
* Create new persistent player data for a player
|
||||
* Initialized with default values
|
||||
*
|
||||
* @param playerUUID target player's UUID
|
||||
* @param playerName target player's name
|
||||
*/
|
||||
public PlayerData(@Nullable UUID playerUUID, @NotNull String playerName) {
|
||||
/*
|
||||
* New Data
|
||||
*/
|
||||
this.playerUUID = playerUUID;
|
||||
this.playerName = playerName;
|
||||
|
||||
this.skillLevelValues = new HashMap<>();
|
||||
this.skillExperienceValues = new HashMap<>();
|
||||
this.abilityDeactivationTimestamps = new HashMap<>();
|
||||
this.uniquePlayerData = new EnumMap<>(UniqueDataType.class);
|
||||
|
||||
this.scoreboardTipsShown = 0;
|
||||
|
||||
for(SuperAbilityType superSkill : SuperAbilityType.values()) {
|
||||
abilityDeactivationTimestamps.put(superSkill, 0);
|
||||
}
|
||||
|
||||
//Core skills
|
||||
//TODO: Don't store values for disabled skills
|
||||
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
|
||||
if(primarySkillType.isChildSkill())
|
||||
continue;
|
||||
|
||||
skillLevelValues.put(primarySkillType, AdvancedConfig.getInstance().getStartingLevel());
|
||||
skillExperienceValues.put(primarySkillType, 0F);
|
||||
}
|
||||
|
||||
//Unique Player Data
|
||||
this.uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, 0);
|
||||
|
||||
this.partyChatSpying = false;
|
||||
|
||||
this.barStateMap = MMOExperienceBarManager.generateDefaultBarStateMap();
|
||||
this.lastLogin = 0L; //Value of 0 will represent that the user hasn't been seen online
|
||||
this.leaderBoardExclusion = false;
|
||||
|
||||
this.lastUpdateHash = hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create persistent player data for a player using existing values
|
||||
* Typically this will be used when loading data
|
||||
* @param playerUUID target player's {@link UUID}
|
||||
* @param playerName target player's saved name
|
||||
* @param partyChatSpying target player's chat spy toggle
|
||||
* @param skillLevelValues target player's skill levels
|
||||
* @param skillExperienceValues target player's skill experience levels
|
||||
* @param abilityDeactivationTimestamps target player's ability deactivation time stamps
|
||||
* @param uniquePlayerData target player's misc unique data
|
||||
* @param barStateMap target player's XP bar state settings
|
||||
* @param scoreboardTipsShown target player's scoreboard tip view count
|
||||
* @param lastLogin target player's last login
|
||||
* @param leaderBoardExclusion target player's leaderboard exemption status
|
||||
*/
|
||||
public PlayerData(@NotNull UUID playerUUID,
|
||||
@NotNull String playerName,
|
||||
boolean partyChatSpying,
|
||||
@NotNull Map<PrimarySkillType, Integer> skillLevelValues,
|
||||
@NotNull Map<PrimarySkillType, Float> skillExperienceValues,
|
||||
@NotNull Map<SuperAbilityType, Integer> abilityDeactivationTimestamps,
|
||||
@NotNull Map<UniqueDataType, Integer> uniquePlayerData,
|
||||
@NotNull Map<PrimarySkillType, SkillBossBarState> barStateMap,
|
||||
int scoreboardTipsShown,
|
||||
long lastLogin,
|
||||
boolean leaderBoardExclusion) throws UnexpectedValueException, NullPointerException {
|
||||
|
||||
/*
|
||||
* Skills Data
|
||||
*/
|
||||
validateRootSkillMap(skillLevelValues);
|
||||
this.skillLevelValues = skillLevelValues;
|
||||
|
||||
validateRootSkillMap(skillExperienceValues);
|
||||
this.skillExperienceValues = skillExperienceValues;
|
||||
|
||||
validateSuperSkillMap(abilityDeactivationTimestamps);
|
||||
this.abilityDeactivationTimestamps = abilityDeactivationTimestamps;
|
||||
|
||||
this.uniquePlayerData = uniquePlayerData;
|
||||
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
|
||||
this.playerUUID = playerUUID;
|
||||
this.playerName = playerName;
|
||||
this.barStateMap = barStateMap;
|
||||
|
||||
this.partyChatSpying = partyChatSpying;
|
||||
this.lastLogin = lastLogin;
|
||||
|
||||
this.leaderBoardExclusion = leaderBoardExclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the map for a few potential logic issues such as negative numbers, or null entries
|
||||
*
|
||||
* @param map target map
|
||||
* @throws UnexpectedValueException when values are outside of expected norms
|
||||
*/
|
||||
private void validateRootSkillMap(Map<PrimarySkillType, ? extends Number> map) throws UnexpectedValueException, NullPointerException {
|
||||
//TODO: Check for missing/unregistered
|
||||
Validator<Number> positiveValidator = new Validator<>();
|
||||
Validator<Number> nullValidator = new Validator<>();
|
||||
|
||||
positiveValidator.addRule(new PositiveIntegerRule<>());
|
||||
nullValidator.addRule(new NonNullRule<>());
|
||||
|
||||
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
if(primarySkillType.isChildSkill())
|
||||
continue;
|
||||
|
||||
try {
|
||||
positiveValidator.validate(map.get(primarySkillType));
|
||||
} catch (Exception e) {
|
||||
throw new UnexpectedValueException();
|
||||
}
|
||||
|
||||
try {
|
||||
nullValidator.validate(map.get(primarySkillType));
|
||||
} catch (Exception e) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the map for a few potential logic issues such as negative numbers, or null entries
|
||||
*
|
||||
* @param map target map
|
||||
* @throws UnexpectedValueException when values are outside of expected norms
|
||||
* @throws Exception when values are outside of expected norms
|
||||
*/
|
||||
private void validateSuperSkillMap(Map<? extends SuperAbilityType, ? extends Number> map) throws UnexpectedValueException, NullPointerException {
|
||||
//TODO: Check for missing/unregistered
|
||||
Validator<Number> validator = new Validator<>();
|
||||
|
||||
validator.addRule(new PositiveIntegerRule<>());
|
||||
validator.addRule(new NonNullRule<>());
|
||||
|
||||
for(SuperAbilityType superSkill : SuperAbilityType.values()) {
|
||||
try {
|
||||
validator.validate(map.get(superSkill));
|
||||
} catch (Exception e) {
|
||||
throw new UnexpectedValueException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSkillLevel(@NotNull PrimarySkillType primarySkillType, int i) {
|
||||
skillLevelValues.put(primarySkillType, i);
|
||||
}
|
||||
|
||||
|
||||
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isProfileDirty() {
|
||||
return lastUpdateHash != hashCode();
|
||||
}
|
||||
|
||||
//TODO: T&C this needs to be called or pointless save operations won't be avoided
|
||||
public void resetDirtyFlag() {
|
||||
lastUpdateHash = hashCode();
|
||||
}
|
||||
|
||||
public @NotNull String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public @Nullable UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public boolean isPartyChatSpying() { return partyChatSpying; }
|
||||
|
||||
public void togglePartyChatSpying() {
|
||||
partyChatSpying = !partyChatSpying;
|
||||
}
|
||||
|
||||
public void setPartyChatSpying(boolean bool) {
|
||||
this.partyChatSpying = bool;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scoreboards
|
||||
*/
|
||||
|
||||
public int getScoreboardTipsShown() {
|
||||
return scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void setScoreboardTipsShown(int newValue) {
|
||||
this.scoreboardTipsShown = newValue;
|
||||
}
|
||||
|
||||
public int getChimaeraWingDATS() {
|
||||
return uniquePlayerData.get((UniqueDataType.CHIMAERA_WING_DATS));
|
||||
}
|
||||
|
||||
public void setChimaeraWingDATS(int DATS) {
|
||||
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, DATS);
|
||||
}
|
||||
|
||||
public void setUniqueData(@NotNull UniqueDataType uniqueDataType, int newData) {
|
||||
uniquePlayerData.put(uniqueDataType, newData);
|
||||
}
|
||||
|
||||
|
||||
public long getUniqueData(@NotNull UniqueDataType uniqueDataType) { return uniquePlayerData.get(uniqueDataType); }
|
||||
|
||||
public long getAbilityDATS(@NotNull SuperAbilityType superSkill) {
|
||||
return abilityDeactivationTimestamps.get(superSkill);
|
||||
}
|
||||
|
||||
public void setAbilityDATS(@NotNull SuperAbilityType superSkill, long DATS) {
|
||||
abilityDeactivationTimestamps.put(superSkill, (int) (DATS * .001D));
|
||||
}
|
||||
|
||||
public void resetCooldowns() {
|
||||
abilityDeactivationTimestamps.replaceAll((a, v) -> 0);
|
||||
}
|
||||
|
||||
public @NotNull Map<PrimarySkillType, SkillBossBarState> getBarStateMap() {
|
||||
return barStateMap;
|
||||
}
|
||||
|
||||
public @NotNull Map<PrimarySkillType, Integer> getSkillLevelsMap() {
|
||||
return skillLevelValues;
|
||||
}
|
||||
|
||||
public @NotNull Map<PrimarySkillType, Float> getSkillsExperienceMap() {
|
||||
return skillExperienceValues;
|
||||
}
|
||||
|
||||
public @NotNull Map<SuperAbilityType, Integer> getAbilityDeactivationTimestamps() {
|
||||
return abilityDeactivationTimestamps;
|
||||
}
|
||||
|
||||
public @NotNull Map<UniqueDataType, Integer> getUniquePlayerData() {
|
||||
return uniquePlayerData;
|
||||
}
|
||||
|
||||
public long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public void setLastLogin(long newValue) {
|
||||
this.lastLogin = newValue;
|
||||
}
|
||||
|
||||
public boolean isLeaderBoardExcluded() {
|
||||
return leaderBoardExclusion;
|
||||
}
|
||||
|
||||
public void setLeaderBoardExclusion(boolean bool) {
|
||||
this.leaderBoardExclusion = bool;
|
||||
}
|
||||
|
||||
public @NotNull ImmutableMap<PrimarySkillType, Integer> copyPrimarySkillLevelsMap() {
|
||||
return ImmutableMap.copyOf(getSkillLevelsMap());
|
||||
}
|
||||
|
||||
public @NotNull ImmutableMap<PrimarySkillType, Float> copyPrimarySkillExperienceValuesMap() {
|
||||
return ImmutableMap.copyOf(getSkillsExperienceMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PlayerData that = (PlayerData) o;
|
||||
return lastLogin == that.lastLogin
|
||||
&& partyChatSpying == that.partyChatSpying
|
||||
&& leaderBoardExclusion == that.leaderBoardExclusion
|
||||
&& scoreboardTipsShown == that.scoreboardTipsShown
|
||||
&& Objects.equal(playerName, that.playerName)
|
||||
&& Objects.equal(playerUUID, that.playerUUID)
|
||||
&& Objects.equal(skillLevelValues, that.skillLevelValues)
|
||||
&& Objects.equal(skillExperienceValues, that.skillExperienceValues)
|
||||
&& Objects.equal(abilityDeactivationTimestamps, that.abilityDeactivationTimestamps)
|
||||
&& Objects.equal(uniquePlayerData, that.uniquePlayerData) && Objects.equal(barStateMap, that.barStateMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(playerName, playerUUID, lastLogin, skillLevelValues, skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData, barStateMap, partyChatSpying, leaderBoardExclusion, scoreboardTipsShown);
|
||||
}
|
||||
}
|
||||
@@ -1,443 +1,70 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.experience.SkillXpGain;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.neetgames.mcmmo.exceptions.UnknownSkillException;
|
||||
import com.neetgames.mcmmo.experience.ExperienceProcessor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.DelayQueue;
|
||||
|
||||
public class PlayerProfile {
|
||||
private final String playerName;
|
||||
private @Nullable UUID uuid;
|
||||
private boolean loaded;
|
||||
private volatile boolean changed;
|
||||
|
||||
/* HUDs */
|
||||
private int scoreboardTipsShown;
|
||||
private int saveAttempts = 0;
|
||||
|
||||
private @Nullable Long lastLogin;
|
||||
|
||||
/* Skill Data */
|
||||
private final Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
|
||||
private final Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
||||
private final Map<SuperAbilityType, Integer> abilityDATS = new EnumMap<SuperAbilityType, Integer>(SuperAbilityType.class); // Ability & Cooldown
|
||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
|
||||
// Store previous XP gains for diminished returns
|
||||
private final DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<>();
|
||||
private final Map<PrimarySkillType, Float> rollingSkillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class);
|
||||
|
||||
@Deprecated
|
||||
//TODO: Add deprecated constructor w/o startinglevel
|
||||
public PlayerProfile(String playerName, int startingLevel) {
|
||||
this(playerName, null, startingLevel);
|
||||
}
|
||||
|
||||
//TODO: Add deprecated constructor w/o startinglevel
|
||||
public PlayerProfile(String playerName, @Nullable UUID uuid, int startingLevel) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
|
||||
scoreboardTipsShown = 0;
|
||||
|
||||
for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
|
||||
abilityDATS.put(superAbilityType, 0);
|
||||
}
|
||||
|
||||
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
|
||||
skills.put(primarySkillType, startingLevel);
|
||||
skillsXp.put(primarySkillType, 0F);
|
||||
}
|
||||
|
||||
//Misc Cooldowns
|
||||
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, 0); //Chimaera wing
|
||||
lastLogin = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(@NotNull String playerName, boolean isLoaded, int startingLvl) {
|
||||
this(playerName, startingLvl);
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
public PlayerProfile(@NotNull String playerName, UUID uuid, boolean isLoaded, int startingLvl) {
|
||||
this(playerName, uuid, startingLvl);
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
public PlayerProfile(@NotNull String playerName, UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData, @Nullable Long lastLogin) {
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
|
||||
skills.putAll(levelData);
|
||||
skillsXp.putAll(xpData);
|
||||
abilityDATS.putAll(cooldownData);
|
||||
uniquePlayerData.putAll(uniqueProfileData);
|
||||
|
||||
loaded = true;
|
||||
|
||||
if(lastLogin != null)
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
public void scheduleAsyncSave() {
|
||||
new PlayerProfileSaveTask(this, false).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
public void scheduleAsyncSaveDelay() {
|
||||
new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(mcMMO.p, 20);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void scheduleSyncSaveDelay() {
|
||||
new PlayerProfileSaveTask(this, true).runTaskLater(mcMMO.p, 20);
|
||||
}
|
||||
|
||||
public void save(boolean useSync) {
|
||||
if (!changed || !loaded) {
|
||||
saveAttempts = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO should this part be synchronized?
|
||||
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), scoreboardTipsShown, ImmutableMap.copyOf(uniquePlayerData), lastLogin);
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||
|
||||
if (changed) {
|
||||
mcMMO.p.getLogger().severe("PlayerProfile saving failed for player: " + playerName + " " + uuid);
|
||||
|
||||
if(saveAttempts > 0) {
|
||||
mcMMO.p.getLogger().severe("Attempted to save profile for player "+getPlayerName()
|
||||
+ " resulted in failure. "+saveAttempts+" have been made so far.");
|
||||
}
|
||||
|
||||
if(saveAttempts < 10)
|
||||
{
|
||||
saveAttempts++;
|
||||
|
||||
//Back out of async saving if we detect a server shutdown, this is not always going to be caught
|
||||
if(mcMMO.isServerShutdownExecuted() || useSync)
|
||||
new PlayerProfileSaveTask(this, true).runTask(mcMMO.p);
|
||||
else
|
||||
scheduleAsyncSave();
|
||||
|
||||
} else {
|
||||
mcMMO.p.getLogger().severe("mcMMO has failed to save the profile for "
|
||||
+getPlayerName()+" numerous times." +
|
||||
" mcMMO will now stop attempting to save this profile." +
|
||||
" Check your console for errors and inspect your DB for issues.");
|
||||
}
|
||||
|
||||
} else {
|
||||
saveAttempts = 0;
|
||||
}
|
||||
}
|
||||
//TODO: T&C update javadocs?
|
||||
public class PlayerProfile extends AbstractMMOPlayer {
|
||||
|
||||
/**
|
||||
* Get this users last login, will return current java.lang.System#currentTimeMillis() if it doesn't exist
|
||||
* @return the last login
|
||||
* @deprecated This is only function for FlatFileDB atm and its only here for unit testing right now
|
||||
*/
|
||||
@Deprecated
|
||||
public @NotNull Long getLastLogin() {
|
||||
if(lastLogin == null)
|
||||
return -1L;
|
||||
else
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public void updateLastLogin() {
|
||||
this.lastLogin = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUniqueId(UUID uuid) {
|
||||
markProfileDirty();
|
||||
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the profile as "dirty" which flags a profile to be saved in the next save operation
|
||||
*/
|
||||
public void markProfileDirty() {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
public int getScoreboardTipsShown() {
|
||||
return scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void setScoreboardTipsShown(int scoreboardTipsShown) {
|
||||
markProfileDirty();
|
||||
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void increaseTipsShown() {
|
||||
setScoreboardTipsShown(getScoreboardTipsShown() + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cooldowns
|
||||
*/
|
||||
|
||||
public int getChimaerWingDATS() { return uniquePlayerData.get(UniqueDataType.CHIMAERA_WING_DATS);}
|
||||
|
||||
protected void setChimaeraWingDATS(int DATS) {
|
||||
markProfileDirty();
|
||||
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, DATS);
|
||||
}
|
||||
|
||||
public void setUniqueData(UniqueDataType uniqueDataType, int newData) {
|
||||
markProfileDirty();
|
||||
uniquePlayerData.put(uniqueDataType, newData);
|
||||
}
|
||||
|
||||
public long getUniqueData(UniqueDataType uniqueDataType) { return uniquePlayerData.get(uniqueDataType); }
|
||||
|
||||
/**
|
||||
* Get the current deactivation timestamp of an ability.
|
||||
* Initialize an {@link PlayerProfile} for {@link PlayerData}
|
||||
* This will be used for existing data
|
||||
*
|
||||
* @param ability The {@link SuperAbilityType} to get the DATS for
|
||||
* @return the deactivation timestamp for the ability
|
||||
* @param mmoPlayerData target persistent player data
|
||||
*/
|
||||
public long getAbilityDATS(SuperAbilityType ability) {
|
||||
return abilityDATS.get(ability);
|
||||
public PlayerProfile(@NotNull PlayerData mmoPlayerData, boolean isLoaded) {
|
||||
super(mmoPlayerData, isLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current deactivation timestamp of an ability.
|
||||
*
|
||||
* @param ability The {@link SuperAbilityType} to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
*/
|
||||
protected void setAbilityDATS(SuperAbilityType ability, long DATS) {
|
||||
markProfileDirty();
|
||||
|
||||
abilityDATS.put(ability, (int) (DATS * .001D));
|
||||
@Override
|
||||
public @NotNull UUID getUUID() {
|
||||
return playerData.getPlayerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all ability cooldowns.
|
||||
*/
|
||||
protected void resetCooldowns() {
|
||||
markProfileDirty();
|
||||
|
||||
abilityDATS.replaceAll((a, v) -> 0);
|
||||
@Override
|
||||
public @NotNull String getPlayerName() {
|
||||
return playerData.getPlayerName();
|
||||
}
|
||||
|
||||
/*
|
||||
* Xp Functions
|
||||
*/
|
||||
|
||||
public int getSkillLevel(PrimarySkillType skill) {
|
||||
return SkillTools.isChildSkill(skill) ? getChildSkillLevel(skill) : skills.get(skill);
|
||||
@Override
|
||||
public int getPowerLevel() {
|
||||
return experienceProcessor.getPowerLevel();
|
||||
}
|
||||
|
||||
public float getSkillXpLevelRaw(PrimarySkillType skill) {
|
||||
return skillsXp.get(skill);
|
||||
@Override
|
||||
public int getSkillLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||
return experienceProcessor.getSkillLevel(primarySkillType);
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(PrimarySkillType skill) {
|
||||
if(SkillTools.isChildSkill(skill)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.floor(getSkillXpLevelRaw(skill));
|
||||
@Override
|
||||
public int getSkillExperience(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||
return experienceProcessor.getSkillXpValue(primarySkillType);
|
||||
}
|
||||
|
||||
public void setSkillXpLevel(PrimarySkillType skill, float xpLevel) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
markProfileDirty();
|
||||
|
||||
skillsXp.put(skill, xpLevel);
|
||||
@Override
|
||||
public int getExperienceToNextLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||
return experienceProcessor.getExperienceToNextLevel(primarySkillType);
|
||||
}
|
||||
|
||||
protected float levelUp(PrimarySkillType skill) {
|
||||
float xpRemoved = getXpToLevel(skill);
|
||||
|
||||
markProfileDirty();
|
||||
|
||||
skills.put(skill, skills.get(skill) + 1);
|
||||
skillsXp.put(skill, skillsXp.get(skill) - xpRemoved);
|
||||
|
||||
return xpRemoved;
|
||||
@Override
|
||||
public double getProgressInCurrentSkillLevel(@NotNull PrimarySkillType primarySkillType) throws UnknownSkillException {
|
||||
return experienceProcessor.getProgressInCurrentSkillLevel(primarySkillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Xp from a skill.
|
||||
*
|
||||
* @param skill Type of skill to modify
|
||||
* @param xp Amount of xp to remove
|
||||
*/
|
||||
public void removeXp(PrimarySkillType skill, int xp) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
markProfileDirty();
|
||||
|
||||
skillsXp.put(skill, skillsXp.get(skill) - xp);
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeXp(PrimarySkillType skill, float xp) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
markProfileDirty();
|
||||
|
||||
skillsXp.put(skill, skillsXp.get(skill) - xp);
|
||||
public @NotNull ExperienceProcessor getExperienceHandler() {
|
||||
return experienceProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a skill level.
|
||||
*
|
||||
* @param skill Type of skill to modify
|
||||
* @param level New level value for the skill
|
||||
*/
|
||||
public void modifySkill(PrimarySkillType skill, int level) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
markProfileDirty();
|
||||
|
||||
//Don't allow levels to be negative
|
||||
if(level < 0)
|
||||
level = 0;
|
||||
|
||||
skills.put(skill, level);
|
||||
skillsXp.put(skill, 0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
*
|
||||
* @param skill Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public void addLevels(PrimarySkillType skill, int levels) {
|
||||
modifySkill(skill, skills.get(skill) + levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Experience to a skill.
|
||||
*
|
||||
* @param skill Type of skill to add experience to
|
||||
* @param xp Number of experience to add
|
||||
*/
|
||||
public void addXp(PrimarySkillType skill, float xp) {
|
||||
markProfileDirty();
|
||||
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
float dividedXP = (xp / parentSkills.size());
|
||||
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skillsXp.put(skill, skillsXp.get(skill) + xp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registered amount of experience gained
|
||||
* This is used for diminished XP returns
|
||||
*
|
||||
* @return xp Experience amount registered
|
||||
*/
|
||||
public float getRegisteredXpGain(PrimarySkillType primarySkillType) {
|
||||
float xp = 0F;
|
||||
|
||||
if (rollingSkillsXp.get(primarySkillType) != null) {
|
||||
xp = rollingSkillsXp.get(primarySkillType);
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an experience gain
|
||||
* This is used for diminished XP returns
|
||||
*
|
||||
* @param primarySkillType Skill being used
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void registerXpGain(PrimarySkillType primarySkillType, float xp) {
|
||||
gainedSkillsXp.add(new SkillXpGain(primarySkillType, xp));
|
||||
rollingSkillsXp.put(primarySkillType, getRegisteredXpGain(primarySkillType) + xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove experience gains older than a given time
|
||||
* This is used for diminished XP returns
|
||||
*/
|
||||
public void purgeExpiredXpGains() {
|
||||
SkillXpGain gain;
|
||||
while ((gain = gainedSkillsXp.poll()) != null) {
|
||||
rollingSkillsXp.put(gain.getSkill(), getRegisteredXpGain(gain.getSkill()) - gain.getXp());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of Xp remaining before the next level.
|
||||
*
|
||||
* @param primarySkillType Type of skill to check
|
||||
* @return the total amount of Xp until next level
|
||||
*/
|
||||
public int getXpToLevel(PrimarySkillType primarySkillType) {
|
||||
if(SkillTools.isChildSkill(primarySkillType)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType);
|
||||
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
|
||||
|
||||
return mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType);
|
||||
}
|
||||
|
||||
private int getChildSkillLevel(PrimarySkillType primarySkillType) {
|
||||
Set<PrimarySkillType> parents = FamilyTree.getParents(primarySkillType);
|
||||
int sum = 0;
|
||||
|
||||
for (PrimarySkillType parent : parents) {
|
||||
sum += Math.min(getSkillLevel(parent), mcMMO.p.getSkillTools().getLevelCap(parent));
|
||||
}
|
||||
|
||||
return sum / parents.size();
|
||||
public @NotNull PlayerData getPlayerData() {
|
||||
return playerData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
public enum UniqueDataType {
|
||||
CHIMAERA_WING_DATS
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
public enum AbilityToolType {
|
||||
SKULL_SPLITTER_TOOL("Axes.Ability.Lower", "Axes.Ability.Ready"),
|
||||
BERSERK_TOOL( "Unarmed.Ability.Lower", "Unarmed.Ability.Ready"),
|
||||
GREEN_TERRA_TOOL("Herbalism.Ability.Lower", "Herbalism.Ability.Ready"),
|
||||
SUPER_BREAKER_TOOL("Mining.Ability.Lower", "Mining.Ability.Ready"),
|
||||
GIGA_DRILL_BREAKER_TOOL("Excavation.Ability.Lower", "Excavation.Ability.Ready"),
|
||||
SERRATED_STRIKES_TOOL("Swords.Ability.Lower", "Swords.Ability.Ready"),
|
||||
TREE_FELLER_TOOL("Axes.Ability.Lower", "Axes.Ability.Ready"),
|
||||
ARCHERY_TOOL("Archery.Ability.Lower", "Archery.Ability.Ready"),
|
||||
SUPER_SHOTGUN_TOOL("Crossbows.Ability.Lower", "Crossbows.Ability.Ready"),
|
||||
TRIDENTS_TOOL("Tridents.Ability.Lower", "Tridents.Ability.Ready");
|
||||
|
||||
private final String lowerToolLocaleKey;
|
||||
private final String raiseToolLocaleKey;
|
||||
|
||||
AbilityToolType(String lowerToolLocaleKey, String raiseToolLocaleKey) {
|
||||
this.lowerToolLocaleKey = lowerToolLocaleKey;
|
||||
this.raiseToolLocaleKey = raiseToolLocaleKey;
|
||||
}
|
||||
|
||||
public String getLowerToolLocaleKey() {
|
||||
return lowerToolLocaleKey;
|
||||
}
|
||||
|
||||
public String getRaiseToolLocaleKey() {
|
||||
return raiseToolLocaleKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.neetgames.mcmmo.skill.AbstractRootSkill;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class CoreRootSkill extends AbstractRootSkill {
|
||||
|
||||
@NotNull private final Class<? extends SkillManager> skillManagerClass;
|
||||
|
||||
public CoreRootSkill(@NotNull String skillName, @NotNull Class<? extends SkillManager> clazz) {
|
||||
super(mcMMO.p.getName(), StringUtils.getCapitalized(skillName), "mcmmo.skills." + skillName.toLowerCase(Locale.ENGLISH));
|
||||
this.skillManagerClass = clazz;
|
||||
}
|
||||
|
||||
public @NotNull Class<? extends SkillManager> getSkillManagerClass() {
|
||||
return skillManagerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPVPPermitted() {
|
||||
return Config.getInstance().getPVPEnabled(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPVEPermitted() {
|
||||
return Config.getInstance().getPVEEnabled(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAffectedByHardcoreModeStatLoss() {
|
||||
return Config.getInstance().getHardcoreStatLossEnabled(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHardcoreVampirismEnabled() {
|
||||
return Config.getInstance().getHardcoreVampirismEnabled(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRootSkillPermitted(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
return Permissions.skillEnabled((Player) mmoPlayer.getServerAPIPlayerImpl(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOffensiveActionAllowed(@NotNull Object victim) {
|
||||
return (victim instanceof Player || (victim instanceof Tameable && ((Tameable) victim).isTamed())) ? isPVPPermitted() : isPVEPermitted();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.neetgames.mcmmo.skill.RootSkill;
|
||||
import com.neetgames.mcmmo.skill.SkillImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CoreSkill extends SkillImpl {
|
||||
|
||||
//TODO: Change to passing SkillIdentity
|
||||
public CoreSkill(@NotNull String pluginName, @NotNull String skillName, @Nullable String permission, @NotNull RootSkill parentSkill) {
|
||||
super(pluginName, skillName, permission, parentSkill);
|
||||
}
|
||||
|
||||
}
|
||||
341
src/main/java/com/gmail/nossr50/datatypes/skills/CoreSkills.java
Normal file
341
src/main/java/com/gmail/nossr50/datatypes/skills/CoreSkills.java
Normal file
@@ -0,0 +1,341 @@
|
||||
//package com.gmail.nossr50.datatypes.skills;
|
||||
//
|
||||
//import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
//import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||
//import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
//import com.gmail.nossr50.skills.axes.AxesManager;
|
||||
//import com.gmail.nossr50.skills.crossbows.CrossbowsManager;
|
||||
//import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
//import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
//import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||
//import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
//import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
//import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
//import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
//import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
//import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
//import com.gmail.nossr50.skills.tridents.TridentsManager;
|
||||
//import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
//import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
//import com.google.common.collect.ImmutableSet;
|
||||
//import com.neetgames.mcmmo.skill.RootSkill;
|
||||
//import com.neetgames.mcmmo.skill.SkillIdentity;
|
||||
//import com.neetgames.mcmmo.skill.SuperSkill;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.Map;
|
||||
//import java.util.Set;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//public class CoreSkills {
|
||||
//
|
||||
// //TODO: Should these be immutable?
|
||||
// private static final @NotNull ImmutableSet<CoreRootSkill> CORE_ROOT_SKILLS;
|
||||
// private static final @NotNull ImmutableSet<CoreRootSkill> CORE_CHILD_SKILLS;
|
||||
// private static final @NotNull ImmutableSet<CoreRootSkill> CORE_NON_CHILD_SKILLS;
|
||||
// private static final @NotNull ImmutableSet<CoreSkill> CORE_SUB_SKILLS;
|
||||
// private static final @NotNull ImmutableSet<SuperSkill> CORE_SUPER_SKILLS;
|
||||
//
|
||||
// //TODO: Use annotations instead
|
||||
// public static final @NotNull CoreRootSkill ACROBATICS, ALCHEMY, ARCHERY, AXES, EXCAVATION,
|
||||
// FISHING, HERBALISM, MINING, REPAIR, SALVAGE, SMELTING, SWORDS, TAMING, UNARMED,
|
||||
// WOODCUTTING, TRIDENTS, CROSSBOWS;
|
||||
//
|
||||
// //TODO: Needed?
|
||||
// public static final @NotNull SkillIdentity ACROBATICS_ID, ALCHEMY_ID, ARCHERY_ID, AXES_ID, EXCAVATION_ID,
|
||||
// FISHING_ID, HERBALISM_ID, MINING_ID, REPAIR_ID, SALVAGE_ID, SMELTING_ID, SWORDS_ID, TAMING_ID, UNARMED_ID,
|
||||
// WOODCUTTING_ID, TRIDENTS_ID, CROSSBOWS_ID;
|
||||
//
|
||||
//// public static final @NotNull SuperSkill SKULL_SPLITTER, GIGA_DRILL_BREAKER, GREEN_TERRA, SUPER_BREAKER,
|
||||
//// BLAST_MINING, SERRATED_STRIKES, CALL_OF_THE_WILD, BERSERK, TREE_FELLER, TRIDENTS_SUPER, SUPER_SHOT_GUN;
|
||||
//
|
||||
//// public static @NotNull CoreSkill
|
||||
//// /* Acrobatics */
|
||||
//// DODGE, ROLL,
|
||||
////
|
||||
//// /* Alchemy */
|
||||
//// CATALYSIS, CONCOCTIONS,
|
||||
////
|
||||
//// /* Archery */
|
||||
//// ARROW_RETRIEVAL, DAZE, SKILLSHOT, LIMIT_BREAK_ARCHERY,
|
||||
////
|
||||
//// /* Axes */
|
||||
//// ARMOR_IMPACT, AXE_MASTERY, LIMIT_BREAK_AXES, CRITICAL_STRIKES, GREATER_IMPACT, SKULL_SPLITTER,
|
||||
////
|
||||
//// /* Excavation */
|
||||
//// ARCHAEOLOGY, GIGA_DRILL_BREAKER,
|
||||
////
|
||||
//// /* Fishing */
|
||||
//// FISHERMANS_DIET, ICE_FISHING, MAGIC_HUNTER, MASTER_ANGLER, TREASURE_HUNTER, SHAKE,
|
||||
////
|
||||
//// /* Herbalism */
|
||||
//// DOUBLE_DROPS_HERBALISM, FARMERS_DIET, GREEN_TERRA, GREEN_THUMB, HYLIAN_LUCK, SHROOM_THUMB,
|
||||
////
|
||||
//// /* Mining */
|
||||
//// BIGGER_BOMBS, BLAST_MINING, DEMOLITIONS_EXPERTISE, DOUBLE_DROPS, SUPER_BREAKER,
|
||||
////
|
||||
//// /* Repair */
|
||||
//// ARCANE_FORGING, REPAIR_MASTERY, SUPER_REPAIR,
|
||||
////
|
||||
//// /* Salvage */
|
||||
//// SCRAP_COLLECTOR, ARCANE_SALVAGE,
|
||||
////
|
||||
//// /* Smelting */
|
||||
//// FUEL_EFFICIENCY, SECOND_SMELT, UNDERSTANDING_THE_ART,
|
||||
////
|
||||
//// /* Swords */
|
||||
//// COUNTER_ATTACK, RUPTURE, SERRATED_STRIKES, STAB, LIMIT_BREAK_SWORDS,
|
||||
////
|
||||
//// /* Taming */
|
||||
//// BEAST_LORE, CALL_OF_THE_WILD, ENVIRONMENTALLY_AWARE, FAST_FOOD_SERVICE, GORE, HOLY_HOUND, PUMMEL, SHARPENED_CLAWS, SHOCK_PROOF, THICK_FUR,
|
||||
////
|
||||
//// /* Archery */
|
||||
//// ARROW_DEFLECT, BERSERK, BLOCK_CRACKER, DISARM, STEEL_ARM_STYLE, IRON_GRIP, LIMIT_BREAK_UNARMED,
|
||||
////
|
||||
//// /* Woodcutting */
|
||||
//// KNOCK_ON_WOOD, HARVEST_LUMBER, LEAF_BLOWER, TREE_FELLER,
|
||||
////
|
||||
//// /* Tridents */
|
||||
//// MULTI_TASKING, LIMIT_BREAK_TRIDENTS,
|
||||
////
|
||||
//// /* Crossbows */
|
||||
//// SUPER_SHOTGUN, LIMIT_BREAK_CROSSBOWS;
|
||||
//
|
||||
// private static final @NotNull HackySkillMappings hackySkillMappings = new HackySkillMappings();
|
||||
//
|
||||
// static {
|
||||
// HashSet<CoreRootSkill> primarySkillTypeSet = new HashSet<>();
|
||||
// HashSet<CoreRootSkill> childSkillSet = new HashSet<>();
|
||||
// HashSet<CoreSkill> subSkillSet = new HashSet<>();
|
||||
// HashSet<SuperSkill> superSkillSet = new HashSet<>();
|
||||
//
|
||||
// ACROBATICS = new CoreRootSkill("acrobatics", AcrobaticsManager.class);
|
||||
// ACROBATICS_ID = ACROBATICS.getSkillIdentity();
|
||||
//
|
||||
// ALCHEMY = new CoreRootSkill("alchemy", AlchemyManager.class);
|
||||
// ALCHEMY_ID = ALCHEMY.getSkillIdentity();
|
||||
//
|
||||
// ARCHERY = new CoreRootSkill("archery", ArcheryManager.class);
|
||||
// ARCHERY_ID = ARCHERY.getSkillIdentity();
|
||||
//
|
||||
// AXES = new CoreRootSkill("axes", AxesManager.class);
|
||||
// AXES_ID = AXES.getSkillIdentity();
|
||||
//
|
||||
// EXCAVATION = new CoreRootSkill("excavation", ExcavationManager.class);
|
||||
// EXCAVATION_ID = EXCAVATION.getSkillIdentity();
|
||||
//
|
||||
// FISHING = new CoreRootSkill("fishing", FishingManager.class);
|
||||
// FISHING_ID = FISHING.getSkillIdentity();
|
||||
//
|
||||
// HERBALISM = new CoreRootSkill("herbalism", HerbalismManager.class);
|
||||
// HERBALISM_ID = HERBALISM.getSkillIdentity();
|
||||
//
|
||||
// MINING = new CoreRootSkill("mining", MiningManager.class);
|
||||
// MINING_ID = MINING.getSkillIdentity();
|
||||
//
|
||||
// REPAIR = new CoreRootSkill("repair", RepairManager.class);
|
||||
// REPAIR_ID = REPAIR.getSkillIdentity();
|
||||
//
|
||||
// SALVAGE = new CoreRootSkill("salvage", SalvageManager.class);
|
||||
// SALVAGE_ID = SALVAGE.getSkillIdentity();
|
||||
//
|
||||
// SMELTING = new CoreRootSkill("smelting", SmeltingManager.class);
|
||||
// SMELTING_ID = SMELTING.getSkillIdentity();
|
||||
//
|
||||
// SWORDS = new CoreRootSkill("swords", SwordsManager.class);
|
||||
// SWORDS_ID = SWORDS.getSkillIdentity();
|
||||
//
|
||||
// TAMING = new CoreRootSkill("taming", TamingManager.class);
|
||||
// TAMING_ID = TAMING.getSkillIdentity();
|
||||
//
|
||||
// UNARMED = new CoreRootSkill("unarmed", UnarmedManager.class);
|
||||
// UNARMED_ID = UNARMED.getSkillIdentity();
|
||||
//
|
||||
// WOODCUTTING = new CoreRootSkill("woodcutting", WoodcuttingManager.class);
|
||||
// WOODCUTTING_ID = WOODCUTTING.getSkillIdentity();
|
||||
//
|
||||
// TRIDENTS = new CoreRootSkill("tridents", TridentsManager.class);
|
||||
// TRIDENTS_ID = TRIDENTS.getSkillIdentity();
|
||||
//
|
||||
// CROSSBOWS = new CoreRootSkill("crossbows", CrossbowsManager.class);
|
||||
// CROSSBOWS_ID = CROSSBOWS.getSkillIdentity();
|
||||
//
|
||||
// //Child skills (soon to be removed)
|
||||
// childSkillSet.add(SMELTING);
|
||||
// childSkillSet.add(SALVAGE);
|
||||
//
|
||||
// primarySkillTypeSet.add(ACROBATICS);
|
||||
// primarySkillTypeSet.add(ALCHEMY);
|
||||
// primarySkillTypeSet.add(ARCHERY);
|
||||
// primarySkillTypeSet.add(AXES);
|
||||
// primarySkillTypeSet.add(EXCAVATION);
|
||||
// primarySkillTypeSet.add(FISHING);
|
||||
// primarySkillTypeSet.add(HERBALISM);
|
||||
// primarySkillTypeSet.add(MINING);
|
||||
// primarySkillTypeSet.add(REPAIR);
|
||||
// primarySkillTypeSet.add(SALVAGE);
|
||||
// primarySkillTypeSet.add(SMELTING);
|
||||
// primarySkillTypeSet.add(SWORDS);
|
||||
// primarySkillTypeSet.add(TAMING);
|
||||
// primarySkillTypeSet.add(UNARMED);
|
||||
// primarySkillTypeSet.add(WOODCUTTING);
|
||||
// primarySkillTypeSet.add(TRIDENTS);
|
||||
// primarySkillTypeSet.add(CROSSBOWS);
|
||||
//
|
||||
// CORE_ROOT_SKILLS = ImmutableSet.copyOf(primarySkillTypeSet);
|
||||
// CORE_CHILD_SKILLS = ImmutableSet.copyOf(childSkillSet);
|
||||
// CORE_NON_CHILD_SKILLS = ImmutableSet.copyOf(generateNonChildSkillSet());
|
||||
// CORE_SUB_SKILLS = ImmutableSet.copyOf(subSkillSet);
|
||||
// CORE_SUPER_SKILLS = ImmutableSet.copyOf(superSkillSet);
|
||||
//
|
||||
// /*
|
||||
// * Init core skills
|
||||
// */
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns a set of built in {@link RootSkill}s for mcMMO
|
||||
// * No guarantees for whether or not the skills are registered or active or inactive
|
||||
// *
|
||||
// * @return a set of all {@link RootSkill} built into mcMMO
|
||||
// */
|
||||
// public static @NotNull Set<CoreRootSkill> getCoreRootSkills() {
|
||||
// return CORE_ROOT_SKILLS;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns a set of built in {@link CoreSkill}s for mcMMO
|
||||
// * No guarantees for whether or not the skills are registered or active or inactive
|
||||
// *
|
||||
// * @return a set of all {@link CoreSkill} built into mcMMO
|
||||
// */
|
||||
// public static @NotNull Set<CoreSkill> getCoreSkills() {
|
||||
// return CORE_SUB_SKILLS;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns a set of built in {@link SuperSkill}s for mcMMO
|
||||
// * No guarantees for whether or not the skills are registered or active or inactive
|
||||
// *
|
||||
// * @return a set of all {@link SuperSkill} built into mcMMO
|
||||
// */
|
||||
// public static @NotNull Set<SuperSkill> getCoreSuperSkills() {
|
||||
// return CORE_SUPER_SKILLS;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns a set of built in skills for mcMMO which are child skills
|
||||
// * No guarantees for whether or not the skills are registered or active or inactive
|
||||
// *
|
||||
// * @return a set of all "child" root skills for mcMMO
|
||||
// * @deprecated child skills will be removed in an upcoming update
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static @NotNull Set<CoreRootSkill> getChildSkills() {
|
||||
// return CORE_CHILD_SKILLS;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Whether or not a skill is considered a child skill
|
||||
// * @param primarySkillType target skill
|
||||
// * @return true if the skill identity belongs to a core "child" root skill
|
||||
// */
|
||||
// public static boolean isChildSkill(@NotNull PrimarySkillType primarySkillType) {
|
||||
// return CORE_CHILD_SKILLS.contains(primarySkillType);
|
||||
// }
|
||||
//
|
||||
// @Deprecated
|
||||
// public static @NotNull RootSkill getSkill(@NotNull PrimarySkillType primarySkillType) {
|
||||
// if(!hackySkillMappings.init) {
|
||||
// hackySkillMappings.initMappings();
|
||||
// }
|
||||
//
|
||||
// return hackySkillMappings.primaryToRootMap.get(primarySkillType);
|
||||
// }
|
||||
//
|
||||
// @Deprecated
|
||||
// public static @NotNull PrimarySkillType getSkill(@NotNull PrimarySkillType primarySkillType) {
|
||||
// if(!hackySkillMappings.init) {
|
||||
// hackySkillMappings.initMappings();
|
||||
// }
|
||||
//
|
||||
// return hackySkillMappings.rootToPrimaryMap.get(primarySkillType);
|
||||
// }
|
||||
//
|
||||
// @Deprecated
|
||||
// private static @NotNull Set<CoreRootSkill> generateNonChildSkillSet() {
|
||||
// return getCoreRootSkills().stream().filter((x) -> !isChildSkill(x)).collect(Collectors.toSet());
|
||||
// }
|
||||
//
|
||||
// public static @NotNull Set<CoreRootSkill> getNonChildSkills() {
|
||||
// return CORE_NON_CHILD_SKILLS;
|
||||
// }
|
||||
//
|
||||
// protected static class HackySkillMappings {
|
||||
// @NotNull Map<PrimarySkillType, CoreRootSkill> primaryToRootMap = new HashMap<>();
|
||||
// @NotNull Map<CoreRootSkill, PrimarySkillType> rootToPrimaryMap = new HashMap<>();
|
||||
// boolean init = false;
|
||||
//
|
||||
// protected void initMappings() {
|
||||
// //TODO: add tests
|
||||
// //Can't init these from the get go as PrimarySkillType does some stuff and it would be race condition hell
|
||||
// primaryToRootMap.put(PrimarySkillType.ACROBATICS, ACROBATICS);
|
||||
// rootToPrimaryMap.put(ACROBATICS, PrimarySkillType.ACROBATICS);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.ALCHEMY, ALCHEMY);
|
||||
// rootToPrimaryMap.put(ALCHEMY, PrimarySkillType.ALCHEMY);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.ARCHERY, ARCHERY);
|
||||
// rootToPrimaryMap.put(ARCHERY, PrimarySkillType.ARCHERY);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.AXES, AXES);
|
||||
// rootToPrimaryMap.put(AXES, PrimarySkillType.AXES);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.EXCAVATION, EXCAVATION);
|
||||
// rootToPrimaryMap.put(EXCAVATION, PrimarySkillType.EXCAVATION);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.FISHING, FISHING);
|
||||
// rootToPrimaryMap.put(FISHING, PrimarySkillType.FISHING);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.HERBALISM, HERBALISM);
|
||||
// rootToPrimaryMap.put(HERBALISM, PrimarySkillType.HERBALISM);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.MINING, MINING);
|
||||
// rootToPrimaryMap.put(MINING, PrimarySkillType.MINING);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.REPAIR, REPAIR);
|
||||
// rootToPrimaryMap.put(REPAIR, PrimarySkillType.REPAIR);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.SALVAGE, SALVAGE);
|
||||
// rootToPrimaryMap.put(SALVAGE, PrimarySkillType.SALVAGE);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.SMELTING, SMELTING);
|
||||
// rootToPrimaryMap.put(SMELTING, PrimarySkillType.SMELTING);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.SWORDS, SWORDS);
|
||||
// rootToPrimaryMap.put(SWORDS, PrimarySkillType.SWORDS);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.TAMING, TAMING);
|
||||
// rootToPrimaryMap.put(TAMING, PrimarySkillType.TAMING);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.UNARMED, UNARMED);
|
||||
// rootToPrimaryMap.put(UNARMED, PrimarySkillType.UNARMED);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.WOODCUTTING, WOODCUTTING);
|
||||
// rootToPrimaryMap.put(WOODCUTTING, PrimarySkillType.WOODCUTTING);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.TRIDENTS, TRIDENTS);
|
||||
// rootToPrimaryMap.put(TRIDENTS, PrimarySkillType.TRIDENTS);
|
||||
//
|
||||
// primaryToRootMap.put(PrimarySkillType.CROSSBOWS, CROSSBOWS);
|
||||
// rootToPrimaryMap.put(CROSSBOWS, PrimarySkillType.CROSSBOWS);
|
||||
//
|
||||
// init = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
public interface PrimarySkill {
|
||||
|
||||
}
|
||||
@@ -26,226 +26,194 @@ public enum PrimarySkillType {
|
||||
SWORDS,
|
||||
TAMING,
|
||||
UNARMED,
|
||||
WOODCUTTING;
|
||||
// boolean issueWarning = true;
|
||||
WOODCUTTING,
|
||||
TRIDENTS,
|
||||
CROSSBOWS;
|
||||
|
||||
/*
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
|
||||
*/
|
||||
|
||||
|
||||
// private void processWarning() {
|
||||
// if(issueWarning) {
|
||||
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
// Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
|
||||
// mcMMO.p.getLogger().severe("A plugin that hooks into mcMMO via the mcMMO API is using soon to be deprecated API calls. Contact the plugin author and inform them to update their code before it breaks.");
|
||||
// mcMMO.p.getLogger().severe("Deprecation Call from: " + stackTraceElements[2].toString());
|
||||
// mcMMO.p.getLogger().severe("This warning will not repeat itself. Nothing is broken for now, but in the future it will be.");
|
||||
// });
|
||||
//
|
||||
// issueWarning = !issueWarning;
|
||||
// }
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getLevelCap(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public int getMaxLevel() {
|
||||
// return mcMMO.p.getSkillTools().getLevelCap(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#isSuperAbilityUnlocked(com.gmail.nossr50.datatypes.skills.PrimarySkillType, org.bukkit.entity.Player)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean isSuperAbilityUnlocked(@NotNull Player player) {
|
||||
// return mcMMO.p.getSkillTools().isSuperAbilityUnlocked(this, player);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getPVPEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean getPVPEnabled() {
|
||||
// return mcMMO.p.getSkillTools().getPVPEnabled(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getPVEEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean getPVEEnabled() {
|
||||
// return mcMMO.p.getSkillTools().getPVEEnabled(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see GeneralConfig#getDoubleDropsDisabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean getDoubleDropsDisabled() {
|
||||
// return mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getHardcoreStatLossEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean getHardcoreStatLossEnabled() {
|
||||
// return mcMMO.p.getSkillTools().getHardcoreStatLossEnabled(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getHardcoreVampirismEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean getHardcoreVampirismEnabled() {
|
||||
// return mcMMO.p.getSkillTools().getHardcoreVampirismEnabled(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getPrimarySkillToolType(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public ToolType getTool() {
|
||||
// return mcMMO.p.getSkillTools().getPrimarySkillToolType(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getSubSkills(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public List<SubSkillType> getSkillAbilities() {
|
||||
// return new ArrayList<>(mcMMO.p.getSkillTools().getSubSkills(this));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getXpModifier(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public double getXpModifier() {
|
||||
// return mcMMO.p.getSkillTools().getXpModifier(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#matchSkill(java.lang.String)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static PrimarySkillType getSkill(String skillName) {
|
||||
// return mcMMO.p.getSkillTools().matchSkill(skillName);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#isChildSkill(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean isChildSkill() {
|
||||
// return SkillTools.isChildSkill(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getPrimarySkillBySubSkill(com.gmail.nossr50.datatypes.skills.SubSkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static PrimarySkillType bySecondaryAbility(SubSkillType subSkillType) {
|
||||
// return mcMMO.p.getSkillTools().getPrimarySkillBySubSkill(subSkillType);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getPrimarySkillBySuperAbility(com.gmail.nossr50.datatypes.skills.SuperAbilityType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static PrimarySkillType byAbility(SuperAbilityType superAbilityType) {
|
||||
// return mcMMO.p.getSkillTools().getPrimarySkillBySuperAbility(superAbilityType);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#getLocalizedSkillName(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String getName() {
|
||||
// return mcMMO.p.getSkillTools().getLocalizedSkillName(this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see Permissions#skillEnabled(org.bukkit.permissions.Permissible, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
// * @deprecated this is being removed in an upcoming update
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean getPermissions(Player player) {
|
||||
// return mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// * @return the max level of this skill
|
||||
// * @see SkillTools#canCombatSkillsTrigger(com.gmail.nossr50.datatypes.skills.PrimarySkillType, org.bukkit.entity.Entity)
|
||||
// * @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean shouldProcess(Entity target) {
|
||||
// return mcMMO.p.getSkillTools().canCombatSkillsTrigger(this, target);
|
||||
// }
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getLevelCap(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public int getMaxLevel() {
|
||||
return mcMMO.p.getSkillTools().getLevelCap(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#isSuperAbilityUnlocked(com.gmail.nossr50.datatypes.skills.PrimarySkillType, org.bukkit.entity.Player)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isSuperAbilityUnlocked(@NotNull Player player) {
|
||||
return mcMMO.p.getSkillTools().isSuperAbilityUnlocked(this, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getPVPEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getPVPEnabled() {
|
||||
return mcMMO.p.getSkillTools().getPVPEnabled(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getPVEEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getPVEEnabled() {
|
||||
return mcMMO.p.getSkillTools().getPVEEnabled(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see GeneralConfig#getDoubleDropsDisabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getDoubleDropsDisabled() {
|
||||
return mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getHardcoreStatLossEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getHardcoreStatLossEnabled() {
|
||||
return mcMMO.p.getSkillTools().getHardcoreStatLossEnabled(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getHardcoreVampirismEnabled(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getHardcoreVampirismEnabled() {
|
||||
return mcMMO.p.getSkillTools().getHardcoreVampirismEnabled(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getPrimarySkillToolType(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public ToolType getTool() {
|
||||
return mcMMO.p.getSkillTools().getPrimarySkillToolType(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getSubSkills(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public List<SubSkillType> getSkillAbilities() {
|
||||
return new ArrayList<>(mcMMO.p.getSkillTools().getSubSkills(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getXpModifier(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public double getXpModifier() {
|
||||
return mcMMO.p.getSkillTools().getXpModifier(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#matchSkill(java.lang.String)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static PrimarySkillType getSkill(String skillName) {
|
||||
return mcMMO.p.getSkillTools().matchSkill(skillName);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#isChildSkill(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isChildSkill() {
|
||||
return SkillTools.isChildSkill(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getPrimarySkillBySubSkill(com.gmail.nossr50.datatypes.skills.SubSkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static PrimarySkillType bySecondaryAbility(SubSkillType subSkillType) {
|
||||
return mcMMO.p.getSkillTools().getPrimarySkillBySubSkill(subSkillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getPrimarySkillBySuperAbility(com.gmail.nossr50.datatypes.skills.SuperAbilityType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static PrimarySkillType byAbility(SuperAbilityType superAbilityType) {
|
||||
return mcMMO.p.getSkillTools().getPrimarySkillBySuperAbility(superAbilityType);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#getLocalizedSkillName(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public String getName() {
|
||||
return mcMMO.p.getSkillTools().getLocalizedSkillName(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see Permissions#skillEnabled(org.bukkit.permissions.Permissible, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
* @deprecated this is being removed in an upcoming update
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getPermissions(Player player) {
|
||||
return mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
* @return the max level of this skill
|
||||
* @see SkillTools#canCombatSkillsTrigger(com.gmail.nossr50.datatypes.skills.PrimarySkillType, org.bukkit.entity.Entity)
|
||||
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean shouldProcess(Entity target) {
|
||||
return mcMMO.p.getSkillTools().canCombatSkillsTrigger(this, target);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
//package com.gmail.nossr50.datatypes.skills;
|
||||
//
|
||||
//import com.gmail.nossr50.locale.LocaleLoader;
|
||||
//import com.gmail.nossr50.mcMMO;
|
||||
//import com.gmail.nossr50.util.text.StringUtils;
|
||||
//import com.neetgames.mcmmo.api.SkillRegister;
|
||||
//import com.neetgames.mcmmo.skill.*;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * Skills mcMMO is aware of are registered here
|
||||
// * The skill register will be used for a few things in mcMMO
|
||||
// * Removing a skill from the register doesn't mean it isn't doing anything as the register is simply for mcMMO's own awareness
|
||||
// * When a player uses certain commands, such as checking their skill levels, if the skill isn't registered it won't be added to the resulting output of that command
|
||||
// */
|
||||
//public class SkillRegisterImpl implements SkillRegister {
|
||||
// //TODO: Move maps and collections to their own container
|
||||
// private final @NotNull HashMap<String, Skill> skillNameMap;
|
||||
// private final @NotNull Set<Skill> registeredSkills;
|
||||
// private final @NotNull Set<SuperSkill> superSkills;
|
||||
// private final @NotNull Set<RankedSkill> rankedSkills;
|
||||
// private final @NotNull Set<RootSkill> primarySkillTypes; //Can include not-official root skills
|
||||
// private final @NotNull Set<CoreRootSkill> coreRootSkills; //Only includes official root skills
|
||||
// private final @NotNull Set<CoreSkill> coreSkills; //Only includes official core skills
|
||||
//
|
||||
// public SkillRegisterImpl() {
|
||||
// skillNameMap = new HashMap<>();
|
||||
// registeredSkills = new HashSet<>();
|
||||
// primarySkillTypes = new HashSet<>();
|
||||
// superSkills = new HashSet<>();
|
||||
// rankedSkills = new HashSet<>();
|
||||
// coreRootSkills = new HashSet<>();
|
||||
// coreSkills = new HashSet<>();
|
||||
//
|
||||
// //TODO: allow config to turn off certain core skills
|
||||
// registerCoreSkills();
|
||||
// }
|
||||
//
|
||||
// private void registerCoreSkills() {
|
||||
// for(CoreRootSkill coreRootSkill : PrimarySkillType.getCoreRootSkills()) {
|
||||
// mcMMO.p.getLogger().info("Registering core skill: " + coreRootSkill.getRawSkillName());
|
||||
// registerSkill(coreRootSkill);
|
||||
// }
|
||||
//
|
||||
// for(CoreSkill coreSkill : PrimarySkillType.)
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @Nullable Skill getSkill(@NotNull String fullyQualifiedName) {
|
||||
// return skillNameMap.get(fullyQualifiedName);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @Nullable Skill getSkill(@NotNull SkillIdentity skillIdentity) {
|
||||
// return skillNameMap.get(skillIdentity.getFullyQualifiedName());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Set<SuperSkill> getSuperSkills() {
|
||||
// return superSkills;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Set<RankedSkill> getRankedSkills() {
|
||||
// return rankedSkills;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Set<RootSkill> getRootSkills() {
|
||||
// return primarySkillTypes;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isSkillRegistered(@NotNull Skill skill) {
|
||||
// return registeredSkills.contains(skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void registerSkill(@NotNull Skill skill) {
|
||||
// registeredSkills.add(skill);
|
||||
// addedSkillRegisterProcessing(skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void registerSkill(@NotNull Skill skill, boolean override) {
|
||||
// if(isSkillRegistered(skill) && override) {
|
||||
// registeredSkills.remove(skill);
|
||||
// }
|
||||
//
|
||||
// registeredSkills.add(skill);
|
||||
// addedSkillRegisterProcessing(skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Set<Skill> getRegisteredSkills() {
|
||||
// return registeredSkills;
|
||||
// }
|
||||
//
|
||||
// private void postRemovalSkillRegisterProcessing(@NotNull Skill skill) {
|
||||
// removeSkillNameLookup(skill);
|
||||
// removeCollectionCache(skill);
|
||||
// }
|
||||
//
|
||||
// private void removeCollectionCache(@NotNull Skill skill) {
|
||||
// //Remove from register cache(s)
|
||||
// if(skill instanceof CoreRootSkill) {
|
||||
// coreRootSkills.remove(skill);
|
||||
// }
|
||||
//
|
||||
// if(skill instanceof CoreSkill) {
|
||||
// coreSkills.remove(skill);
|
||||
// }
|
||||
//
|
||||
// if(skill instanceof RootSkill) {
|
||||
// primarySkillTypes.remove(skill);
|
||||
// }
|
||||
//
|
||||
// if (skill instanceof SuperSkill) {
|
||||
// superSkills.remove(skill);
|
||||
// }
|
||||
//
|
||||
// if(skill instanceof RankedSkill) {
|
||||
// rankedSkills.remove( skill);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void removeSkillNameLookup(@NotNull Skill skill) {
|
||||
// skillNameMap.remove(skill.getSkillIdentity().getFullyQualifiedName());
|
||||
// }
|
||||
//
|
||||
// private void addedSkillRegisterProcessing(@NotNull Skill skill) {
|
||||
// addSkillNameLookup(skill);
|
||||
// addCollectionCache(skill);
|
||||
// }
|
||||
//
|
||||
// private void addCollectionCache(@NotNull Skill skill) {
|
||||
// //Add to various collections for cached lookups
|
||||
// if(skill instanceof CoreSkill) {
|
||||
// coreSkills.add((CoreSkill) skill);
|
||||
// }
|
||||
//
|
||||
// if(skill instanceof CoreRootSkill) {
|
||||
// coreRootSkills.add((CoreRootSkill) skill);
|
||||
// }
|
||||
//
|
||||
// if(skill instanceof RootSkill) {
|
||||
// primarySkillTypes.add((RootSkill) skill);
|
||||
// }
|
||||
//
|
||||
// if (skill instanceof SuperSkill) {
|
||||
// superSkills.add((SuperSkill) skill);
|
||||
// }
|
||||
//
|
||||
// if(skill instanceof RankedSkill) {
|
||||
// rankedSkills.add((RankedSkill) skill);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void addSkillNameLookup(@NotNull Skill skill) {
|
||||
// skillNameMap.put(skill.getSkillIdentity().getFullyQualifiedName(), skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void unregisterSkill(@NotNull Skill skill) {
|
||||
// mcMMO.p.getLogger().info("Skill "+skill.toString()+" has been removed from the skill register.");
|
||||
// registeredSkills.remove(skill);
|
||||
// skillNameMap.remove(skill.getSkillIdentity().getFullyQualifiedName());
|
||||
//
|
||||
// //Collection cache cleanup
|
||||
// postRemovalSkillRegisterProcessing(skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Set<CoreRootSkill> getCoreRootSkills() {
|
||||
// return coreRootSkills;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Used to match skill by a "skill name"
|
||||
// * This is NOT case sensitive
|
||||
// *
|
||||
// * Will match against any registered root skill if one of the following is true
|
||||
// * 1) The skills localized name is equal to the provided {@link String skillName}
|
||||
// * 2) The provided {@link String skillName} matches a root skill's fully qualified name
|
||||
// * 3) The provided {@link String skillName} matches the name of the default name of the skill (the en_US not localized name, this name is never overridden by locale)
|
||||
// *
|
||||
// * @param skillName skill name or skill identity
|
||||
// * @return The matching {@link RootSkill} if it exists
|
||||
// * @see SkillIdentity#getFullyQualifiedName()
|
||||
// */
|
||||
// public @Nullable RootSkill matchRootSkill(@NotNull String skillName) {
|
||||
// for (PrimarySkillType primarySkillType : primarySkillTypes) {
|
||||
// if (primarySkillType.getSkillIdentity().getFullyQualifiedName().equalsIgnoreCase(skillName)
|
||||
// || skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(primarySkillType.getRawSkillName()) + ".SkillName"))
|
||||
// || primarySkillType.getRawSkillName().equalsIgnoreCase(skillName)) {
|
||||
// return primarySkillType;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
@@ -107,7 +107,17 @@ public enum SubSkillType {
|
||||
WOODCUTTING_LEAF_BLOWER(1),
|
||||
/* WOODCUTTING_NATURES_BOUNTY(3),
|
||||
WOODCUTTING_SPLINTER(3),*/
|
||||
WOODCUTTING_TREE_FELLER(1);
|
||||
WOODCUTTING_TREE_FELLER(1),
|
||||
|
||||
/* TRIDENTS */
|
||||
TRIDENTS_MULTI_TASKING(5),
|
||||
TRIDENTS_TRIDENTS_LIMIT_BREAK(10),
|
||||
|
||||
/* CROSSBOWS */
|
||||
|
||||
CROSSBOWS_SUPER_SHOTGUN(3),
|
||||
CROSSBOWS_CROSSBOWS_LIMIT_BREAK(10);
|
||||
|
||||
|
||||
private final int numRanks;
|
||||
//TODO: SuperAbilityType should also contain flags for active by default? Not sure if it should work that way.
|
||||
|
||||
@@ -76,6 +76,31 @@ public enum SuperAbilityType {
|
||||
"Mining.Blast.Refresh",
|
||||
null,
|
||||
"Mining.SubSkill.BlastMining.Name"),
|
||||
|
||||
ARCHERY_SUPER(
|
||||
"Archery.SuperAbility.SuperAbilityName.On",
|
||||
"Archery.SuperAbility.SuperAbilityName.Off",
|
||||
"Archery.SuperAbility.SuperAbilityName.InformOthers.On",
|
||||
"Archery.SuperAbility.SuperAbilityName.Refresh",
|
||||
"Archery.SuperAbility.SuperAbilityName.InformOthers.Off",
|
||||
"Archery.SuperAbility.SuperAbilityName.Name"
|
||||
),
|
||||
SUPER_SHOTGUN(
|
||||
"Crossbows.SuperAbility.SuperShotgun.On",
|
||||
"Crossbows.SuperAbility.SuperShotgun.Off",
|
||||
"Crossbows.SuperAbility.SuperShotgun.InformOthers.On",
|
||||
"Crossbows.SuperAbility.SuperShotgun.Refresh",
|
||||
"Crossbows.SuperAbility.SuperShotgun.InformOthers.Off",
|
||||
"Crossbows.SuperAbility.SuperShotgun.Name"
|
||||
),
|
||||
TRIDENT_SUPER(
|
||||
"Tridents.SuperAbility.SuperAbilityName.On",
|
||||
"Tridents.SuperAbility.SuperAbilityName.Off",
|
||||
"Tridents.SuperAbility.SuperAbilityName.InformOthers.On",
|
||||
"Tridents.SuperAbility.SuperAbilityName.Refresh",
|
||||
"Tridents.SuperAbility.SuperAbilityName.InformOthers.Off",
|
||||
"Tridents.SuperAbility.SuperAbilityName.Name"
|
||||
),
|
||||
;
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.neetgames.mcmmo.skill.RootSkill;
|
||||
import com.neetgames.mcmmo.skill.SuperSkill;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SuperCoreSkill extends CoreSkill implements SuperSkill {
|
||||
|
||||
private final int defaultCooldown;
|
||||
|
||||
public SuperCoreSkill(@NotNull String pluginName, @NotNull String skillName, @Nullable String permission, @NotNull RootSkill parentSkill, int defaultCooldown) {
|
||||
super(pluginName, skillName, permission, parentSkill);
|
||||
this.defaultCooldown = defaultCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultCooldown() {
|
||||
return defaultCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown(@NotNull OnlineMMOPlayer onlineMMOPlayer) {
|
||||
return PerksUtils.handleCooldownPerks((Player) onlineMMOPlayer.getServerAPIPlayerImpl(), defaultCooldown);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum ToolType {
|
||||
AXE("Axes.Ability.Lower", "Axes.Ability.Ready"),
|
||||
FISTS("Unarmed.Ability.Lower", "Unarmed.Ability.Ready"),
|
||||
HOE("Herbalism.Ability.Lower", "Herbalism.Ability.Ready"),
|
||||
PICKAXE("Mining.Ability.Lower", "Mining.Ability.Ready"),
|
||||
SHOVEL("Excavation.Ability.Lower", "Excavation.Ability.Ready"),
|
||||
SWORD("Swords.Ability.Lower", "Swords.Ability.Ready");
|
||||
|
||||
private final String lowerTool;
|
||||
private final String raiseTool;
|
||||
|
||||
ToolType(String lowerTool, String raiseTool) {
|
||||
this.lowerTool = lowerTool;
|
||||
this.raiseTool = raiseTool;
|
||||
}
|
||||
|
||||
public String getLowerTool() {
|
||||
return lowerTool;
|
||||
}
|
||||
|
||||
public String getRaiseTool() {
|
||||
return raiseTool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the item is of the appropriate type.
|
||||
*
|
||||
* @param itemStack The item to check
|
||||
* @return true if the item is the right type, false otherwise
|
||||
*/
|
||||
public boolean inHand(ItemStack itemStack) {
|
||||
switch (this) {
|
||||
case AXE:
|
||||
return ItemUtils.isAxe(itemStack);
|
||||
|
||||
case FISTS:
|
||||
return itemStack.getType() == Material.AIR;
|
||||
|
||||
case HOE:
|
||||
return ItemUtils.isHoe(itemStack);
|
||||
|
||||
case PICKAXE:
|
||||
return ItemUtils.isPickaxe(itemStack);
|
||||
|
||||
case SHOVEL:
|
||||
return ItemUtils.isShovel(itemStack);
|
||||
|
||||
case SWORD:
|
||||
return ItemUtils.isSword(itemStack);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.skills.interfaces;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
|
||||
public interface ChildSkill extends Skill {
|
||||
/**
|
||||
* Get's the other parent for this Skill
|
||||
* @return the other parent
|
||||
*/
|
||||
PrimarySkillType getSecondParent();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.skills.interfaces;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
|
||||
/**
|
||||
* This interface is mostly here to maintain backwards compatibility with other mcMMO plugins
|
||||
* Only Core Skills will make use of this
|
||||
* Previously in mcMMO subskills were basically defined by the SecondaryAbility ENUM
|
||||
* In the new system which I'm gradually converting all the existing skills to, skills instead are unique instances of AbstractSubSkill
|
||||
*/
|
||||
public interface CoreSkill {
|
||||
/**
|
||||
* Gets the associated SubSkillType for this subskill
|
||||
* @return the associated SubSkillType ENUM definition
|
||||
*/
|
||||
SubSkillType getSubSkillType();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.skills.interfaces;
|
||||
|
||||
/**
|
||||
* Localized interface represents skills which have localizations
|
||||
* Skills with localizations will use their localization names/descriptions when being printed
|
||||
*/
|
||||
public interface Localized {
|
||||
/**
|
||||
* The translated name for this locale
|
||||
* @return the translated name for this locale
|
||||
*/
|
||||
String getLocaleName();
|
||||
|
||||
/**
|
||||
* The translated name for this subskill description
|
||||
* @return
|
||||
*/
|
||||
String getLocaleDescription();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.skills.interfaces;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
|
||||
public interface Skill {
|
||||
/**
|
||||
* The primary skill
|
||||
* @return this primary skill
|
||||
*/
|
||||
PrimarySkillType getPrimarySkill();
|
||||
|
||||
/**
|
||||
* Returns the key name used for this skill in conjunction with config files
|
||||
* @return config file key name
|
||||
*/
|
||||
String getPrimaryKeyName();
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.skills.interfaces;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface Toolable {
|
||||
/**
|
||||
* Whether or not this Skill requires a tool
|
||||
* Not all skills will require a tool
|
||||
* @return true if tool is required
|
||||
*/
|
||||
boolean requiresTool();
|
||||
|
||||
/**
|
||||
* The tools associated with this Skill
|
||||
* @return the tools
|
||||
*/
|
||||
Collection<ItemStack> getTools();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.skills.subskills.acrobatics;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
@@ -13,7 +12,6 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
@@ -22,6 +20,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.Location;
|
||||
@@ -67,9 +66,9 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
return false;
|
||||
|
||||
if (entityDamageEvent.getCause() == EntityDamageEvent.DamageCause.FALL) {//Grab the player
|
||||
McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
|
||||
OnlineMMOPlayer mmoPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
|
||||
|
||||
if (mcMMOPlayer == null)
|
||||
if (mmoPlayer == null)
|
||||
return false;
|
||||
|
||||
/*
|
||||
@@ -77,7 +76,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
*/
|
||||
Player player = (Player) ((EntityDamageEvent) event).getEntity();
|
||||
if (canRoll(player)) {
|
||||
entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getFinalDamage()));
|
||||
entityDamageEvent.setDamage(rollCheck(player, mmoPlayer, entityDamageEvent.getFinalDamage()));
|
||||
|
||||
if (entityDamageEvent.getFinalDamage() == 0) {
|
||||
entityDamageEvent.setCancelled(true);
|
||||
@@ -124,8 +123,8 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
|
||||
|
||||
/* Values related to the player */
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
float skillValue = mmoPlayer.getExperienceHandler().getSkillLevel(getPrimarySkill());
|
||||
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
|
||||
|
||||
String[] rollStrings = RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
|
||||
@@ -191,12 +190,12 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
private double rollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage) {
|
||||
private double rollCheck(Player player, OnlineMMOPlayer mmoPlayer, double damage) {
|
||||
|
||||
int skillLevel = mcMMOPlayer.getSkillLevel(getPrimarySkill());
|
||||
int skillLevel = mmoPlayer.getExperienceHandler().getSkillLevel(getPrimarySkill());
|
||||
|
||||
if (player.isSneaking()) {
|
||||
return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel);
|
||||
return gracefulRollCheck(player, mmoPlayer, damage, skillLevel);
|
||||
}
|
||||
|
||||
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.p.getAdvancedConfig().getRollDamageThreshold());
|
||||
@@ -207,18 +206,18 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
|
||||
//player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
||||
|
||||
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
|
||||
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
|
||||
//if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
|
||||
if(!isExploiting(player) && ((McMMOPlayer) (mmoPlayer)).getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
|
||||
//}
|
||||
|
||||
addFallLocation(player);
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(player, damage)) {
|
||||
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
|
||||
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
|
||||
//if (!SkillUtils.cooldownExpired((long) mmoPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
|
||||
if(!isExploiting(player) && ((McMMOPlayer) (mmoPlayer)).getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -226,8 +225,8 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
return damage;
|
||||
}
|
||||
|
||||
private int getActivationChance(McMMOPlayer mcMMOPlayer) {
|
||||
return PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill());
|
||||
private int getActivationChance(OnlineMMOPlayer mmoPlayer) {
|
||||
return PerksUtils.handleLuckyPerks(Misc.adaptPlayer(mmoPlayer), getPrimarySkill());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +235,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||
*/
|
||||
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
|
||||
private double gracefulRollCheck(Player player, OnlineMMOPlayer mmoPlayer, double damage, int skillLevel) {
|
||||
double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.p.getAdvancedConfig().getRollDamageThreshold() * 2);
|
||||
|
||||
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType);
|
||||
@@ -247,15 +246,15 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
{
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
|
||||
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
|
||||
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
|
||||
if(!isExploiting(player) && ((McMMOPlayer) (mmoPlayer)).getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
|
||||
|
||||
addFallLocation(player);
|
||||
return modifiedDamage;
|
||||
}
|
||||
else if (!isFatal(player, damage)) {
|
||||
if(!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
|
||||
if(!isExploiting(player) && ((McMMOPlayer) (mmoPlayer)).getAcrobaticsManager().canGainRollXP())
|
||||
SkillUtils.applyXpGain(mmoPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
|
||||
|
||||
addFallLocation(player);
|
||||
}
|
||||
@@ -274,19 +273,19 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
return false;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
if (ItemUtils.hasItemInEitherHand(player, Material.ENDER_PEARL) || player.isInsideVehicle()) {
|
||||
if(mcMMOPlayer.isDebugMode()) {
|
||||
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
Misc.adaptPlayer(mmoPlayer).sendMessage("Acrobatics XP Prevented: Ender Pearl or Inside Vehicle");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
|
||||
if(UserManager.queryPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
|
||||
{
|
||||
if(mcMMOPlayer.isDebugMode()) {
|
||||
mcMMOPlayer.getPlayer().sendMessage("Acrobatics XP Prevented: Fallen in location before");
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
Misc.adaptPlayer(mmoPlayer).sendMessage("Acrobatics XP Prevented: Fallen in location before");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -428,7 +427,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
|
||||
public void addFallLocation(Player player)
|
||||
{
|
||||
UserManager.getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
|
||||
UserManager.queryPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
|
||||
}
|
||||
|
||||
public Location getBlockLocation(Player player)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.datatypes.skills.subskills.interfaces;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface SubSkill extends Skill {
|
||||
/**
|
||||
@@ -59,9 +61,9 @@ public interface SubSkill extends Skill {
|
||||
/**
|
||||
* Adds detailed stats specific to this skill
|
||||
* @param componentBuilder target component builder
|
||||
* @param player owner of this skill
|
||||
* @param mmoPlayer owner of this skill
|
||||
*/
|
||||
void addStats(TextComponent.Builder componentBuilder, Player player);
|
||||
void addStats(TextComponent.Builder componentBuilder, @NotNull OnlineMMOPlayer mmoPlayer);
|
||||
|
||||
/**
|
||||
* Whether or not this subskill is enabled
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.datatypes.validation;
|
||||
|
||||
public class NonNullRule<T> extends Rule<T> {
|
||||
@Override
|
||||
public void applyRule(T object) throws NullPointerException {
|
||||
if(object == null)
|
||||
throw new NullPointerException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.gmail.nossr50.datatypes.validation;
|
||||
|
||||
import com.neetgames.mcmmo.exceptions.UnexpectedValueException;
|
||||
|
||||
public class PositiveIntegerRule<T extends Number> extends Rule<T> {
|
||||
@Override
|
||||
public void applyRule(T number) throws UnexpectedValueException {
|
||||
if(number.intValue() < 0)
|
||||
throw new UnexpectedValueException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.gmail.nossr50.datatypes.validation;
|
||||
|
||||
public abstract class Rule<T> {
|
||||
public abstract void applyRule(T object) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gmail.nossr50.datatypes.validation;
|
||||
|
||||
public interface Validates<T> {
|
||||
/**
|
||||
* Perform a validation check on this object
|
||||
* Returns the value if validation passes
|
||||
* @return the object
|
||||
* @throws Exception if the object fails validation
|
||||
* @param object
|
||||
*/
|
||||
T validate(T object) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gmail.nossr50.datatypes.validation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Validator<T> implements Validates<T> {
|
||||
private List<Rule<T>> rulesList;
|
||||
|
||||
public Validator() {
|
||||
this.rulesList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T validate(T object) throws Exception {
|
||||
for(Rule<T> rule : rulesList) {
|
||||
rule.applyRule(object);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public void addRule(Rule<T> newRule) {
|
||||
rulesList.add(newRule);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import com.gmail.nossr50.chat.message.PartyChatMessage;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExperienceCaptureEvent extends PlayerEvent {
|
||||
|
||||
public ExperienceCaptureEvent(@NotNull Player who) {
|
||||
super(who);
|
||||
}
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -35,7 +35,6 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
||||
} else {
|
||||
this.skillLevel = 0;
|
||||
}
|
||||
|
||||
this.xpGainReason = xpGainReason;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private final String oldAlly;
|
||||
private final String newAlly;
|
||||
private final EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
if (newAlly != null) {
|
||||
newAlly = newAlly.replace(":", ".");
|
||||
}
|
||||
|
||||
this.oldAlly = oldAlly;
|
||||
this.newAlly = newAlly;
|
||||
this.reason = reason;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being left, or null if the player was not in a party
|
||||
*/
|
||||
public String getOldAlly() {
|
||||
return oldAlly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being joined, or null if the player is not joining a new party
|
||||
*/
|
||||
public String getNewAlly() {
|
||||
return newAlly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The reason for the event being fired
|
||||
*/
|
||||
public EventReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Formed an alliance for the first time.
|
||||
*/
|
||||
FORMED_ALLIANCE,
|
||||
|
||||
/**
|
||||
* Left a party and did not join a new one.
|
||||
*/
|
||||
DISBAND_ALLIANCE,
|
||||
|
||||
/**
|
||||
* Any reason that doesn't fit elsewhere.
|
||||
*/
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.bukkit.event.player.PlayerEvent;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
|
||||
// private final String oldAlly;
|
||||
// private final String newAlly;
|
||||
// private final EventReason reason;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) {
|
||||
// super(player);
|
||||
//
|
||||
// if (newAlly != null) {
|
||||
// newAlly = newAlly.replace(":", ".");
|
||||
// }
|
||||
//
|
||||
// this.oldAlly = oldAlly;
|
||||
// this.newAlly = newAlly;
|
||||
// this.reason = reason;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being left, or null if the player was not in a party
|
||||
// */
|
||||
// public String getOldAlly() {
|
||||
// return oldAlly;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being joined, or null if the player is not joining a new party
|
||||
// */
|
||||
// public String getNewAlly() {
|
||||
// return newAlly;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The reason for the event being fired
|
||||
// */
|
||||
// public EventReason getReason() {
|
||||
// return reason;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * A list of reasons why the event may have been fired
|
||||
// */
|
||||
// public enum EventReason {
|
||||
// /**
|
||||
// * Formed an alliance for the first time.
|
||||
// */
|
||||
// FORMED_ALLIANCE,
|
||||
//
|
||||
// /**
|
||||
// * Left a party and did not join a new one.
|
||||
// */
|
||||
// DISBAND_ALLIANCE,
|
||||
//
|
||||
// /**
|
||||
// * Any reason that doesn't fit elsewhere.
|
||||
// */
|
||||
// CUSTOM
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// 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 @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,104 +1,75 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player attempts to join, leave, or change parties.
|
||||
*/
|
||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private final String oldParty;
|
||||
private final String newParty;
|
||||
private final EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
if (newParty != null) {
|
||||
newParty = newParty.replace(":", ".");
|
||||
}
|
||||
|
||||
this.oldParty = oldParty;
|
||||
this.newParty = newParty;
|
||||
this.reason = reason;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being left, or null if the player was not in a party
|
||||
*/
|
||||
public String getOldParty() {
|
||||
return oldParty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being joined, or null if the player is not joining a new party
|
||||
*/
|
||||
public String getNewParty() {
|
||||
return newParty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The reason for the event being fired
|
||||
*/
|
||||
public EventReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Joined a party for the first time.
|
||||
*/
|
||||
JOINED_PARTY,
|
||||
|
||||
/**
|
||||
* Left a party and did not join a new one.
|
||||
*/
|
||||
LEFT_PARTY,
|
||||
|
||||
/**
|
||||
* Was kicked from a party.
|
||||
*/
|
||||
KICKED_FROM_PARTY,
|
||||
|
||||
/**
|
||||
* Left one party to join another.
|
||||
*/
|
||||
CHANGED_PARTIES,
|
||||
|
||||
/**
|
||||
* Any reason that doesn't fit elsewhere.
|
||||
*/
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import com.neetgames.mcmmo.party.PartyEventReason;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.bukkit.event.player.PlayerEvent;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
///**
|
||||
// * Called when a player attempts to join, leave, or change parties.
|
||||
// */
|
||||
//public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
// private final String oldParty;
|
||||
// private final String newParty;
|
||||
// private final PartyEventReason reason;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyChangeEvent(@NotNull Player player, @NotNull String oldParty, @NotNull String newParty, PartyEventReason reason) {
|
||||
// super(player);
|
||||
//
|
||||
// if (newParty != null) {
|
||||
// newParty = newParty.replace(":", ".");
|
||||
// }
|
||||
//
|
||||
// this.oldParty = oldParty;
|
||||
// this.newParty = newParty;
|
||||
// this.reason = reason;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being left, or null if the player was not in a party
|
||||
// */
|
||||
// public String getOldParty() {
|
||||
// return oldParty;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being joined, or null if the player is not joining a new party
|
||||
// */
|
||||
// public String getNewParty() {
|
||||
// return newParty;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The reason for the event being fired
|
||||
// */
|
||||
// public PartyEventReason getReason() {
|
||||
// return reason;
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// 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 @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
|
||||
private final Party party;
|
||||
private int levelsChanged;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyLevelUpEvent(Party party, int levelsChanged) {
|
||||
this.party = party;
|
||||
this.levelsChanged = levelsChanged;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public int getLevelsChanged() {
|
||||
return levelsChanged;
|
||||
}
|
||||
|
||||
public void setLevelsChanged(int levelsChanged) {
|
||||
this.levelsChanged = levelsChanged;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import com.neetgames.mcmmo.party.Party;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.Event;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
|
||||
// private final Party party;
|
||||
// private int levelsChanged;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyLevelUpEvent(Party party, int levelsChanged) {
|
||||
// this.party = party;
|
||||
// this.levelsChanged = levelsChanged;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// public Party getParty() {
|
||||
// return party;
|
||||
// }
|
||||
//
|
||||
// public int getLevelsChanged() {
|
||||
// return levelsChanged;
|
||||
// }
|
||||
//
|
||||
// public void setLevelsChanged(int levelsChanged) {
|
||||
// this.levelsChanged = levelsChanged;
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// 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 @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called just before a player teleports using the /ptp command.
|
||||
*/
|
||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||
private final String party;
|
||||
private final Player target;
|
||||
|
||||
public McMMOPartyTeleportEvent(Player player, Player target, String party) {
|
||||
super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
|
||||
this.party = party;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party the teleporting player is in
|
||||
*/
|
||||
public String getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The player being teleported to
|
||||
*/
|
||||
public Player getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
///**
|
||||
// * Called just before a player teleports using the /ptp command.
|
||||
// */
|
||||
//public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||
// private final String party;
|
||||
// private final Player target;
|
||||
//
|
||||
// public McMMOPartyTeleportEvent(Player player, Player target, String party) {
|
||||
// super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
|
||||
// this.party = party;
|
||||
// this.target = target;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party the teleporting player is in
|
||||
// */
|
||||
// public String getParty() {
|
||||
// return party;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The player being teleported to
|
||||
// */
|
||||
// public Player getTarget() {
|
||||
// return target;
|
||||
// }
|
||||
//
|
||||
// /** Rest of file is required boilerplate for custom events **/
|
||||
// private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static @NotNull HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPartyXpGainEvent extends Event implements Cancellable {
|
||||
private final Party party;
|
||||
private float xpGained;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyXpGainEvent(Party party, float xpGained) {
|
||||
this.party = party;
|
||||
this.xpGained = xpGained;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The amount of experience gained in this event
|
||||
*/
|
||||
public float getRawXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int amount of experience gained in this event
|
||||
*/
|
||||
@Deprecated
|
||||
public int getXpGained() {
|
||||
return (int) xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xpGained set amount of experience gained in this event
|
||||
*/
|
||||
public void setRawXpGained(float xpGained) {
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xpGained set int amount of experience gained in this event
|
||||
*/
|
||||
@Deprecated
|
||||
public void setXpGained(int xpGained) {
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import com.neetgames.mcmmo.party.Party;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.Event;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//public class McMMOPartyXpGainEvent extends Event implements Cancellable {
|
||||
// private final Party party;
|
||||
// private float xpGained;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyXpGainEvent(Party party, float xpGained) {
|
||||
// this.party = party;
|
||||
// this.xpGained = xpGained;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// public Party getParty() {
|
||||
// return party;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The amount of experience gained in this event
|
||||
// */
|
||||
// public float getRawXpGained() {
|
||||
// return xpGained;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return int amount of experience gained in this event
|
||||
// */
|
||||
// @Deprecated
|
||||
// public int getXpGained() {
|
||||
// return (int) xpGained;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param xpGained set amount of experience gained in this event
|
||||
// */
|
||||
// public void setRawXpGained(float xpGained) {
|
||||
// this.xpGained = xpGained;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param xpGained set int amount of experience gained in this event
|
||||
// */
|
||||
// @Deprecated
|
||||
// public void setXpGained(int xpGained) {
|
||||
// this.xpGained = xpGained;
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// 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 @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.events.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
@@ -5,10 +5,9 @@ import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityToolType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -27,6 +26,7 @@ import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.entity.Item;
|
||||
@@ -248,16 +248,16 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
if(mcMMOPlayer == null)
|
||||
if(mmoPlayer == null)
|
||||
return;
|
||||
|
||||
if (blockState.getType() == Repair.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.REPAIR)) {
|
||||
mcMMOPlayer.getRepairManager().placedAnvilCheck();
|
||||
((McMMOPlayer) (mmoPlayer)).getRepairManager().placedAnvilCheck();
|
||||
}
|
||||
else if (blockState.getType() == Salvage.anvilMaterial && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.SALVAGE)) {
|
||||
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
|
||||
((McMMOPlayer) (mmoPlayer)).getSalvageManager().placedAnvilCheck();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,10 +338,10 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
//Check if profile is loaded
|
||||
if(mcMMOPlayer == null) {
|
||||
if(mmoPlayer == null) {
|
||||
/* Remove metadata from placed watched blocks */
|
||||
mcMMO.getPlaceStore().setFalse(blockState);
|
||||
return;
|
||||
@@ -351,11 +351,11 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||
HerbalismManager herbalismManager = ((McMMOPlayer) (mmoPlayer)).getHerbalismManager();
|
||||
|
||||
/* Green Terra */
|
||||
if (herbalismManager.canActivateAbility()) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
|
||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -374,14 +374,14 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* MINING */
|
||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
MiningManager miningManager = ((McMMOPlayer) (mmoPlayer)).getMiningManager();
|
||||
miningManager.miningBlockCheck(blockState);
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockUtils.hasWoodcuttingXP(blockState) && ItemUtils.isAxe(heldItem)
|
||||
&& mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||
WoodcuttingManager woodcuttingManager = ((McMMOPlayer) (mmoPlayer)).getWoodcuttingManager();
|
||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||
woodcuttingManager.processTreeFeller(blockState);
|
||||
}
|
||||
@@ -396,10 +396,10 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
||||
ExcavationManager excavationManager = ((McMMOPlayer) (mmoPlayer)).getExcavationManager();
|
||||
excavationManager.excavationBlockCheck(blockState);
|
||||
|
||||
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) {
|
||||
excavationManager.gigaDrillBreaker(blockState);
|
||||
}
|
||||
}
|
||||
@@ -437,7 +437,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class BlockListener implements Listener {
|
||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (ItemUtils.isSword(heldItem)) {
|
||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||
HerbalismManager herbalismManager = UserManager.queryPlayer(player).getHerbalismManager();
|
||||
|
||||
if (herbalismManager.canUseHylianLuck()) {
|
||||
if (herbalismManager.processHylianLuck(blockState)) {
|
||||
@@ -500,10 +500,10 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
//Profile not loaded
|
||||
if(mcMMOPlayer == null)
|
||||
if(mmoPlayer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -516,25 +516,25 @@ public class BlockListener implements Listener {
|
||||
if (BlockUtils.canActivateAbilities(blockState)) {
|
||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
|
||||
if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GREEN_TERRA_TOOL) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && Permissions.treeFeller(player)) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING);
|
||||
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && Permissions.treeFeller(player)) {
|
||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING);
|
||||
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.MINING);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
|
||||
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GIGA_DRILL_BREAKER_TOOL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.EXCAVATION);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState)
|
||||
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.BERSERK_TOOL) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState)
|
||||
|| mcMMO.getMaterialMapStore().isGlass(blockState.getType())
|
||||
|| blockState.getType() == Material.SNOW
|
||||
|| BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
|
||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.UNARMED);
|
||||
|
||||
if(mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK)) {
|
||||
if(mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK)) {
|
||||
if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
||||
event.setInstaBreak(true);
|
||||
|
||||
@@ -553,7 +553,7 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.hasWoodcuttingXP(blockState) && mcMMO.p.getGeneralConfig().getTreeFellerSoundsEnabled()) {
|
||||
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.hasWoodcuttingXP(blockState) && mcMMO.p.getGeneralConfig().getTreeFellerSoundsEnabled()) {
|
||||
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
|
||||
}
|
||||
}
|
||||
@@ -586,10 +586,10 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -603,14 +603,14 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
|
||||
if (mcMMOPlayer.getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
|
||||
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
|
||||
if (((McMMOPlayer) (mmoPlayer)).getHerbalismManager().processGreenTerraBlockConversion(blockState)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
|
||||
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
|
||||
if (EventUtils.simulateBlockBreak(block, player, true) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||
else if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
|
||||
if (((McMMOPlayer) (mmoPlayer)).getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
|
||||
if (EventUtils.simulateBlockBreak(block, player, true) && ((McMMOPlayer) (mmoPlayer)).getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||
blockState.update();
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||
else if (((McMMOPlayer) (mmoPlayer)).getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||
event.setInstaBreak(true);
|
||||
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
||||
}
|
||||
@@ -633,10 +633,10 @@ public class BlockListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockDamageCleanup(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -645,7 +645,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||
|
||||
cleanupAbilityTools(player, mcMMOPlayer, blockState, heldItem);
|
||||
cleanupAbilityTools(player, mmoPlayer, blockState, heldItem);
|
||||
|
||||
debugStickDump(player, blockState);
|
||||
}
|
||||
@@ -654,19 +654,19 @@ public class BlockListener implements Listener {
|
||||
//TODO: Convert into locale strings
|
||||
private void debugStickDump(Player player, BlockState blockState) {
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer(player).isDebugMode())
|
||||
if(UserManager.queryPlayer(player).isDebugMode())
|
||||
{
|
||||
if(mcMMO.getPlaceStore().isTrue(blockState))
|
||||
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
|
||||
else
|
||||
{
|
||||
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
|
||||
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
|
||||
UserManager.queryPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
|
||||
}
|
||||
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
@@ -705,13 +705,13 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
|
||||
private void cleanupAbilityTools(Player player, OnlineMMOPlayer mmoPlayer, BlockState blockState, ItemStack heldItem) {
|
||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
|
||||
if ((ItemUtils.isPickaxe(heldItem) && !mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
|
||||
SkillUtils.removeAbilityBuff(heldItem);
|
||||
}
|
||||
} else {
|
||||
if ((mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||
if ((mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
|
||||
SkillUtils.removeAbilityBoostsFromInventory(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//package com.gmail.nossr50.listeners;
|
||||
//
|
||||
//import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
//import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
//import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
//import com.gmail.nossr50.mcMMO;
|
||||
//import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -26,7 +26,7 @@
|
||||
//
|
||||
// SkillUtils.removeAbilityBoostsFromInventory(player);
|
||||
//
|
||||
// McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
// OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
//
|
||||
// if(mmoPlayer == null)
|
||||
// return;
|
||||
|
||||
@@ -2,14 +2,15 @@ package com.gmail.nossr50.listeners;
|
||||
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.meta.ProjectileOriginMeta;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
@@ -29,6 +30,7 @@ import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -168,34 +170,67 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity().getShooter() instanceof Player)
|
||||
{
|
||||
if(mcMMO.getSpawnedProjectileTracker().isSpawnedProjectile(event.getEntity())) {
|
||||
mcMMO.getSpawnedProjectileTracker().untrackProjectile(event.getEntity());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(event.getEntity().getShooter() instanceof Player) {
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile projectile = event.getEntity();
|
||||
EntityType entityType = projectile.getType();
|
||||
|
||||
if(entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
|
||||
if (entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
|
||||
CombatUtils.delayArrowMetaCleanup(projectile); //Cleans up metadata 1 minute from now in case other collection methods fall through
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.bowForceKey))
|
||||
if (!projectile.hasMetadata(mcMMO.bowForceKey))
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0));
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
if (!projectile.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
|
||||
boolean isCrossbow = false;
|
||||
|
||||
//Track origin of projectile
|
||||
if (ItemUtils.hasItemInMainHand(player, "bow")) {
|
||||
markProjectileOriginAsBow(projectile);
|
||||
} else if (ItemUtils.hasItemInMainHand(player, "crossbow")) {
|
||||
markProjectileOriginAsCrossbow(projectile);
|
||||
isCrossbow = true;
|
||||
} else if (ItemUtils.hasItemInOffHand(player, "bow")) {
|
||||
markProjectileOriginAsBow(projectile);
|
||||
} else if (ItemUtils.hasItemInOffHand(player, "crossbow")) {
|
||||
markProjectileOriginAsCrossbow(projectile);
|
||||
isCrossbow = true;
|
||||
}
|
||||
|
||||
//Crossbow only
|
||||
if (isCrossbow) {
|
||||
OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
|
||||
|
||||
//Process launch event
|
||||
if (Permissions.skillEnabled(player, PrimarySkillType.CROSSBOWS)) {
|
||||
if (mmoPlayer != null) {
|
||||
((McMMOPlayer) (mmoPlayer)).getCrossbowManager().processProjectileLaunchEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Check both hands
|
||||
if(ItemUtils.doesPlayerHaveEnchantmentInHands(player, "piercing")) {
|
||||
return;
|
||||
@@ -208,6 +243,14 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void markProjectileOriginAsCrossbow(@NotNull Projectile projectile) {
|
||||
projectile.setMetadata(mcMMO.PROJECTILE_ORIGIN_METAKEY, new ProjectileOriginMeta(plugin, 2));
|
||||
}
|
||||
|
||||
private void markProjectileOriginAsBow(@NotNull Projectile projectile) {
|
||||
projectile.setMetadata(mcMMO.PROJECTILE_ORIGIN_METAKEY, new ProjectileOriginMeta(plugin, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityChangeBlock events.
|
||||
*
|
||||
@@ -389,9 +432,9 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
//Deflect checks
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
|
||||
if (mcMMOPlayer != null) {
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
final OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(defendingPlayer);
|
||||
if (mmoPlayer != null) {
|
||||
UnarmedManager unarmedManager = ((McMMOPlayer) (mmoPlayer)).getUnarmedManager();
|
||||
|
||||
if (unarmedManager.canDeflect()) {
|
||||
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
|
||||
@@ -465,8 +508,8 @@ public class EntityListener implements Listener {
|
||||
|
||||
//Party Friendly Fire
|
||||
if(!mcMMO.p.getGeneralConfig().getPartyFriendlyFire())
|
||||
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer)
|
||||
|| PartyManager.areAllies(defendingPlayer, attackingPlayer))
|
||||
if ((mcMMO.getPartyManager().inSameParty(defendingPlayer, attackingPlayer)
|
||||
|| mcMMO.getPartyManager().areAllies(defendingPlayer, attackingPlayer))
|
||||
&& !(Permissions.friendlyFire(attackingPlayer)
|
||||
&& Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
@@ -551,20 +594,20 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
McMMOPlayer mmoPlayer = (McMMOPlayer) UserManager.queryPlayer(player);
|
||||
|
||||
//Profile not loaded
|
||||
if(mcMMOPlayer == null)
|
||||
if(mmoPlayer == null)
|
||||
return;
|
||||
|
||||
/* Check for invincibility */
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
if (mmoPlayer.isGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getFinalDamage() >= 1) {
|
||||
mcMMOPlayer.actualizeRecentlyHurt();
|
||||
mmoPlayer.actualizeRecentlyHurtTimestamp();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -589,12 +632,12 @@ public class EntityListener implements Listener {
|
||||
Wolf wolf = (Wolf) pet;
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager();
|
||||
TamingManager tamingManager = UserManager.queryPlayer(player).getTamingManager();
|
||||
|
||||
switch (cause) {
|
||||
case CONTACT:
|
||||
@@ -783,7 +826,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -795,7 +838,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
MiningManager miningManager = UserManager.queryPlayer(player).getMiningManager();
|
||||
|
||||
if (miningManager.canUseBiggerBombs()) {
|
||||
event.setRadius(miningManager.biggerBombs(event.getRadius()));
|
||||
@@ -836,12 +879,12 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
MiningManager miningManager = UserManager.queryPlayer(player).getMiningManager();
|
||||
|
||||
if (miningManager.canUseBlastMining()) {
|
||||
miningManager.blastMiningDropProcessing(event.getYield(), event);
|
||||
@@ -870,7 +913,7 @@ public class EntityListener implements Listener {
|
||||
Player player = (Player) entity;
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -935,7 +978,7 @@ public class EntityListener implements Listener {
|
||||
* 1000
|
||||
*/
|
||||
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
||||
event.setFoodLevel(UserManager.queryPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -947,7 +990,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
||||
event.setFoodLevel(UserManager.queryPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
||||
}
|
||||
return;
|
||||
case COD:
|
||||
@@ -957,7 +1000,7 @@ public class EntityListener implements Listener {
|
||||
case COOKED_SALMON:
|
||||
|
||||
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
|
||||
event.setFoodLevel(UserManager.queryPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -992,7 +1035,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
LivingEntity livingEntity = event.getEntity();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)
|
||||
if (UserManager.queryPlayer(player) == null
|
||||
|| (ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(livingEntity))
|
||||
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.EGG_MOB, livingEntity)
|
||||
|| persistentDataLayer.hasMobFlag(MobMetaFlagType.MOB_SPAWNER_MOB, livingEntity)) {
|
||||
@@ -1002,12 +1045,12 @@ public class EntityListener implements Listener {
|
||||
persistentDataLayer.flagMetadata(MobMetaFlagType.PLAYER_TAMED_MOB, livingEntity);
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).getTamingManager().awardTamingXP(livingEntity);
|
||||
UserManager.queryPlayer(player).getTamingManager().awardTamingXP(livingEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeBrewEvent;
|
||||
@@ -11,10 +10,10 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -66,13 +65,13 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
//Profile doesn't exist
|
||||
if(UserManager.getOfflinePlayer(offlinePlayer) == null)
|
||||
if(UserManager.queryOfflineMcMMOPlayer(offlinePlayer) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean debugMode = player.isOnline() && UserManager.getPlayer(player).isDebugMode();
|
||||
boolean debugMode = player.isOnline() && UserManager.queryPlayer(player).isDebugMode();
|
||||
|
||||
if(debugMode) {
|
||||
player.sendMessage("FURNACE FUEL EFFICIENCY DEBUG REPORT");
|
||||
@@ -81,7 +80,7 @@ public class InventoryListener implements Listener {
|
||||
player.sendMessage("Burn Length before Fuel Efficiency is applied - "+event.getBurnTime());
|
||||
}
|
||||
|
||||
event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
|
||||
event.setBurnTime(UserManager.queryPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
|
||||
|
||||
if(debugMode) {
|
||||
player.sendMessage("New Furnace Burn Length (after applying fuel efficiency) "+event.getBurnTime());
|
||||
@@ -111,7 +110,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
if(offlinePlayer != null) {
|
||||
|
||||
McMMOPlayer offlineProfile = UserManager.getOfflinePlayer(offlinePlayer);
|
||||
OnlineMMOPlayer offlineProfile = UserManager.queryOfflineMcMMOPlayer(offlinePlayer);
|
||||
|
||||
//Profile doesn't exist
|
||||
if(offlineProfile != null) {
|
||||
@@ -149,13 +148,13 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(UserManager.queryPlayer(player) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int xpToDrop = event.getExpToDrop();
|
||||
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
|
||||
int exp = UserManager.queryPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
|
||||
event.setExpToDrop(exp);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user