mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 01:42:32 +01:00
Compare commits
244 Commits
1.3.13
...
1.4.00-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc33f27899 | ||
|
|
e40095977a | ||
|
|
d1f499f6fd | ||
|
|
610bc42815 | ||
|
|
2006356ccd | ||
|
|
63e827aefb | ||
|
|
1898537149 | ||
|
|
60033d47ec | ||
|
|
b633f36131 | ||
|
|
749443454d | ||
|
|
d68dfe2a32 | ||
|
|
f3b119b91b | ||
|
|
aca3d5c4c6 | ||
|
|
b0acea3353 | ||
|
|
862f5d73e1 | ||
|
|
52bf73aecc | ||
|
|
54e5be1961 | ||
|
|
7fbf3d4f27 | ||
|
|
2df285fd7c | ||
|
|
a3e9d12f6a | ||
|
|
89e5e16aad | ||
|
|
cec132092f | ||
|
|
01723b2d36 | ||
|
|
b463e4ce6f | ||
|
|
8c7fd7b1a6 | ||
|
|
2762a9d1fd | ||
|
|
137864dc04 | ||
|
|
ef775f1c24 | ||
|
|
56617a1c1c | ||
|
|
77e048471e | ||
|
|
7d83dd8283 | ||
|
|
d0c0b9a089 | ||
|
|
75894c4419 | ||
|
|
d3c8a5565a | ||
|
|
bd2cd07f46 | ||
|
|
cd35df17ec | ||
|
|
a1d710fe3d | ||
|
|
c34d269f33 | ||
|
|
01c8b8ad4a | ||
|
|
fc5dda78f5 | ||
|
|
d6e78beb72 | ||
|
|
f324181190 | ||
|
|
5c13661c47 | ||
|
|
8b514d631c | ||
|
|
13a65e875f | ||
|
|
a1d4a4b3f8 | ||
|
|
610b87f462 | ||
|
|
374b758700 | ||
|
|
d32e0962b0 | ||
|
|
1cb9f93f0e | ||
|
|
4a24ade442 | ||
|
|
3f6bd7894d | ||
|
|
cbb941116f | ||
|
|
bcaa7ecacb | ||
|
|
b8eb6186ed | ||
|
|
6d5cf2b139 | ||
|
|
5e6b1fe362 | ||
|
|
1c0cafc6c8 | ||
|
|
8eee0cb0b0 | ||
|
|
bfe8403d75 | ||
|
|
8a852ce22e | ||
|
|
64fc7bcaf8 | ||
|
|
599bbe73b4 | ||
|
|
852872f55c | ||
|
|
62a037a4fd | ||
|
|
637442149c | ||
|
|
9a89c7c49f | ||
|
|
c6ef053aac | ||
|
|
d3b0da4186 | ||
|
|
d09cd49f01 | ||
|
|
bfa29cbf02 | ||
|
|
74d9fa422f | ||
|
|
b43538ee78 | ||
|
|
755b9bc2a1 | ||
|
|
ae49f0b6e4 | ||
|
|
063de93eb8 | ||
|
|
ec997bd2b6 | ||
|
|
20aa312173 | ||
|
|
48b0050451 | ||
|
|
c04b14c751 | ||
|
|
3d8aa29b52 | ||
|
|
ac7ed67d91 | ||
|
|
20f6a55df2 | ||
|
|
60041a1253 | ||
|
|
1e7b54ef0d | ||
|
|
d2cb88d93b | ||
|
|
659e982c47 | ||
|
|
5bf1e49e43 | ||
|
|
5b862a4cee | ||
|
|
2aec202e6d | ||
|
|
f5259decab | ||
|
|
0a17bf69c0 | ||
|
|
6db78d3cda | ||
|
|
0692dd82ad | ||
|
|
088d4ac14a | ||
|
|
92262d0e47 | ||
|
|
1549f66fd7 | ||
|
|
1118cd8ca1 | ||
|
|
d744c6a46d | ||
|
|
765199eba3 | ||
|
|
cb46040309 | ||
|
|
abd8223e41 | ||
|
|
e061acb44a | ||
|
|
cc6850b37d | ||
|
|
a3c92b07cb | ||
|
|
e61581c4e6 | ||
|
|
43dbb94a7f | ||
|
|
d43e61a49c | ||
|
|
7ccadae489 | ||
|
|
251c152efa | ||
|
|
a8fa625b5c | ||
|
|
5151be05b9 | ||
|
|
3f44bd8eac | ||
|
|
2eb593e163 | ||
|
|
2356fda67a | ||
|
|
bff7919c21 | ||
|
|
f1075f800f | ||
|
|
473b9e8bbe | ||
|
|
00c84e775f | ||
|
|
a1a630bad2 | ||
|
|
b91b88a74b | ||
|
|
56e16acce4 | ||
|
|
4692a461eb | ||
|
|
3e04bacf73 | ||
|
|
a0a52a3433 | ||
|
|
188ad359fe | ||
|
|
d601496173 | ||
|
|
85b909a7ab | ||
|
|
18a4f5ed40 | ||
|
|
c4ec9a6df9 | ||
|
|
a4aebdc643 | ||
|
|
b61410b6eb | ||
|
|
51d681974c | ||
|
|
071f7edade | ||
|
|
46f1157030 | ||
|
|
3cca6d9ab4 | ||
|
|
91e8051cee | ||
|
|
c220f0dee5 | ||
|
|
a7be57241c | ||
|
|
a35af4dbe6 | ||
|
|
329f779781 | ||
|
|
95fa688306 | ||
|
|
3d275a4f53 | ||
|
|
06cf0ff2c2 | ||
|
|
ba7ebe1319 | ||
|
|
3efc2138d6 | ||
|
|
9b0cba9dbe | ||
|
|
62a5d2db5c | ||
|
|
96d59a2e81 | ||
|
|
f5179cdcea | ||
|
|
4639b8b939 | ||
|
|
9cdfebda9a | ||
|
|
7c59621c9e | ||
|
|
8736aae2ef | ||
|
|
76a987e1e0 | ||
|
|
9dac898c1c | ||
|
|
ab677e941d | ||
|
|
29d796b6af | ||
|
|
276800f999 | ||
|
|
8d22df0411 | ||
|
|
8d077ff4f2 | ||
|
|
58b01021c1 | ||
|
|
5a6dc8511f | ||
|
|
b7bb3f4487 | ||
|
|
bba23de31c | ||
|
|
973279ed40 | ||
|
|
a4494f0873 | ||
|
|
121354e489 | ||
|
|
531e92bda3 | ||
|
|
135bfc2627 | ||
|
|
a01882aea5 | ||
|
|
a8b5b438bf | ||
|
|
8ccaf3caf2 | ||
|
|
1337c45f1d | ||
|
|
a968019799 | ||
|
|
0a9e1ba42e | ||
|
|
7e91776cfb | ||
|
|
9689c50603 | ||
|
|
bb2eb053da | ||
|
|
de5110310f | ||
|
|
64137995c2 | ||
|
|
6f45e479bd | ||
|
|
53ac857b43 | ||
|
|
6f0e2437e0 | ||
|
|
56d27c3d78 | ||
|
|
7919e591cb | ||
|
|
aabbc2f238 | ||
|
|
fb31cef68b | ||
|
|
2a89e912f8 | ||
|
|
ee91ed8708 | ||
|
|
69475f92c7 | ||
|
|
dc2452231d | ||
|
|
1bbb245e32 | ||
|
|
1548863a21 | ||
|
|
9169f53465 | ||
|
|
b5542effc2 | ||
|
|
6b0e7a9c61 | ||
|
|
00d50953ad | ||
|
|
397dd96383 | ||
|
|
cac5f15a37 | ||
|
|
74c32c4e59 | ||
|
|
e048a6d0d0 | ||
|
|
65d71db72f | ||
|
|
b4fffe154d | ||
|
|
716c4d3783 | ||
|
|
5a9ca96a0f | ||
|
|
cedfb1a538 | ||
|
|
176ffcc3d1 | ||
|
|
91b318e8f7 | ||
|
|
3cc9672ff3 | ||
|
|
946d845987 | ||
|
|
eef5df33b3 | ||
|
|
f0f7dee3c2 | ||
|
|
ddbf5a559a | ||
|
|
67fd45ef25 | ||
|
|
7f8beca33c | ||
|
|
0fcf033ecc | ||
|
|
ea4048dce9 | ||
|
|
0a295f7738 | ||
|
|
0711454e31 | ||
|
|
900623461a | ||
|
|
9512879cc7 | ||
|
|
299c7ff804 | ||
|
|
0276294569 | ||
|
|
06b75386b9 | ||
|
|
16bc359f99 | ||
|
|
c8013421e6 | ||
|
|
c1e82b566e | ||
|
|
f7aba26be2 | ||
|
|
77ffc9c3c2 | ||
|
|
9a6ebb0b9a | ||
|
|
57d1cd5f63 | ||
|
|
b7354779d4 | ||
|
|
0cdb50e538 | ||
|
|
37469232b0 | ||
|
|
0c52260a89 | ||
|
|
a85c9679a9 | ||
|
|
d625edf53e | ||
|
|
643af1c32b | ||
|
|
e7ceef479e | ||
|
|
0545ed434d | ||
|
|
b9bf3f96d2 | ||
|
|
f184e7bd01 | ||
|
|
e1804cded4 |
@@ -7,8 +7,66 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.3.13-dev
|
||||
! Indexed most used mySQL columns for faster queries
|
||||
Version 1.4.00-dev
|
||||
+ Added new Child Skill - Smelting!
|
||||
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
|
||||
+ Added config options for Hylian Luck skill
|
||||
+ Added display values to Unarmed command for Iron Grip
|
||||
+ Added '/party create <name>' command, use this to create a party
|
||||
+ Added '/party disband' command, kicks out all members and deletes the party
|
||||
+ Added '/ptp toggle' command, to disable party teleportation.
|
||||
+ Added '/ptp accept' and '/ptp acceptall' commands
|
||||
+ Added timeout on party teleport requests
|
||||
+ Added XP bonus for Archery based on distance from shooter to target
|
||||
+ Added ability to config Hylian Luck drops through treasures.yml
|
||||
+ Added party XP sharing
|
||||
+ Added vanilla XP boost for Fishing - includes permissions, config options, etc
|
||||
= Fixed /addlevels not working properly on offline players
|
||||
= Fixed /mmoedit not giving feedback when modifying another players stats
|
||||
= Fixed the guide usage string showing up every time /skillname was called
|
||||
= Fixed Spout not being able to precache our resources properly, and therefore making our XP bars fail
|
||||
= Fixed Spout config files loading / generating when they shouldn't have
|
||||
= Fixed mod config files loading / generating when they shouldn't have
|
||||
= Fixed bug where Green Terra could activate on crops that weren't fully grown.
|
||||
= Fixed several typos relating to locale string display
|
||||
= Fixed bug where all skill guide headers appeared as "Skillname Guide Guide"
|
||||
= Fixed bug where Impact was applied incorrectly due to an inverted method call
|
||||
= Fixed bug where Impact improperly determined the defender's armor
|
||||
= Fixed ArrayIndexOutOfBoundsException resulting from being unranked in a skill when using FlatFile
|
||||
= Fixed Woodcutting accidentally using Mining double drop values.
|
||||
= Fixed Hylian Luck not removing the block-placed flag from flowers.
|
||||
= Fixed Hylian Luck not checking the block-placed flag on flowers.
|
||||
= Fixed Leaf Blower not respecting the unlock level set in advanced.yml
|
||||
= Fixed abilities activating with the wrong tool in hand
|
||||
= Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted)
|
||||
= Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's.
|
||||
= Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player
|
||||
= Fixed a bug where party join messages weren't displayed
|
||||
= Fixed a bug where Disarm and Deflect had wrong values
|
||||
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
||||
! We're now using Bukkit sounds instead of Spout sounds.
|
||||
! It is now possible to use a negative number for Max_Level in treasures.yml to not use a maximum level, changed default file accordingly
|
||||
! A Fishing catch will now always contains a fish even if a treasure is found
|
||||
! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent
|
||||
! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR.
|
||||
! Changed how Tree Feller is handled, it should now put less stress on the CPU
|
||||
! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values
|
||||
! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API.
|
||||
! Changed the way party commands work, use /party ? to check how to use the new commands
|
||||
! Changed McMMOChatEvent to contain the plugin that the event originated from.
|
||||
! Changed Excavation to have individual XP values for each block type, rather than a base XP value.
|
||||
! Changed the way party teleportation works. When using /ptp, the target player needs to confirm the teleport before it takes place. (Configurable)
|
||||
! Changed BeastLore: Now also displays offline player names
|
||||
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
|
||||
- Removed unused "healthbar" files from the resources
|
||||
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
|
||||
|
||||
Version 1.3.14
|
||||
+ Added new Hylian Luck skill to Herbalism.
|
||||
= Fixed a memory leak involving mob tracking
|
||||
- Removed extra durability loss from Leaf Blower
|
||||
|
||||
Version 1.3.13
|
||||
+ Added task & command to prune old and powerless users from the SQL database.
|
||||
+ Added Craftbukkit 1.4.6 / 1.4.7 compatibility
|
||||
+ Added new /mcrank command for showing a players leader board ranking for all skills in one place
|
||||
@@ -65,6 +123,7 @@ Version 1.3.13-dev
|
||||
! Changed FFS Leaderboards to hold information in memory rather than doing IO work (optimizations)
|
||||
! Improved chunk conversion (less errors)
|
||||
! Changed Fishing Treasure Hunter, chance has increased and now actually is level dependent
|
||||
! Indexed most used mySQL columns for faster queries
|
||||
- Removed dead code relating to null profiles
|
||||
- Removed unused imports
|
||||
- Removed ChunkletUnloader and dependents, since they are no longer necessary.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Dev builds
|
||||
http://nuclearw.com:8080/job/mcMMO/ Download the latest dev build of mcMMO here.
|
||||
http://ci.mcmmo.info Download the latest dev build of mcMMO here.
|
||||
|
||||
=== Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
@@ -25,4 +25,4 @@ Required Libraries:
|
||||
Required to Run:
|
||||
* Bukkit
|
||||
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
|
||||
30
pom.xml
30
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.13</version>
|
||||
<version>1.4.00-beta1</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -54,12 +54,12 @@
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/locale/</directory>
|
||||
<includes>
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/locale/</directory>
|
||||
<includes>
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
@@ -116,8 +116,8 @@
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@@ -135,12 +135,12 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
||||
@@ -2,10 +2,11 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AbilityAPI {
|
||||
public final class AbilityAPI {
|
||||
private AbilityAPI() {}
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
|
||||
public final class ChatAPI {
|
||||
|
||||
private ChatAPI() {}
|
||||
|
||||
/**
|
||||
@@ -18,27 +13,44 @@ public final class ChatAPI {
|
||||
* </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) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), 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) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendPartyChat(Plugin, String, String, String)
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendPartyChat(String sender, String party, String message) {
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(player).inParty()) {
|
||||
if (Users.getProfile(player).getParty().getName().equalsIgnoreCase(chatEvent.getParty())) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {chatEvent.getSender()} ) + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
sendPartyChat(null, party, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,22 +58,40 @@ public final class ChatAPI {
|
||||
* </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) {
|
||||
ChatManager.handleAdminChat(plugin, 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) {
|
||||
ChatManager.handleAdminChat(plugin, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendAdminChat(Plugin, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendAdminChat(String sender, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(player) || player.isOp())
|
||||
player.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {chatEvent.getSender()} ) + chatEvent.getMessage());
|
||||
}
|
||||
sendAdminChat(null, sender, sender, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class ExperienceAPI {
|
||||
|
||||
private ExperienceAPI() {}
|
||||
|
||||
/**
|
||||
@@ -18,10 +17,10 @@ public final class ExperienceAPI {
|
||||
*/
|
||||
private static void checkXP(Player player, SkillType skillType) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(player, Users.getProfile(player));
|
||||
SkillTools.xpCheckAll(player, Users.getProfile(player));
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +34,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverride(skillType, XP);
|
||||
Users.getPlayer(player).addXpOverride(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverrideBonus(skillType, XP);
|
||||
Users.getPlayer(player).addXpOverrideBonus(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXP(skillType, XP);
|
||||
Users.getPlayer(player).addXp(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -159,7 +158,7 @@ public final class ExperienceAPI {
|
||||
* @param newValue The value to set the XP to
|
||||
*/
|
||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||
Users.getProfile(player).setSkillXPLevel(skillType, newValue);
|
||||
Users.getProfile(player).setSkillXpLevel(skillType, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,6 +171,6 @@ public final class ExperienceAPI {
|
||||
* @param xp The amount of XP to remove
|
||||
*/
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getProfile(player).removeXP(skillType, xp);
|
||||
Users.getProfile(player).removeXp(skillType, xp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class PartyAPI {
|
||||
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,7 @@ public final class PartyAPI {
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.getInstance().inSameParty(playera, playerb);
|
||||
return PartyManager.inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +56,7 @@ public final class PartyAPI {
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getInstance().getParties();
|
||||
return PartyManager.getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +68,7 @@ public final class PartyAPI {
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
Party party = PartyManager.getInstance().getParty(partyName);
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (party == null) {
|
||||
@@ -78,7 +77,7 @@ public final class PartyAPI {
|
||||
party.setLeader(playerName);
|
||||
}
|
||||
|
||||
PartyManager.getInstance().addToParty(playerName, Users.getProfile(player), party);
|
||||
PartyManager.addToParty(playerName, Users.getProfile(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +88,7 @@ public final class PartyAPI {
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||
PartyManager.removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +100,7 @@ public final class PartyAPI {
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getInstance().getPartyLeader(partyName);
|
||||
return PartyManager.getPartyLeader(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +112,7 @@ public final class PartyAPI {
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
|
||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +124,7 @@ public final class PartyAPI {
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
return PartyManager.getInstance().getAllMembers(player);
|
||||
return PartyManager.getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +136,7 @@ public final class PartyAPI {
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getInstance().getOnlineMembers(partyName);
|
||||
return PartyManager.getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,6 +148,6 @@ public final class PartyAPI {
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getInstance().getOnlineMembers(player);
|
||||
return PartyManager.getOnlineMembers(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,17 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
|
||||
public final class SpoutToolsAPI {
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
* </br>
|
||||
|
||||
67
src/main/java/com/gmail/nossr50/chat/ChatManager.java
Normal file
67
src/main/java/com/gmail/nossr50/chat/ChatManager.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getAdminDisplayNames())
|
||||
displayName = chatEvent.getDisplayName();
|
||||
else
|
||||
displayName = chatEvent.getSender();
|
||||
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player otherPlayer : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {displayName}) + adminMessage);
|
||||
}
|
||||
}
|
||||
|
||||
displayName = ChatColor.stripColor(displayName);
|
||||
mcMMO.p.getLogger().info("[A]<" + displayName + "> " + adminMessage);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getPartyDisplayNames())
|
||||
displayName = chatEvent.getDisplayName();
|
||||
else
|
||||
displayName = chatEvent.getSender();
|
||||
|
||||
String partyMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {displayName}) + partyMessage);
|
||||
}
|
||||
|
||||
displayName = ChatColor.stripColor(displayName);
|
||||
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + displayName + "> " + partyMessage);
|
||||
}
|
||||
}
|
||||
73
src/main/java/com/gmail/nossr50/chat/commands/ACommand.java
Normal file
73
src/main/java/com/gmail/nossr50/chat/commands/ACommand.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"a", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getPartyChatMode()) {
|
||||
profile.togglePartyChat();
|
||||
}
|
||||
|
||||
profile.toggleAdminChat();
|
||||
|
||||
if (profile.getAdminChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
String message = builder.toString();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
else {
|
||||
String ssender = LocaleLoader.getString("Commands.Chat.Console");
|
||||
ChatManager.handleAdminChat(mcMMO.p, ssender, ssender, message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -6,9 +6,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -64,31 +64,16 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {player.getName()} );
|
||||
|
||||
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
String message = builder.toString();
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
@@ -96,36 +81,25 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PartyManager.getInstance().isParty(args[0])) {
|
||||
Party party = PartyManager.getParty(args[0]);
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[1]);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[1]);
|
||||
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
String ssender = LocaleLoader.getString("Commands.Chat.Console");
|
||||
String message = builder.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
|
||||
|
||||
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
|
||||
|
||||
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
ChatManager.handlePartyChat(plugin, party, ssender, ssender, message);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -4,13 +4,13 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class CommandHelper {
|
||||
public final class CommandHelper {
|
||||
private CommandHelper() {}
|
||||
|
||||
/**
|
||||
* Checks for command permissions.
|
||||
@@ -32,6 +32,15 @@ public class CommandHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean noCommandPermissions(Player player, String permission) {
|
||||
if (!Permissions.hasPermission(player, permission)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean noConsoleUsage(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
|
||||
@@ -45,17 +54,11 @@ public class CommandHelper {
|
||||
* Print out details on Gathering skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printGatheringSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasGatheringSkills(inspect)) {
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
public static void printGatheringSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasGatheringSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
|
||||
if (Permissions.excavation(inspect)) {
|
||||
@@ -80,25 +83,19 @@ public class CommandHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void printGatheringSkills(Player player) {
|
||||
printGatheringSkills(player, player);
|
||||
public static void printGatheringSkills(Player player, PlayerProfile profile) {
|
||||
printGatheringSkills(player, profile, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Combat skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printCombatSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasCombatSkills(inspect)) {
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
public static void printCombatSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasCombatSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
|
||||
if (Permissions.axes(inspect)) {
|
||||
@@ -123,25 +120,19 @@ public class CommandHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void printCombatSkills(Player player) {
|
||||
printCombatSkills(player, player);
|
||||
public static void printCombatSkills(Player player, PlayerProfile profile) {
|
||||
printCombatSkills(player, profile, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Misc skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printMiscSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasMiscSkills(inspect)) {
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
public static void printMiscSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasMiscSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
|
||||
if (Permissions.acrobatics(inspect)) {
|
||||
@@ -154,7 +145,7 @@ public class CommandHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void printMiscSkills(Player player) {
|
||||
printMiscSkills(player, player);
|
||||
public static void printMiscSkills(Player player, PlayerProfile profile) {
|
||||
printMiscSkills(player, profile, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.admin.AddlevelsCommand;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||
import com.gmail.nossr50.skills.axes.AxesCommand;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationCommand;
|
||||
import com.gmail.nossr50.skills.fishing.FishingCommand;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismCommand;
|
||||
import com.gmail.nossr50.skills.mining.MiningCommand;
|
||||
import com.gmail.nossr50.skills.repair.RepairCommand;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingCommand;
|
||||
import com.gmail.nossr50.skills.swords.SwordsCommand;
|
||||
import com.gmail.nossr50.skills.taming.TamingCommand;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class CommandRegistrationHelper {
|
||||
private CommandRegistrationHelper() {};
|
||||
|
||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
public static void registerSkillCommands() {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill != SkillType.ALL) {
|
||||
String commandName = skill.toString().toLowerCase();
|
||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
||||
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
aliasList.add(localizedName);
|
||||
|
||||
PluginCommand command;
|
||||
|
||||
// Make us play nice with Essentials
|
||||
if (skill == SkillType.REPAIR && mcMMO.p.getServer().getPluginManager().isPluginEnabled("Essentials")) {
|
||||
command = mcMMO.p.getCommand("mcrepair");
|
||||
}
|
||||
else {
|
||||
command = mcMMO.p.getCommand(commandName);
|
||||
}
|
||||
|
||||
command.setAliases(aliasList);
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", new Object[] { Misc.getCapitalized(localizedName) }));
|
||||
command.setPermission("mcmmo.skills." + commandName);
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
|
||||
switch (skill) {
|
||||
case ACROBATICS:
|
||||
command.setExecutor(new AcrobaticsCommand());
|
||||
break;
|
||||
|
||||
case ARCHERY:
|
||||
command.setExecutor(new ArcheryCommand());
|
||||
break;
|
||||
|
||||
case AXES:
|
||||
command.setExecutor(new AxesCommand());
|
||||
break;
|
||||
|
||||
case EXCAVATION:
|
||||
command.setExecutor(new ExcavationCommand());
|
||||
break;
|
||||
|
||||
case FISHING:
|
||||
command.setExecutor(new FishingCommand());
|
||||
break;
|
||||
|
||||
case HERBALISM:
|
||||
command.setExecutor(new HerbalismCommand());
|
||||
break;
|
||||
|
||||
case MINING:
|
||||
command.setExecutor(new MiningCommand());
|
||||
break;
|
||||
|
||||
case REPAIR:
|
||||
command.setExecutor(new RepairCommand());
|
||||
break;
|
||||
|
||||
case SMELTING:
|
||||
command.setExecutor(new SmeltingCommand());
|
||||
break;
|
||||
|
||||
case SWORDS:
|
||||
command.setExecutor(new SwordsCommand());
|
||||
break;
|
||||
|
||||
case TAMING:
|
||||
command.setExecutor(new TamingCommand());
|
||||
break;
|
||||
|
||||
case UNARMED:
|
||||
command.setExecutor(new UnarmedCommand());
|
||||
break;
|
||||
|
||||
case WOODCUTTING:
|
||||
command.setExecutor(new WoodcuttingCommand());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerAddlevelsCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("addlevels");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
|
||||
command.setPermission("mcmmo.commands.addlevels");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" }));
|
||||
command.setExecutor(new AddlevelsCommand());
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
private SkillType skill;
|
||||
private String skillString;
|
||||
private String permission;
|
||||
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected float skillValue;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
this.skillString = Misc.getCapitalized(skill.toString());
|
||||
this.permission = "mcmmo.skills." + skillString.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, permission)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
|
||||
|
||||
if (effectsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
effectsDisplay();
|
||||
|
||||
if (statsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
statsDisplay();
|
||||
|
||||
Page.grabGuidePageForSkill(skill, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void dataCalculations();
|
||||
|
||||
protected abstract void permissionsCheck();
|
||||
|
||||
protected abstract boolean effectsHeaderPermissions();
|
||||
|
||||
protected abstract void effectsDisplay();
|
||||
|
||||
protected abstract boolean statsHeaderPermissions();
|
||||
|
||||
protected abstract void statsDisplay();
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
case 3:
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Misc.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
levels = Integer.valueOf(args[2]);
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
if (player.isOnline()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {args[0]}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), args[0]}));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -9,20 +9,15 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
//TODO: Any way we can make this work for offline use?
|
||||
public class AddxpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AddxpCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player modifiedPlayer;
|
||||
@@ -30,14 +25,14 @@ public class AddxpCommand implements CommandExecutor {
|
||||
SkillType skill;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">" });
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
@@ -45,11 +40,11 @@ public class AddxpCommand implements CommandExecutor {
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
xp = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
mcMMOPlayer.addXpOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||
@@ -59,10 +54,10 @@ public class AddxpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -76,31 +71,31 @@ public class AddxpCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp.others")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
modifiedPlayer = mcMMO.p.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (profile == null) {
|
||||
// TODO: Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[2])) {
|
||||
xp = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
mcMMOPlayer.addXpOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
|
||||
@@ -111,11 +106,11 @@ public class AddxpCommand implements CommandExecutor {
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcgodCommand(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
case 1:
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and
|
||||
// check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
if (player.isOnline()) {
|
||||
if (profile.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -13,12 +13,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McrefreshCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer player;
|
||||
@@ -42,7 +36,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
player = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
player = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -8,10 +8,11 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
@@ -23,14 +24,14 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
String skillName;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" });
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[0])) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
@@ -38,18 +39,17 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
if (Misc.isInt(args[1])) {
|
||||
Player player = (Player) sender;
|
||||
newValue = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", new Object[] { newValue }));
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] { Misc.getCapitalized(skill.toString()), newValue }));
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] {skillName, newValue}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
@@ -62,25 +62,22 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit.others")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Misc.isInt(args[2])) {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
if (skill == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
newValue = Integer.valueOf(args[2]);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
@@ -93,8 +90,16 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] {skillName, newValue}));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] {skillName, args[0]}));
|
||||
if (skill == SkillType.ALL) {
|
||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", new Object[] { newValue }));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] { args[0] }));
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
|
||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] { skillName, newValue }));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] { skillName, args[0] }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
@@ -106,6 +111,13 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
profile.save();
|
||||
|
||||
if (skill == SkillType.ALL) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] { args[0] }));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] { Misc.getCapitalized(skill.toString()), args[0] }));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillResetCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile profile;
|
||||
SkillType skill;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"});
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (sender instanceof Player) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
|
||||
if (CommandHelper.noCommandPermissions((Player) sender, "mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
modifiedPlayer = (Player) sender;
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (skill == SkillType.ALL) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { Misc.getCapitalized(skill.toString()) }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
// TODO:Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
if (skill == SkillType.ALL) {
|
||||
((Player)modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
((Player)modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { Misc.getCapitalized(skill.toString()) }));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] { Misc.getCapitalized(skill.toString()), args[0] }));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -12,13 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
||||
private static boolean xpEvent = false;
|
||||
|
||||
public XprateCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -26,23 +20,29 @@ public class XprateCommand implements CommandExecutor {
|
||||
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
|
||||
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean xpEventEnabled = mcMMO.p.isXPEventEnabled();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (xpEventEnabled) {
|
||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
}
|
||||
|
||||
xpEvent = !xpEvent;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
mcMMO.p.setXPEventEnabled(!xpEventEnabled);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
}
|
||||
else {
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
}
|
||||
}
|
||||
else if (Misc.isInt(args[0])) {
|
||||
@@ -56,25 +56,27 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[0])) {
|
||||
oldRate = Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set")) {
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||
xpEvent = Boolean.valueOf(args[1]);
|
||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage3);
|
||||
}
|
||||
|
||||
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
|
||||
int newRate = Misc.getInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newRate);
|
||||
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (xpEventEnabled) {
|
||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {newRate}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {newRate}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -90,8 +92,4 @@ public class XprateCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXpEventRunning() {
|
||||
return xpEvent;
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AddlevelsCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" });
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[2])) {
|
||||
levels = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
|
||||
}
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillResetCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//ensure they have the skillreset perm
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skillType = null; //simple initialization
|
||||
|
||||
//make sure there's only one argument. output at least some kind of error if not
|
||||
if (args.length == 0 || (args.length != 1 && args[0] != null)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//parse the skilltype that they sent
|
||||
try
|
||||
{
|
||||
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
|
||||
}catch(IllegalArgumentException ex)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
//reset the values in the hash table and persist them
|
||||
PlayerProfile profile = Users.getProfile((Player)sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.resetSkill(skillType);
|
||||
profile.save();
|
||||
|
||||
//display a success message to the user
|
||||
if (skillType == SkillType.ALL)
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
else
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcgod")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public ACommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"a", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getPartyChatMode()) {
|
||||
profile.togglePartyChat();
|
||||
}
|
||||
|
||||
profile.toggleAdminChat();
|
||||
|
||||
if (profile.getAdminChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {player.getName()} );
|
||||
|
||||
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
|
||||
|
||||
plugin.getLogger().info("[A]<*Console*> " + message);
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(player) || player.isOp()) {
|
||||
player.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AcceptCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AcceptCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (playerProfile.hasPartyInvite()) {
|
||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
||||
|
||||
if (playerProfile.inParty()) {
|
||||
Party party = playerProfile.getParty();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(player.getName(), party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
partyManagerInstance.joinInvitedParty(player, playerProfile);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
//TODO: Make this work from console.
|
||||
public class InviteCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InviteCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (!playerProfile.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if (target != null) {
|
||||
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
Users.getProfile(target).setInvite(party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public PartyCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
String playerName = player.getName();
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (party == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
||||
}
|
||||
else {
|
||||
Server server = plugin.getServer();
|
||||
String leader = party.getLeader();
|
||||
StringBuffer tempList = new StringBuffer();
|
||||
|
||||
for (String otherPlayerName : party.getMembers()) {
|
||||
if (leader.equals(otherPlayerName)) {
|
||||
tempList.append(ChatColor.GOLD);
|
||||
}
|
||||
else if (server.getPlayer(otherPlayerName) != null) {
|
||||
tempList.append(ChatColor.WHITE);
|
||||
}
|
||||
else {
|
||||
tempList.append(ChatColor.GRAY);
|
||||
}
|
||||
|
||||
tempList.append(otherPlayerName + " ");
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("q")) {
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
}
|
||||
}
|
||||
else if (args[0].equals("?")) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.4"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.5"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.6"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lock")) {
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
|
||||
}
|
||||
else {
|
||||
party.setLocked(true);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
||||
}
|
||||
else {
|
||||
party.setLocked(false);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, null)) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (playerProfile.inParty()) {
|
||||
if (args[0].equalsIgnoreCase("password")) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
party.setLocked(true);
|
||||
party.setPassword(args[1]);
|
||||
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("kick")) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyName = party.getName();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(args[1], party);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("owner")) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.setPartyLeader(args[1], party);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public PtpCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if (player.equals(target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isDead()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.getInstance().inSameParty(player, target)) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player.teleport(target);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
|
||||
profile.setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
@@ -30,21 +30,23 @@ public class InspectCommand implements CommandExecutor {
|
||||
if (mcmmoPlayer != null) {
|
||||
Player target = mcmmoPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.inspectDistanceBypass((Player) sender)) {
|
||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = mcmmoPlayer.getProfile();
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
|
||||
CommandHelper.printGatheringSkills(target, sender);
|
||||
CommandHelper.printCombatSkills(target, sender);
|
||||
CommandHelper.printMiscSkills(target, sender);
|
||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
||||
CommandHelper.printCombatSkills(target, profile, sender);
|
||||
CommandHelper.printMiscSkills(target, profile, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { mcmmoPlayer.getPowerLevel() }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !Permissions.inspectOfflineBypass((Player) sender)) {
|
||||
if (sender instanceof Player && !Permissions.inspectOffline((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcability", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability.others")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
// TODO:Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -6,13 +6,11 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands.
|
||||
public class MccCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -25,15 +23,16 @@ public class MccCommand implements CommandExecutor {
|
||||
|
||||
if (Permissions.party(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
player.sendMessage("/party " + LocaleLoader.getString("Commands.Party"));
|
||||
player.sendMessage("/party q " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
player.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
player.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
player.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (Permissions.partyChat(player)) {
|
||||
player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
player.sendMessage("/invite " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
player.sendMessage("/accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
player.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
player.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (Permissions.partyTeleport(player)) {
|
||||
player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
@@ -44,7 +43,7 @@ public class MccCommand implements CommandExecutor {
|
||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.skillReset(player)) {
|
||||
if (Permissions.skillReset(player)) {
|
||||
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -31,8 +31,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {mcMMO.p.getDescription().getVersion()}));
|
||||
|
||||
Anniversary anniversary = new Anniversary();
|
||||
anniversary.anniversaryCheck(sender);
|
||||
Anniversary.anniversaryCheck(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -8,14 +8,13 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McRankAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
//TODO: Better input handling, add usage string
|
||||
@@ -31,16 +30,16 @@ public class McrankCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
String playerName;
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
playerName = player.getName();
|
||||
break;
|
||||
case 0:
|
||||
playerName = player.getName();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
break;
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
@@ -58,22 +57,25 @@ public class McrankCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
continue; // We want the overall ranking to be at the bottom
|
||||
}
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
||||
}
|
||||
}
|
||||
|
||||
//Show the powerlevel ranking
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, SkillType.ALL);
|
||||
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", new Object[] {LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -7,32 +7,39 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcstats")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandHelper.printGatheringSkills(player);
|
||||
CommandHelper.printCombatSkills(player);
|
||||
CommandHelper.printMiscSkills(player);
|
||||
CommandHelper.printGatheringSkills(player, profile);
|
||||
CommandHelper.printCombatSkills(player, profile);
|
||||
CommandHelper.printMiscSkills(player, profile);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap > 0)
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||
if (powerLevelCap > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -8,17 +8,15 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"});
|
||||
@@ -34,11 +32,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
if (Misc.isInt(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[0]), "ALL", sender);
|
||||
}
|
||||
else if (Skills.isSkill(args[0])) {
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
flatfileDisplay(1, args[0].toUpperCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(1, Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(1, SkillTools.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
@@ -48,11 +46,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[1])) {
|
||||
if (Skills.isSkill(args[0])) {
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
@@ -81,11 +79,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
if (Misc.isInt(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
|
||||
}
|
||||
else if (Skills.isSkill(args[0])) {
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
sqlDisplay(1, args[0].toLowerCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(1, Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(1, SkillTools.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
@@ -95,11 +93,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[1])) {
|
||||
if (Skills.isSkill(args[0])) {
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
@@ -118,8 +116,8 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||
SkillType skillType = SkillType.getSkill(skill);
|
||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||
SkillType skillType = SkillType.getSkill(skill);
|
||||
String[] info = Leaderboard.retrieveInfo(skillType, page);
|
||||
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
@@ -151,9 +149,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
|
||||
HashMap<Integer, ArrayList<String>> userslist = Database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
|
||||
|
||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class ArcheryCommand extends SkillCommand {
|
||||
private String skillShotBonus;
|
||||
private String dazeChance;
|
||||
private String dazeChanceLucky;
|
||||
private String retrieveChance;
|
||||
private String retrieveChanceLucky;
|
||||
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
private boolean lucky;
|
||||
|
||||
public ArcheryCommand() {
|
||||
super(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float dazeChanceF;
|
||||
float retrieveChanceF;
|
||||
|
||||
// SkillShot
|
||||
double bonus = (int)((double) skillValue / (double) Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
|
||||
if (bonus > Archery.skillShotMaxBonusPercentage) skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage);
|
||||
else skillShotBonus = percent.format(bonus);
|
||||
|
||||
// Daze
|
||||
if (skillValue >= Archery.dazeMaxBonusLevel) dazeChanceF = (float) Archery.dazeMaxBonus;
|
||||
else dazeChanceF = (float) (( Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * skillValue);
|
||||
dazeChance = percent.format(dazeChanceF / 100D);
|
||||
if (dazeChanceF * 1.3333D >= 100D) dazeChanceLucky = percent.format(1D);
|
||||
else dazeChanceLucky = percent.format(dazeChanceF * 1.3333D / 100D);
|
||||
|
||||
// Retrieve
|
||||
if (skillValue >= Archery.retrieveMaxBonusLevel) retrieveChanceF = (float) Archery.retrieveMaxChance;
|
||||
else retrieveChanceF = (float) ((Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * skillValue);
|
||||
retrieveChance = percent.format(retrieveChanceF / 100D);
|
||||
if (retrieveChanceF * 1.3333D >= 100D) retrieveChanceLucky = percent.format(1D);
|
||||
else retrieveChanceLucky = percent.format(retrieveChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = Permissions.archeryBonus(player);
|
||||
canDaze = Permissions.daze(player);
|
||||
canRetrieve = Permissions.trackArrows(player);
|
||||
lucky = Permissions.luckyArchery(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.ARCHERY) }) }));
|
||||
}
|
||||
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dazeChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { retrieveChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class SwordsCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
private String counterAttackChance;
|
||||
private String counterAttackChanceLucky;
|
||||
private String bleedLength;
|
||||
private String bleedChance;
|
||||
private String bleedChanceLucky;
|
||||
private String serratedStrikesLength;
|
||||
private String serratedStrikesLengthEndurance;
|
||||
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
private float bleedChanceMax = advancedConfig.getBleedChanceMax();
|
||||
private float bleedMaxLevel = advancedConfig.getBleedMaxBonusLevel();
|
||||
private int bleedMaxTicks = advancedConfig.getBleedMaxTicks();
|
||||
private int bleedBaseTicks = advancedConfig.getBleedBaseTicks();
|
||||
private float counterChanceMax = advancedConfig.getCounterChanceMax();
|
||||
private float counterMaxLevel = advancedConfig.getCounterMaxBonusLevel();
|
||||
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public SwordsCommand() {
|
||||
super(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float bleedChanceF;
|
||||
float counterAttackChanceF;
|
||||
//Serrated Strikes
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
serratedStrikesLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.SWORDS.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
serratedStrikesLengthEndurance = String.valueOf(length);
|
||||
|
||||
//Bleed
|
||||
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
|
||||
else bleedLength = String.valueOf(bleedBaseTicks);
|
||||
|
||||
if (skillValue >= bleedMaxLevel) bleedChanceF = bleedChanceMax;
|
||||
else bleedChanceF = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * skillValue);
|
||||
bleedChance = percent.format(bleedChanceF / 100D);
|
||||
if (bleedChanceF * 1.3333D >= 100D) bleedChanceLucky = percent.format(1D);
|
||||
else bleedChanceLucky = percent.format(bleedChanceF * 1.3333D / 100D);
|
||||
|
||||
//Counter Attack
|
||||
if (skillValue >= counterMaxLevel) counterAttackChanceF = counterChanceMax;
|
||||
else counterAttackChanceF = (float) (((double) counterChanceMax / (double) counterMaxLevel) * skillValue);
|
||||
counterAttackChance = percent.format(counterAttackChanceF / 100D);
|
||||
if (counterAttackChanceF * 1.3333D >= 100D) counterAttackChanceLucky = percent.format(1D);
|
||||
else counterAttackChanceLucky = percent.format(counterAttackChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBleed = Permissions.swordsBleed(player);
|
||||
canCounter = Permissions.counterAttack(player);
|
||||
canSerratedStrike = Permissions.serratedStrikes(player);
|
||||
lucky = Permissions.luckySwords(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.SWORDS) }) }));
|
||||
}
|
||||
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canCounter) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { counterAttackChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { bleedChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { serratedStrikesLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class WoodcuttingCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private String treeFellerLength;
|
||||
private String treeFellerLengthEndurance;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
|
||||
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
|
||||
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float doubleDropChanceF;
|
||||
|
||||
//Tree Feller
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
treeFellerLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.WOODCUTTING.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
treeFellerLengthEndurance = String.valueOf(length);
|
||||
|
||||
//Double Drops
|
||||
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
|
||||
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
||||
doubleDropChance = percent.format(doubleDropChanceF / 100D);
|
||||
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
|
||||
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canTreeFell = Permissions.treeFeller(player);
|
||||
canDoubleDrop = Permissions.woodcuttingDoubleDrops(player);
|
||||
canLeafBlow = Permissions.leafBlower(player);
|
||||
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
|
||||
lucky = Permissions.luckyWoodcutting(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.WOODCUTTING) }) }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canLeafBlow) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
//TODO: Remove? Basically duplicates the above.
|
||||
if (canLeafBlow) {
|
||||
if (skillValue < leafBlowUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { leafBlowUnlock }) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { treeFellerLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,12 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
super("advanced.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static AdvancedConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new AdvancedConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -77,6 +79,8 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
|
||||
public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); }
|
||||
|
||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
||||
|
||||
/* Shake */
|
||||
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
||||
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
||||
@@ -85,18 +89,28 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getShakeChanceRank4() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_4", 60); }
|
||||
public int getShakeChanceRank5() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_5", 75); }
|
||||
|
||||
/* Vanilla XP Boost */
|
||||
public int getFishingVanillaXPModifierRank1() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_1", 1); }
|
||||
public int getFishingVanillaXPModifierRank2() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_2", 2); }
|
||||
public int getFishingVanillaXPModifierRank3() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_3", 3); }
|
||||
public int getFishingVanillaXPModifierRank4() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_4", 4); }
|
||||
public int getFishingVanillaXPModifierRank5() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_5", 5); }
|
||||
|
||||
/* HERBALISM */
|
||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Food_RankChange", 200); }
|
||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Farmer_Diet_RankChange", 200); }
|
||||
|
||||
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
|
||||
public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); }
|
||||
public double getGreenThumbChanceMax() { return config.getDouble("Skills.Herbalism.GreenThumb_ChanceMax", 100.0D); }
|
||||
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
|
||||
|
||||
public int getHerbalismDoubleDropsChanceMax() { return config.getInt("Skills.Herbalism.DoubleDrops_ChanceMax", 100); }
|
||||
public double getHerbalismDoubleDropsChanceMax() { return config.getDouble("Skills.Herbalism.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
||||
public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||
|
||||
/* MINING */
|
||||
public int getMiningDoubleDropChance() { return config.getInt("Skills.Mining.DoubleDrops_ChanceMax", 100); }
|
||||
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
public int getBlastMiningRank1() { return config.getInt("Skills.Mining.BlastMining_Rank1", 125); }
|
||||
@@ -109,9 +123,9 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
||||
|
||||
/* REPAIR */
|
||||
public int getRepairMasteryMaxBonus() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusPercentage", 200); }
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||
public int getSuperRepairChanceMax() { return config.getInt("Skills.Repair.SuperRepair_ChanceMax", 100); }
|
||||
public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); }
|
||||
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
||||
|
||||
/* Arcane Forging */
|
||||
@@ -130,13 +144,35 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getArcaneForgingRankLevels3() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3", 500); }
|
||||
public int getArcaneForgingRankLevels4() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_4", 750); }
|
||||
|
||||
/* SMELTING */
|
||||
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency_MaxBonusLevel", 1000); }
|
||||
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency_Multiplier", 3.0D); }
|
||||
|
||||
public int getSecondSmeltMaxLevel() { return config.getInt("Skills.Smelting.SecondSmelt_MaxBonusLevel", 1000); }
|
||||
public double getSecondSmeltMaxChance() { return config.getDouble("Skills.Smelting.SecondSmelt_MaxBonusChance", 100.0D); }
|
||||
|
||||
public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining_UnlockLevel", 250); }
|
||||
public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining_Chance", 33.0D); }
|
||||
|
||||
public int getSmeltingVanillaXPBoostRank1Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank1Level", 100); }
|
||||
public int getSmeltingVanillaXPBoostRank2Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank2Level", 300); }
|
||||
public int getSmeltingVanillaXPBoostRank3Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank3Level", 500); }
|
||||
public int getSmeltingVanillaXPBoostRank4Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank4Level", 700); }
|
||||
public int getSmeltingVanillaXPBoostRank5Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank5Level", 900); }
|
||||
|
||||
public int getSmeltingVanillaXPBoostRank1Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank1Multiplier", 2); }
|
||||
public int getSmeltingVanillaXPBoostRank2Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank2Multiplier", 3); }
|
||||
public int getSmeltingVanillaXPBoostRank3Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank3Multiplier", 4); }
|
||||
public int getSmeltingVanillaXPBoostRank4Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank4Multiplier", 5); }
|
||||
public int getSmeltingVanillaXPBoostRank5Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank5Multiplier", 6); }
|
||||
|
||||
/* SWORDS */
|
||||
public int getBleedChanceMax() { return config.getInt("Skills.Swords.Bleed_ChanceMax", 75); }
|
||||
public double getBleedChanceMax() { return config.getDouble("Skills.Swords.Bleed_ChanceMax", 75.0D); }
|
||||
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Swords.Bleed_MaxBonusLevel", 750); }
|
||||
public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed_MaxTicks", 3); }
|
||||
public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed_BaseTicks", 2); }
|
||||
|
||||
public int getCounterChanceMax() { return config.getInt("Skills.Swords.Counter_ChanceMax", 30); }
|
||||
public double getCounterChanceMax() { return config.getDouble("Skills.Swords.Counter_ChanceMax", 30.0D); }
|
||||
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Swords.Counter_MaxBonusLevel", 600); }
|
||||
public int getCounterModifier() { return config.getInt("Skills.Swords.Counter_DamageModifier", 2); }
|
||||
|
||||
@@ -144,13 +180,13 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); }
|
||||
|
||||
/* TAMING */
|
||||
public int getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
|
||||
public double getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
|
||||
public int getGoreMaxBonusLevel() { return config.getInt("Skills.Taming.Gore_MaxBonusLevel", 1000); }
|
||||
public int getGoreBleedTicks() { return config.getInt("Skills.Taming.Gore_BleedTicks", 2); }
|
||||
public int getGoreModifier() { return config.getInt("Skills.Taming.Gore_Modifier", 2); }
|
||||
|
||||
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
|
||||
public int getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||
public double getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||
|
||||
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
|
||||
|
||||
@@ -164,18 +200,22 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
|
||||
|
||||
/* UNARMED */
|
||||
public int getDisarmChanceMax() { return config.getInt("Skills.Unarmed.Disarm_ChanceMax", 33); }
|
||||
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); }
|
||||
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm_MaxBonusLevel", 1000); }
|
||||
public int getDeflectChanceMax() { return config.getInt("Skills.Unarmed.Deflect_ChanceMax", 50); }
|
||||
|
||||
public double getDeflectChanceMax() { return config.getDouble("Skills.Unarmed.Deflect_ChanceMax", 50.0D); }
|
||||
public int getDeflectMaxBonusLevel() { return config.getInt("Skills.Unarmed.Deflect_MaxBonusLevel", 1000); }
|
||||
public int getIronGripChanceMax() { return config.getInt("Skills.Unarmed.IronGrip_ChanceMax", 100); }
|
||||
|
||||
public double getIronGripChanceMax() { return config.getDouble("Skills.Unarmed.IronGrip_ChanceMax", 100.0D); }
|
||||
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
|
||||
public int getIronArmBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
|
||||
|
||||
public int getIronArmMaxBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
|
||||
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
|
||||
|
||||
/* WOODCUTTING */
|
||||
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
|
||||
public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); }
|
||||
|
||||
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
/* SPOUT STUFF*/
|
||||
|
||||
@@ -6,11 +6,9 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static Config instance;
|
||||
public double xpGainMultiplier = 1;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -32,9 +30,12 @@ public class Config extends ConfigLoader {
|
||||
/* General Settings */
|
||||
public String getLocale() { return config.getString("General.Locale", "en_us"); }
|
||||
public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
|
||||
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
||||
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
@@ -57,13 +58,13 @@ public class Config extends ConfigLoader {
|
||||
}
|
||||
|
||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||
String str = cfg.getString(key);
|
||||
if (str == null)
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
if (str == null)
|
||||
str = "No value set for '" + key + "'";
|
||||
return str;
|
||||
}
|
||||
String str = cfg.getString(key);
|
||||
if (str == null)
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
if (str == null)
|
||||
str = "No value set for '" + key + "'";
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
|
||||
@@ -76,33 +77,10 @@ public class Config extends ConfigLoader {
|
||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||
|
||||
/* Commands */
|
||||
public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); }
|
||||
public boolean getCommandXPRateEnabled() { return config.getBoolean("Commands.xprate.Enabled", true); }
|
||||
public boolean getCommandMCTopEnabled() { return config.getBoolean("Commands.mctop.Enabled", true); }
|
||||
public boolean getCommandMCRankEnabled() { return config.getBoolean("Commands.mcrank.Enabled", true); }
|
||||
public boolean getCommandAddXPEnabled() { return config.getBoolean("Commands.addxp.Enabled", true); }
|
||||
public boolean getCommandAddLevelsEnabled() { return config.getBoolean("Commands.addlevels.Enabled", true); }
|
||||
public boolean getCommandMCAbilityEnabled() { return config.getBoolean("Commands.mcability.Enabled", true); }
|
||||
public boolean getCommandMCRefreshEnabled() { return config.getBoolean("Commands.mcrefresh.Enabled", true); }
|
||||
public boolean getCommandmcMMOEnabled() { return config.getBoolean("Commands.mcmmo.Enabled", true); }
|
||||
public boolean getCommandMCCEnabled() { return config.getBoolean("Commands.mcc.Enabled", true); }
|
||||
public boolean getCommandMCGodEnabled() { return config.getBoolean("Commands.mcgod.Enabled", true); }
|
||||
public boolean getCommandMCStatsEnabled() { return config.getBoolean("Commands.mcstats.Enabled", true); }
|
||||
public boolean getCommandSkillResetEnabled() { return config.getBoolean("Commands.skillreset.Enabled", true); }
|
||||
public boolean getCommandMmoeditEnabled() { return config.getBoolean("Commands.mmoedit.Enabled", true); }
|
||||
public boolean getCommandMCRemoveEnabled() { return config.getBoolean("Commands.mcremove.Enable", true); }
|
||||
public boolean getCommandMCPurgeEnabled() { return config.getBoolean("Commands.mcpurge.Enable", true); }
|
||||
public boolean getCommandPTPEnabled() { return config.getBoolean("Commands.ptp.Enabled", true); }
|
||||
public boolean getCommandPartyEnabled() { return config.getBoolean("Commands.party.Enabled", true); }
|
||||
public boolean getCommandInspectEnabled() { return config.getBoolean("Commands.inspect.Enabled", true); }
|
||||
public boolean getCommandInviteEnabled() { return config.getBoolean("Commands.invite.Enabled", true); }
|
||||
public boolean getCommandAcceptEnabled() { return config.getBoolean("Commands.accept.Enabled", true); }
|
||||
public boolean getCommandAdminChatAEnabled() { return config.getBoolean("Commands.a.Enabled", true); }
|
||||
public boolean getCommandPartyChatPEnabled() { return config.getBoolean("Commands.p.Enabled", true); }
|
||||
|
||||
/* Party Teleport Settings */
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
|
||||
@@ -155,7 +133,13 @@ public class Config extends ConfigLoader {
|
||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
||||
|
||||
/* Excavation */
|
||||
public int getExcavationBaseXP() { return config.getInt("Experience.Excavation.Base", 40); }
|
||||
public int getExcavationClayXP() { return config.getInt("Experience.Excavation.Clay", 40); }
|
||||
public int getExcavationDirtXP() { return config.getInt("Experience.Excavation.Dirt", 40); }
|
||||
public int getExcavationGrassXP() { return config.getInt("Experience.Excavation.Grass", 40); }
|
||||
public int getExcavationGravelXP() { return config.getInt("Experience.Excavation.Gravel", 40); }
|
||||
public int getExcavationMycelXP() { return config.getInt("Experience.Excavation.Mycel", 40); }
|
||||
public int getExcavationSandXP() { return config.getInt("Experience.Excavation.Sand", 40); }
|
||||
public int getExcavationSoulSandXP() { return config.getInt("Experience.Excavation.SoulSand", 40); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
@@ -247,6 +231,15 @@ public class Config extends ConfigLoader {
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
|
||||
/* Smelting */
|
||||
public int getSmeltingXPCoal() { return config.getInt("Experience.Smelting.Coal", 10); }
|
||||
public int getSmeltingXPRedstone() { return config.getInt("Experience.Smelting.Redstone", 15); }
|
||||
public int getSmeltingXPIron() { return config.getInt("Experience.Smelting.Iron", 25); }
|
||||
public int getSmeltingXPGold() { return config.getInt("Experience.Smelting.Gold", 35); }
|
||||
public int getSmeltingXPDiamond() { return config.getInt("Experience.Smelting.Diamond", 75); }
|
||||
public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); }
|
||||
public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||
@@ -273,7 +266,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Dogde Lightning */
|
||||
public boolean getDodgeLightningDisabled() {return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Level Caps */
|
||||
public int getLevelCapAcrobatics() {
|
||||
@@ -308,6 +301,10 @@ public class Config extends ConfigLoader {
|
||||
return getLevelCap("Skills.Repair.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSmelting() {
|
||||
return getLevelCap("Skills.Smelting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSwords() {
|
||||
return getLevelCap("Skills.Swords.Level_Cap");
|
||||
}
|
||||
@@ -350,6 +347,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
@@ -408,4 +406,10 @@ public class Config extends ConfigLoader {
|
||||
int cap = config.getInt(configString, 0);
|
||||
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
|
||||
}
|
||||
|
||||
/* Party Settings */
|
||||
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
|
||||
public double getPartyShareBonus() { return config.getDouble("Party.Sharing.ExpShare_bonus", 1.1); }
|
||||
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
||||
}
|
||||
|
||||
@@ -14,9 +14,10 @@ import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class TreasuresConfig extends ConfigLoader{
|
||||
public class TreasuresConfig extends ConfigLoader {
|
||||
private static TreasuresConfig instance;
|
||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
@@ -25,6 +26,11 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
||||
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
private TreasuresConfig() {
|
||||
@@ -132,10 +138,6 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
|
||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
||||
|
||||
if (maxLevel < 0) {
|
||||
reason.add("Invalid Max_Level: " + maxLevel);
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
||||
treasures.put(treasureName, fTreasure);
|
||||
@@ -143,6 +145,7 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
}
|
||||
else {
|
||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
||||
eTreasure.setDropsFromDirt();
|
||||
@@ -172,18 +175,34 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
eTreasure.setDropsFromSoulSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
|
||||
hTreasure.setDropsFromBushes();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
|
||||
hTreasure.setDropsFromFlowers();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
|
||||
hTreasure.setDropsFromPots();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
reason.add("Excavation drops cannot also be fishing drops");
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, eTreasure);
|
||||
}
|
||||
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0){
|
||||
treasures.put(treasureName, hTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||
|
||||
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
|
||||
String treasureKey = nextEntry.getKey();
|
||||
@@ -196,6 +215,25 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof HylianTreasure) {
|
||||
if (!hylianTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HylianTreasure hTreasure = (HylianTreasure) treasure;
|
||||
|
||||
if (hTreasure.getDropsFromBushes()) {
|
||||
hylianFromBushes.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromFlowers()) {
|
||||
hylianFromFlowers.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromPots()) {
|
||||
hylianFromPots.add(hTreasure);
|
||||
}
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (!excavationTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util;
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@@ -15,21 +15,18 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
||||
import com.gmail.nossr50.database.runnables.SQLReconnect;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.runnables.SQLReconnect;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.spout.SpoutTools;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Database {
|
||||
|
||||
private static Config configInstance = Config.getInstance();
|
||||
public final class Database {
|
||||
private static String connectionString;
|
||||
|
||||
private static String tablePrefix = configInstance.getMySQLTablePrefix();
|
||||
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
private static Connection connection = null;
|
||||
private static mcMMO plugin = null;
|
||||
|
||||
// Scale waiting time by this much per failed attempt
|
||||
private static final double SCALING_FACTOR = 40;
|
||||
@@ -49,16 +46,15 @@ public class Database {
|
||||
// How many connection attemtps have failed
|
||||
private static int reconnectAttempt = 0;
|
||||
|
||||
public Database(mcMMO instance) {
|
||||
plugin = instance;
|
||||
checkConnected(); //Connect to MySQL
|
||||
}
|
||||
private Database() {}
|
||||
|
||||
/**
|
||||
* Attempt to connect to the mySQL database.
|
||||
*/
|
||||
public static void connect() {
|
||||
Config configInstance = Config.getInstance();
|
||||
connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName();
|
||||
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
|
||||
|
||||
@@ -74,17 +70,21 @@ public class Database {
|
||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||
} catch (SQLException ex) {
|
||||
connection = null;
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
connection = null;
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to create the database structure.
|
||||
*/
|
||||
public void createStructure() {
|
||||
public static void createStructure() {
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
@@ -156,9 +156,9 @@ public class Database {
|
||||
/**
|
||||
* Check database structure for missing values.
|
||||
*
|
||||
* @param update Type of data to check updates for
|
||||
* @param update Type of data to check updates for
|
||||
*/
|
||||
public void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
private static void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
String sql = null;
|
||||
ResultSet resultSet = null;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
@@ -179,8 +179,8 @@ public class Database {
|
||||
break;
|
||||
|
||||
case INDEX:
|
||||
if(read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13) {
|
||||
plugin.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, "
|
||||
@@ -195,7 +195,7 @@ public class Database {
|
||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class Database {
|
||||
* @param sql Query to write.
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
*/
|
||||
public boolean write(String sql) {
|
||||
public static boolean write(String sql) {
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -288,7 +288,7 @@ public class Database {
|
||||
* @param sql SQL query to execute
|
||||
* @return the number of rows affected
|
||||
*/
|
||||
public int update(String sql) {
|
||||
public static int update(String sql) {
|
||||
int ret = 0;
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
@@ -320,7 +320,7 @@ public class Database {
|
||||
* @param sql SQL query to execute
|
||||
* @return the value in the first row / first field
|
||||
*/
|
||||
public int getInt(String sql) {
|
||||
public static int getInt(String sql) {
|
||||
ResultSet resultSet;
|
||||
int result = 0;
|
||||
|
||||
@@ -416,7 +416,7 @@ public class Database {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
// Schedule a database save if we really had an outage
|
||||
if (reconnectAttempt > 1) {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnect(), 5);
|
||||
}
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
@@ -441,7 +441,7 @@ public class Database {
|
||||
* @param sql SQL query to read
|
||||
* @return the rows in this SQL query
|
||||
*/
|
||||
public HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
ResultSet resultSet;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
@@ -469,32 +469,35 @@ public class Database {
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
public Map<String, Integer> readSQLRank(String playerName) {
|
||||
|
||||
public static Map<String, Integer> readSQLRank(String playerName) {
|
||||
ResultSet resultSet;
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
if (checkConnected()) {
|
||||
try {
|
||||
for (SkillType skillType: SkillType.values()) {
|
||||
if (skillType.isChildSkill()) continue;
|
||||
String sql;
|
||||
if(skillType != SkillType.ALL) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||
}
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
resultSet.next();
|
||||
int rank = resultSet.getInt("rank");
|
||||
if(skillType != SkillType.ALL) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||
}
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
if(resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
@@ -502,7 +505,7 @@ public class Database {
|
||||
statement.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
@@ -511,8 +514,8 @@ public class Database {
|
||||
return skills;
|
||||
}
|
||||
|
||||
public void purgePowerlessSQL() {
|
||||
plugin.getLogger().info("Purging powerless users...");
|
||||
public static void purgePowerlessSQL() {
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
||||
|
||||
@@ -528,11 +531,11 @@ public class Database {
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public void purgeOldSQL() {
|
||||
plugin.getLogger().info("Purging old users...");
|
||||
public static void purgeOldSQL() {
|
||||
mcMMO.p.getLogger().info("Purging old users...");
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
||||
@@ -550,7 +553,7 @@ public class Database {
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
private static void printErrors(SQLException ex) {
|
||||
@@ -576,7 +579,7 @@ public class Database {
|
||||
Users.addUser(player);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutStuff.reloadSpoutPlayer(player);
|
||||
SpoutTools.reloadSpoutPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
public enum DatabaseUpdate {
|
||||
FISHING,
|
||||
BLAST_MINING,
|
||||
CASCADE_DELETE,
|
||||
CASCADE_DELETE,
|
||||
INDEX;
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.database.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor{
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
||||
@@ -20,10 +17,10 @@ public class McpurgeCommand implements CommandExecutor{
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
database.purgePowerlessSQL();
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
database.purgeOldSQL();
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.database.commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
@@ -12,18 +12,10 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
private final String location;
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McremoveCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
this.location = mcMMO.getUsersFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String playerName;
|
||||
@@ -49,9 +41,8 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
int affected = 0;
|
||||
affected = database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
||||
affected = Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
||||
|
||||
if (affected > 0) {
|
||||
sender.sendMessage(success);
|
||||
@@ -78,9 +69,10 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
FileReader file = new FileReader(usersFilePath);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
@@ -98,11 +90,11 @@ public class McremoveCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
out = new FileWriter(location); //Write out the new file
|
||||
out = new FileWriter(usersFilePath); //Write out the new file
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.database.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -8,20 +8,14 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MmoupdateCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoupdate")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +23,7 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
Users.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x);
|
||||
}
|
||||
|
||||
@@ -46,6 +40,6 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new SQLConversionTask(plugin), 1);
|
||||
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
public SQLConversionTask(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String location = mcMMO.getUsersFile();
|
||||
String location = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
@@ -166,7 +160,7 @@ public class SQLConversionTask implements Runnable {
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = database.getInt("SELECT id FROM "
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
|
||||
@@ -174,11 +168,11 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Update the skill values
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -194,7 +188,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@@ -215,32 +209,32 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Create the user in the DB
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / 1000 + ")");
|
||||
id = database.getInt("SELECT id FROM "
|
||||
+ System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -256,7 +250,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@@ -279,7 +273,7 @@ public class SQLConversionTask implements Runnable {
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SQLReconnect implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SQLReconnect(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Database.checkConnected()) {
|
||||
Users.saveAll(); //Save all profiles
|
||||
Users.clearAll(); //Clear the profiles
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,16 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
|
||||
public class UserPurgeTask implements Runnable {
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
public UserPurgeTask() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
database.purgePowerlessSQL();
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
database.purgeOldSQL();
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -6,19 +6,21 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
|
||||
@@ -26,7 +28,7 @@ public class McMMOPlayer {
|
||||
String playerName = player.getName();
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(playerName, true);
|
||||
this.party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
this.party = PartyManager.getPlayerParty(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,6 +40,10 @@ public class McMMOPlayer {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
@@ -47,52 +53,25 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
* Adds Xp to the player, doesn't calculate for Xp Rate
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
* @param skillType The skill to add Xp to
|
||||
* @param xp The amount of Xp to add
|
||||
*/
|
||||
private double calculatePartyXPModifier(SkillType skillType) {
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (party.getLeader().equals(member.getName())) {
|
||||
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
PlayerProfile partyLeader = Users.getProfile(member);
|
||||
int leaderSkill = partyLeader.getSkillLevel(skillType);
|
||||
int playerSkill = profile.getSkillLevel(skillType);
|
||||
|
||||
if (leaderSkill >= playerSkill) {
|
||||
int difference = leaderSkill - playerSkill;
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int xp) {
|
||||
public void addXpOverride(SkillType skillType, int xp) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.equals(SkillType.ALL)) {
|
||||
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, type, xp));
|
||||
profile.setSkillXPLevel(type, profile.getSkillXpLevel(type) + xp);
|
||||
profile.setSkillXpLevel(type, profile.getSkillXpLevel(type) + xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
@@ -103,49 +82,40 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this ignores skill modifiers.
|
||||
* Adds Xp to the player, this ignores skill modifiers.
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
* @param skillType The skill to add Xp to
|
||||
* @param xp The amount of Xp to add
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
|
||||
addXPOverride(skillType, modifiedXp);
|
||||
public void addXpOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = (int) Math.floor(xp * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
addXpOverride(skillType, modifiedXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
* Adds experience to the player, this is affected by skill modifiers, rate and permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
* @param skillType The skill to add Xp to
|
||||
* @param xp The amount of Xp to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player == null)
|
||||
return;
|
||||
else if (player.getGameMode() == null)
|
||||
return;
|
||||
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
public void addXp(SkillType skillType, int xp) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = calculatePartyXPModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
if (party != null && !ShareHandler.isRunning()) {
|
||||
// Return if the Xp has been shared
|
||||
if (ShareHandler.handleEqualXpShare(xp, this, skillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Misc.getPowerLevelCap() < getPowerLevel() + 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
xp = (int) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
@@ -155,30 +125,33 @@ public class McMMOPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: find a better way to do this, if possible
|
||||
if (Permissions.xpQuadruple(player)) {
|
||||
xp = xp * 4;
|
||||
xp *= 4;
|
||||
}
|
||||
else if (Permissions.xpTriple(player)) {
|
||||
xp = xp * 3;
|
||||
xp *= 3;
|
||||
}
|
||||
else if (Permissions.xpDoubleAndOneHalf(player)) {
|
||||
xp = (int) (xp * 2.5);
|
||||
xp *= 2.5;
|
||||
}
|
||||
else if (Permissions.xpDouble(player)) {
|
||||
xp = xp * 2;
|
||||
xp *= 2;
|
||||
}
|
||||
else if (Permissions.xpOneAndOneHalf(player)) {
|
||||
xp = (int) (xp * 1.5);
|
||||
xp *= 1.5;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
|
||||
SkillTools.xpCheckSkill(skillType, player, profile);
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
|
||||
@@ -7,65 +7,82 @@ import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.huds.HudType;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class PlayerProfile {
|
||||
|
||||
private String playerName;
|
||||
|
||||
/* HUD */
|
||||
// HUD
|
||||
private SpoutHud spoutHud;
|
||||
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
private HudType hudType;
|
||||
|
||||
/* Party Stuff */
|
||||
// Party Stuff
|
||||
private Party party;
|
||||
private Party invite;
|
||||
private Player ptpRequest;
|
||||
private boolean ptpEnabled = true;
|
||||
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
|
||||
|
||||
/* Toggles */
|
||||
// Toggles
|
||||
private boolean loaded;
|
||||
|
||||
private boolean placedAnvil;
|
||||
private boolean placedSalvageAnvil;
|
||||
private boolean partyChatMode, adminChatMode;
|
||||
private boolean godMode;
|
||||
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
|
||||
private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
|
||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
||||
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
||||
pickaxePreparationMode, axePreparationMode;
|
||||
private boolean abilityUse = true;
|
||||
|
||||
/* Timestamps */
|
||||
// Timestamps
|
||||
private long recentlyHurt;
|
||||
private int respawnATS;
|
||||
private long lastSave = 0L;
|
||||
private long ptpTimeout;
|
||||
|
||||
/* mySQL STUFF */
|
||||
// mySQL STUFF
|
||||
private int userId;
|
||||
|
||||
private HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
|
||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and Xp
|
||||
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private final static String location = mcMMO.getUsersFile();
|
||||
private final static String location = mcMMO.getUsersFilePath();
|
||||
|
||||
public PlayerProfile(String playerName, boolean addNew) {
|
||||
this.playerName = playerName;
|
||||
party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
party = PartyManager.getPlayerParty(playerName);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
}
|
||||
else {
|
||||
hudType = HudType.DISABLED;
|
||||
}
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
if (skillType != SkillType.ALL && !skillType.isChildSkill()) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
@@ -88,19 +105,18 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public boolean loadMySQL() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
userId = Database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> huds = database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> huds = Database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||
|
||||
if (huds.get(1) == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
else {
|
||||
for (HudType type : HudType.values()) {
|
||||
@@ -114,11 +130,11 @@ public class PlayerProfile {
|
||||
* I'm still learning MySQL, this is a fix for adding a new table
|
||||
* its not pretty but it works
|
||||
*/
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = Database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||
ArrayList<String> cooldownValues = cooldowns.get(1);
|
||||
|
||||
if (cooldownValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
||||
}
|
||||
else {
|
||||
@@ -132,11 +148,11 @@ public class PlayerProfile {
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> stats = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> stats = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||
ArrayList<String> statValues = stats.get(1);
|
||||
|
||||
if (statValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
||||
}
|
||||
else {
|
||||
@@ -154,11 +170,11 @@ public class PlayerProfile {
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> experience = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> experience = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||
ArrayList<String> experienceValues = experience.get(1);
|
||||
|
||||
if (experienceValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
||||
}
|
||||
else {
|
||||
@@ -181,25 +197,24 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void addMySQLPlayer() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
|
||||
userId = database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
userId = Database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
try {
|
||||
//Open the user file
|
||||
// Open the user file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
//Find if the line contains the player we want.
|
||||
// Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
|
||||
if (!character[0].equals(playerName)) {
|
||||
@@ -300,14 +315,13 @@ public class PlayerProfile {
|
||||
if (timestamp < (lastSave + ((long) Config.getInstance().getSaveInterval() * 60000)) && !override)
|
||||
return;
|
||||
|
||||
// if we are using mysql save to database
|
||||
// If we are using mysql save to database
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / 1000L)) + " WHERE id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
Database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
Database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId);
|
||||
Database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
||||
@@ -317,7 +331,7 @@ public class PlayerProfile {
|
||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "skills SET "
|
||||
Database.write("UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = " + skills.get(SkillType.TAMING)
|
||||
+ ", mining = " + skills.get(SkillType.MINING)
|
||||
+ ", repair = " + skills.get(SkillType.REPAIR)
|
||||
@@ -331,7 +345,7 @@ public class PlayerProfile {
|
||||
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
||||
+ ", fishing = " + skills.get(SkillType.FISHING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "experience SET "
|
||||
Database.write("UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
||||
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
||||
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
|
||||
@@ -347,68 +361,68 @@ public class PlayerProfile {
|
||||
+ " WHERE user_id = " + userId);
|
||||
}
|
||||
else {
|
||||
// otherwise save to flatfile
|
||||
// Otherwise save to flatfile
|
||||
try {
|
||||
//Open the file
|
||||
// Open the file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
String line;
|
||||
|
||||
//While not at the end of the file
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
//Read the line in and copy it to the output it's not the player
|
||||
//we want to edit
|
||||
// Read the line in and copy it to the output it's not the player
|
||||
// we want to edit
|
||||
if (!line.split(":")[0].equals(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
//Otherwise write the new player information
|
||||
writer.append(playerName + ":");
|
||||
writer.append(skills.get(SkillType.MINING) + ":");
|
||||
writer.append("" + ":");
|
||||
writer.append("" + ":");
|
||||
writer.append(skillsXp.get(SkillType.MINING) + ":");
|
||||
writer.append(skills.get(SkillType.WOODCUTTING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
|
||||
writer.append(skills.get(SkillType.REPAIR) + ":");
|
||||
writer.append(skills.get(SkillType.UNARMED) + ":");
|
||||
writer.append(skills.get(SkillType.HERBALISM) + ":");
|
||||
writer.append(skills.get(SkillType.EXCAVATION) + ":");
|
||||
writer.append(skills.get(SkillType.ARCHERY) + ":");
|
||||
writer.append(skills.get(SkillType.SWORDS) + ":");
|
||||
writer.append(skills.get(SkillType.AXES) + ":");
|
||||
writer.append(skills.get(SkillType.ACROBATICS) + ":");
|
||||
writer.append(skillsXp.get(SkillType.REPAIR) + ":");
|
||||
writer.append(skillsXp.get(SkillType.UNARMED) + ":");
|
||||
writer.append(skillsXp.get(SkillType.HERBALISM) + ":");
|
||||
writer.append(skillsXp.get(SkillType.EXCAVATION) + ":");
|
||||
writer.append(skillsXp.get(SkillType.ARCHERY) + ":");
|
||||
writer.append(skillsXp.get(SkillType.SWORDS) + ":");
|
||||
writer.append(skillsXp.get(SkillType.AXES) + ":");
|
||||
writer.append(skillsXp.get(SkillType.ACROBATICS) + ":");
|
||||
writer.append("" + ":");
|
||||
writer.append(skills.get(SkillType.TAMING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.TAMING) + ":");
|
||||
//Need to store the DATS of abilities nao
|
||||
//Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
|
||||
writer.append(hudType.toString() + ":");
|
||||
writer.append(skills.get(SkillType.FISHING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
|
||||
// Otherwise write the new player information
|
||||
writer.append(playerName).append(":");
|
||||
writer.append(skills.get(SkillType.MINING)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(":");
|
||||
writer.append(skillsXp.get(SkillType.MINING)).append(":");
|
||||
writer.append(skills.get(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(skills.get(SkillType.REPAIR)).append(":");
|
||||
writer.append(skills.get(SkillType.UNARMED)).append(":");
|
||||
writer.append(skills.get(SkillType.HERBALISM)).append(":");
|
||||
writer.append(skills.get(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(skills.get(SkillType.ARCHERY)).append(":");
|
||||
writer.append(skills.get(SkillType.SWORDS)).append(":");
|
||||
writer.append(skills.get(SkillType.AXES)).append(":");
|
||||
writer.append(skills.get(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.REPAIR)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.UNARMED)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.HERBALISM)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.ARCHERY)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.SWORDS)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.AXES)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(skills.get(SkillType.TAMING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.TAMING)).append(":");
|
||||
// Need to store the DATS of abilities nao
|
||||
// Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK))).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER))).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER))).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA))).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES))).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER))).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER))).append(":");
|
||||
writer.append(hudType.toString()).append(":");
|
||||
writer.append(skills.get(SkillType.FISHING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING)).append(":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING))).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
//Write the new file
|
||||
// Write the new file
|
||||
FileWriter out = new FileWriter(location);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
@@ -417,55 +431,55 @@ public class PlayerProfile {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
lastSave = timestamp;
|
||||
lastSave = timestamp;
|
||||
}
|
||||
|
||||
public void addPlayer() {
|
||||
try {
|
||||
//Open the file to write the player
|
||||
// Open the file to write the player
|
||||
FileWriter file = new FileWriter(location, true);
|
||||
BufferedWriter out = new BufferedWriter(file);
|
||||
|
||||
//Add the player to the end
|
||||
out.append(playerName + ":");
|
||||
out.append(0 + ":"); //mining
|
||||
out.append("" + ":");
|
||||
out.append("" + ":");
|
||||
out.append(0 + ":"); //XP
|
||||
out.append(0 + ":"); //woodcutting
|
||||
out.append(0 + ":"); //woodCuttingXP
|
||||
out.append(0 + ":"); //repair
|
||||
out.append(0 + ":"); //unarmed
|
||||
out.append(0 + ":"); //herbalism
|
||||
out.append(0 + ":"); //excavation
|
||||
out.append(0 + ":"); //archery
|
||||
out.append(0 + ":"); //swords
|
||||
out.append(0 + ":"); //axes
|
||||
out.append(0 + ":"); //acrobatics
|
||||
out.append(0 + ":"); //repairXP
|
||||
out.append(0 + ":"); //unarmedXP
|
||||
out.append(0 + ":"); //herbalismXP
|
||||
out.append(0 + ":"); //excavationXP
|
||||
out.append(0 + ":"); //archeryXP
|
||||
out.append(0 + ":"); //swordsXP
|
||||
out.append(0 + ":"); //axesXP
|
||||
out.append(0 + ":"); //acrobaticsXP
|
||||
out.append("" + ":");
|
||||
out.append(0 + ":"); //taming
|
||||
out.append(0 + ":"); //tamingXP
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(SpoutConfig.getInstance().defaultHudType.toString() + ":");//HUD
|
||||
out.append(0 + ":"); //Fishing
|
||||
out.append(0 +":"); //FishingXP
|
||||
out.append(0 + ":"); //Blast Mining
|
||||
// Add the player to the end
|
||||
out.append(playerName).append(":");
|
||||
out.append("0:"); // mining
|
||||
out.append(":");
|
||||
out.append(":");
|
||||
out.append("0:"); // Xp
|
||||
out.append("0:"); // woodcutting
|
||||
out.append("0:"); // woodCuttingXp
|
||||
out.append("0:"); // repair
|
||||
out.append("0:"); // unarmed
|
||||
out.append("0:"); // herbalism
|
||||
out.append("0:"); // excavation
|
||||
out.append("0:"); // archery
|
||||
out.append("0:"); // swords
|
||||
out.append("0:"); // axes
|
||||
out.append("0:"); // acrobatics
|
||||
out.append("0:"); // repairXp
|
||||
out.append("0:"); // unarmedXp
|
||||
out.append("0:"); // herbalismXp
|
||||
out.append("0:"); // excavationXp
|
||||
out.append("0:"); // archeryXp
|
||||
out.append("0:"); // swordsXp
|
||||
out.append("0:"); // axesXp
|
||||
out.append("0:"); // acrobaticsXp
|
||||
out.append(":");
|
||||
out.append("0:"); // taming
|
||||
out.append("0:"); // tamingXp
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append(hudType.toString()).append(":"); // HUD
|
||||
out.append("0:"); // Fishing
|
||||
out.append("0:"); // FishingXp
|
||||
out.append("0:"); // Blast Mining
|
||||
|
||||
//Add more in the same format as the line above
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
out.close();
|
||||
@@ -658,7 +672,7 @@ public class PlayerProfile {
|
||||
* @param ATS the ATS of the tool
|
||||
*/
|
||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||
int startTime = (int) (ATS / 1000);
|
||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
||||
toolATS.put(tool, startTime);
|
||||
}
|
||||
|
||||
@@ -853,7 +867,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void actualizeRecentlyHurt() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / 1000);
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -899,22 +913,36 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void actualizeRespawnATS() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / 1000);
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP Functions
|
||||
* Xp Functions
|
||||
*/
|
||||
|
||||
public int getSkillLevel(SkillType skillType) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return getChildSkillLevel(skillType);
|
||||
}
|
||||
|
||||
return skills.get(skillType);
|
||||
}
|
||||
|
||||
public int getChildSkillLevel(SkillType skillType) {
|
||||
switch (skillType) {
|
||||
case SMELTING:
|
||||
return ((getSkillLevel(SkillType.MINING) / 4) + (getSkillLevel(SkillType.REPAIR) / 4)); //TODO: Make this cleaner somehow
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(SkillType skillType) {
|
||||
return skillsXp.get(skillType);
|
||||
}
|
||||
|
||||
public void setSkillXPLevel(SkillType skillType, int newValue) {
|
||||
public void setSkillXpLevel(SkillType skillType, int newValue) {
|
||||
skillsXp.put(skillType, newValue);
|
||||
save(false);
|
||||
}
|
||||
@@ -924,29 +952,13 @@ public class PlayerProfile {
|
||||
save(false);
|
||||
}
|
||||
|
||||
public void resetSkill(SkillType skillType)
|
||||
{
|
||||
//do a single skilltype
|
||||
if (skillType != SkillType.ALL)
|
||||
skills.put(skillType, 0);
|
||||
else //do them all
|
||||
{
|
||||
for (SkillType skill : SkillType.values()) //iterate over all items in the enumeration
|
||||
{
|
||||
if (skill != SkillType.ALL) // skip the "all" value
|
||||
skills.put(skill, 0);
|
||||
}
|
||||
}
|
||||
save(false);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Adds XP to the player, doesn't calculate for XP Rate
|
||||
// * Adds Xp to the player, doesn't calculate for Xp Rate
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newValue The amount of XP to add
|
||||
// * @param skillType The skill to add Xp to
|
||||
// * @param newValue The amount of Xp to add
|
||||
// */
|
||||
// public void addXPOverride(SkillType skillType, int newValue) {
|
||||
// public void addXpOverride(SkillType skillType, int newValue) {
|
||||
// if (skillType.equals(SkillType.ALL)) {
|
||||
// for (SkillType x : SkillType.values()) {
|
||||
// if (x.equals(SkillType.ALL)) {
|
||||
@@ -965,23 +977,23 @@ public class PlayerProfile {
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Adds XP to the player, this ignores skill modifiers.
|
||||
// * Adds Xp to the player, this ignores skill modifiers.
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newValue The amount of XP to add
|
||||
// * @param skillType The skill to add Xp to
|
||||
// * @param newValue The amount of Xp to add
|
||||
// */
|
||||
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
// public void addXpOverrideBonus(SkillType skillType, int newValue) {
|
||||
// int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||
// addXPOverride(skillType, xp);
|
||||
// addXpOverride(skillType, xp);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
// * Adds Xp to the player, this is affected by skill modifiers and Xp Rate and Permissions
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newvalue The amount of XP to add
|
||||
// * @param skillType The skill to add Xp to
|
||||
// * @param newvalue The amount of Xp to add
|
||||
// */
|
||||
// public void addXP(SkillType skillType, int newValue) {
|
||||
// public void addXp(SkillType skillType, int newValue) {
|
||||
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
// return;
|
||||
// }
|
||||
@@ -1035,12 +1047,16 @@ public class PlayerProfile {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Remove XP from a skill.
|
||||
* Remove Xp from a skill.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param xp Amount of xp to remove
|
||||
*/
|
||||
public void removeXP(SkillType skillType, int xp) {
|
||||
public void removeXp(SkillType skillType, int xp) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
@@ -1063,6 +1079,10 @@ public class PlayerProfile {
|
||||
* @param newValue New level value for the skill
|
||||
*/
|
||||
public void modifySkill(SkillType skillType, int newValue) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
@@ -1087,9 +1107,13 @@ public class PlayerProfile {
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public void addLevels(SkillType skillType, int levels) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillType == SkillType.ALL) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
if (skill == SkillType.ALL || skill.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1105,10 +1129,10 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP remaining before the next level.
|
||||
* Get the amount of Xp remaining before the next level.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the XP remaining until next level
|
||||
* @return the Xp remaining until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||
@@ -1132,7 +1156,7 @@ public class PlayerProfile {
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Calculate the party XP modifier.
|
||||
// * Calculate the party Xp modifier.
|
||||
// *
|
||||
// * @param skillType Type of skill to check
|
||||
// * @return the party bonus multiplier
|
||||
@@ -1203,4 +1227,52 @@ public class PlayerProfile {
|
||||
public void removeInvite() {
|
||||
invite = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Party Teleportation
|
||||
*/
|
||||
|
||||
public boolean getPtpEnabled() {
|
||||
return ptpEnabled;
|
||||
}
|
||||
|
||||
public void togglePtpUse() {
|
||||
ptpEnabled = !ptpEnabled;
|
||||
}
|
||||
|
||||
public void setPtpRequest(Player ptpRequest) {
|
||||
this.ptpRequest = ptpRequest;
|
||||
}
|
||||
|
||||
public Player getPtpRequest() {
|
||||
return ptpRequest;
|
||||
}
|
||||
|
||||
public boolean hasPtpRequest() {
|
||||
if (ptpRequest != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removePtpRequest() {
|
||||
ptpRequest = null;
|
||||
}
|
||||
|
||||
public boolean getPtpConfirmRequired() {
|
||||
return ptpConfirmRequired;
|
||||
}
|
||||
|
||||
public void togglePtpConfirmRequired() {
|
||||
ptpConfirmRequired = !ptpConfirmRequired;
|
||||
}
|
||||
|
||||
public long getPtpTimeout() {
|
||||
return ptpTimeout;
|
||||
}
|
||||
|
||||
public void actualizePtpTimeout() {
|
||||
ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ public class PlayerStat {
|
||||
public String name;
|
||||
public int statVal = 0;
|
||||
|
||||
public PlayerStat() {};
|
||||
|
||||
public PlayerStat(String name, int value) {
|
||||
this.name = name;
|
||||
this.statVal = value;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.datatypes.treasure;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ExcavationTreasure extends Treasure {
|
||||
|
||||
// dirt | grass | sand | gravel | clay | mycel | soulsand
|
||||
// 00000001 - dirt 1
|
||||
// 00000010 - grass 2
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HylianTreasure extends Treasure {
|
||||
// bushes | flowers | pots
|
||||
// 00000001 - bushes 1
|
||||
// 00000010 - flowers 2
|
||||
// 00000100 - pots 4
|
||||
private byte dropsFrom = 0x0;
|
||||
|
||||
public HylianTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
}
|
||||
|
||||
// Raw getters and setters
|
||||
public byte getDropsFrom() {
|
||||
return dropsFrom;
|
||||
}
|
||||
|
||||
public void setDropsFrom(byte dropsFrom) {
|
||||
this.dropsFrom = dropsFrom;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean getDropsFromBushes() {
|
||||
return getDropFromMask(1);
|
||||
}
|
||||
|
||||
public boolean getDropsFromFlowers() {
|
||||
return getDropFromMask(2);
|
||||
}
|
||||
|
||||
public boolean getDropsFromPots() {
|
||||
return getDropFromMask(4);
|
||||
}
|
||||
|
||||
private boolean getDropFromMask(int mask) {
|
||||
return ((dropsFrom & mask) > 0) ? true : false;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setDropsFromBushes() {
|
||||
setDropFromMask(1);
|
||||
}
|
||||
|
||||
public void setDropsFromFlowers() {
|
||||
setDropFromMask(2);
|
||||
}
|
||||
|
||||
public void setDropsFromPots() {
|
||||
setDropFromMask(4);
|
||||
}
|
||||
|
||||
private void setDropFromMask(int mask) {
|
||||
dropsFrom |= mask;
|
||||
}
|
||||
|
||||
// Un-setters
|
||||
public void unsetDropsFromBushes() {
|
||||
unsetDropFromMask(1);
|
||||
}
|
||||
|
||||
public void unsetDropsFromFlowers() {
|
||||
unsetDropFromMask(2);
|
||||
}
|
||||
|
||||
public void unsetDropsFromPots() {
|
||||
unsetDropFromMask(4);
|
||||
}
|
||||
|
||||
private void unsetDropFromMask(int mask) {
|
||||
dropsFrom &= ~mask;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to the admin chat channel
|
||||
*/
|
||||
public class McMMOAdminChatEvent extends McMMOChatEvent{
|
||||
|
||||
public McMMOAdminChatEvent(String sender, String message) {
|
||||
super(sender, message);
|
||||
public class McMMOAdminChatEvent extends McMMOChatEvent {
|
||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
||||
super(plugin, sender, displayName, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,29 @@ package com.gmail.nossr50.events.chat;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class McMMOChatEvent extends Event implements Cancellable{
|
||||
public class McMMOChatEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private Plugin plugin;
|
||||
private String sender;
|
||||
private String displayName;
|
||||
private String message;
|
||||
|
||||
public McMMOChatEvent(String sender, String message) {
|
||||
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
this.displayName = displayName;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The plugin responsible for this event, note this can be null
|
||||
*/
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
@@ -21,6 +33,13 @@ public class McMMOChatEvent extends Event implements Cancellable{
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String display name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String message that will be sent
|
||||
*/
|
||||
@@ -28,6 +47,13 @@ public class McMMOChatEvent extends Event implements Cancellable{
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName String display name of the player who sent the chat
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message String message to be sent in chat
|
||||
*/
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to a party channel
|
||||
*/
|
||||
public class McMMOPartyChatEvent extends McMMOChatEvent{
|
||||
public class McMMOPartyChatEvent extends McMMOChatEvent {
|
||||
private String party;
|
||||
|
||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||
super(sender, message);
|
||||
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
super(plugin, sender, displayName, message);
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Generic event for mcMMO experience events.
|
||||
*/
|
||||
public class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
|
||||
public McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = skill.getSkillLevel(player);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.events.experience;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Called when a user levels up in a skill
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.events.experience;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Called when a player gains XP in a skill
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
* Called when mcMMO breaks a block due to a special ability.
|
||||
*/
|
||||
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
||||
|
||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
* Called when mcMMO damages a block due to a special ability.
|
||||
*/
|
||||
public class FakeBlockDamageEvent extends BlockDamageEvent {
|
||||
|
||||
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
||||
super(player, block, itemInHand, instaBreak);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
* Called when mcMMO applies damage due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
||||
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||
super(damagee, cause, damage);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
* Called when handling extra drops to avoid issues with NoCheat.
|
||||
*/
|
||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
|
||||
|
||||
public FakePlayerAnimationEvent(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,11 @@ import org.bukkit.event.player.PlayerEvent;
|
||||
/**
|
||||
* Called when a player attempts to join, leave, or change parties.
|
||||
*/
|
||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
|
||||
|
||||
protected String oldParty;
|
||||
protected String newParty;
|
||||
protected EventReason reason;
|
||||
protected boolean cancelled;
|
||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private String oldParty;
|
||||
private String newParty;
|
||||
private EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
/**
|
||||
* Called just before a player teleports using the /ptp command.
|
||||
*/
|
||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent{
|
||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||
private String party;
|
||||
private Player target;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.gmail.nossr50.events.skills;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private Player defender;
|
||||
|
||||
public McMMOPlayerDisarmEvent(Player defender) {
|
||||
super(defender, SkillType.UNARMED);
|
||||
this.defender = defender;
|
||||
}
|
||||
|
||||
public Player getDefender() {
|
||||
return defender;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Called just before a player repairs an object with mcMMO.
|
||||
|
||||
@@ -4,16 +4,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Generic event for mcMMO skill handling.
|
||||
*/
|
||||
public class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||
public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
|
||||
public McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||
protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = skill.getSkillLevel(player);
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.gmail.nossr50.listeners;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -16,30 +18,32 @@ import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
||||
import com.gmail.nossr50.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.excavation.Excavation;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.gathering.WoodCutting;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
@@ -58,8 +62,7 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
// Block that would be air after piston is finished
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction);
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (mcMMO.placeStore.isTrue(b)) {
|
||||
@@ -81,41 +84,45 @@ public class BlockListener implements Listener {
|
||||
/**
|
||||
* Monitor BlockPistonRetract events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (event.isSticky()) {
|
||||
//Needed only because under some circumstances Minecraft doesn't move the block
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 0);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPlace events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Config configInstance = Config.getInstance();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
int id = block.getTypeId();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
|
||||
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
|
||||
Repair.placedAnvilCheck(player, id);
|
||||
}
|
||||
if (id == configInstance.getSalvageAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
|
||||
Salvage.placedAnvilCheck(player, id);
|
||||
if (Repair.anvilMessagesEnabled) {
|
||||
int blockID = block.getTypeId();
|
||||
|
||||
if (blockID == Repair.anvilID) {
|
||||
Repair.placedAnvilCheck(player, blockID);
|
||||
}
|
||||
else if (blockID == Salvage.anvilID) {
|
||||
Salvage.placedAnvilCheck(player, blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,175 +138,226 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, mcMMOPlayer.getProfile())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockChecks.canBeGreenTerra(block)) {
|
||||
/* Green Terra */
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* Triple drops */
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (Permissions.herbalism(player)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
Herbalism.herbalismProcCheck(block, mcMMOPlayer, event, plugin); //Double drops
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, mcMMOPlayer, event, plugin); //Triple drops
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockChecks.canBeSuperBroken(block) && Permissions.mining(player)) {
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
else if (BlockChecks.canBeSuperBroken(block) && Permissions.mining(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (Mining.requiresTool) {
|
||||
if (ItemChecks.isPickaxe(heldItem)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.miningBlockCheck(block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.miningBlockCheck(block);
|
||||
}
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockChecks.isLog(block) && Permissions.woodcutting(player)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
else if (BlockChecks.isLog(block) && Permissions.woodcutting(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginTreeFeller(mcMMOPlayer, block);
|
||||
}
|
||||
else {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginWoodcutting(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Woodcutting.beginWoodcutting(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
if (Excavation.requiresTool) {
|
||||
if (ItemChecks.isShovel(heldItem)) {
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
/* Remove metadata from placed watched blocks */
|
||||
if (BlockChecks.shouldBeWatched(block) && mcMMO.placeStore.isTrue(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle BlockBreak events where the event is modified.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreakHigher(BlockBreakEvent event) {
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (Permissions.hylianLuck(player) && ItemChecks.isSword(heldItem)) {
|
||||
Herbalism.hylianLuck(block, player, event);
|
||||
}
|
||||
else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.fluxMining(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle BlockDamage events where the event is modified.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamageHigher(BlockDamageEvent event) {
|
||||
if (event instanceof FakeBlockDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*
|
||||
* We check permissions here before processing activation.
|
||||
*/
|
||||
if (BlockChecks.canActivateAbilities(block)) {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && Permissions.greenTerra(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.canBeSuperBroken(block) && Permissions.superBreaker(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW)) && Permissions.berserk(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TREE FELLER SOUNDS
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(block)) {
|
||||
player.playSound(block.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockDamage events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
if (event instanceof FakeBlockDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/* TREE FELLER SOUNDS */
|
||||
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && profile.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block)) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (Excavation.requiresTool) {
|
||||
if (ItemChecks.isShovel(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inHand.getType().equals(Material.AIR)) {
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (heldItem.getType().equals(Material.AIR)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
event.setInstaBreak(true);
|
||||
}
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
if (Mining.requiresTool) {
|
||||
if (ItemChecks.isPickaxe(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
miningManager.superBreakerBlockCheck(block);
|
||||
}
|
||||
@@ -309,17 +367,17 @@ public class BlockListener implements Listener {
|
||||
miningManager.superBreakerBlockCheck(block);
|
||||
}
|
||||
}
|
||||
else if (profile.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) {
|
||||
if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
Woodcutting.beginLeafBlower(player, block);
|
||||
}
|
||||
}
|
||||
else if (!inHand.getType().equals(Material.SHEARS)) {
|
||||
else if (!heldItem.getType().equals(Material.SHEARS)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
Woodcutting.beginLeafBlower(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -28,22 +27,22 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
@@ -53,7 +52,12 @@ public class EntityListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
/**
|
||||
* Monitor EntityChangeBlock events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
@@ -72,22 +76,22 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityDamageByEntity events.
|
||||
* Handle EntityDamageByEntity events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent)
|
||||
if (event instanceof FakeEntityDamageByEntityEvent || event.getDamage() <= 0)
|
||||
return;
|
||||
|
||||
if (event.getDamage() <= 0)
|
||||
return;
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
|
||||
if (Misc.isNPCEntity(defender) || defender.isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
@@ -95,7 +99,7 @@ public class EntityListener implements Listener {
|
||||
else if (attacker instanceof Tameable) {
|
||||
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||
|
||||
if (animalTamer instanceof Entity) {
|
||||
if (animalTamer != null) {
|
||||
attacker = (Entity) animalTamer;
|
||||
}
|
||||
}
|
||||
@@ -107,11 +111,9 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (PartyManager.getInstance().inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,59 +122,58 @@ public class EntityListener implements Listener {
|
||||
LivingEntity livingDefender = (LivingEntity) defender;
|
||||
|
||||
if (!Misc.isInvincible(livingDefender, event)) {
|
||||
Combat.combatChecks(event);
|
||||
CombatTools.combatChecks(event, attacker, livingDefender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityDamage events.
|
||||
* Handle EntityDamage events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event instanceof FakeEntityDamageEvent) {
|
||||
if (event instanceof FakeEntityDamageEvent || event.getDamage() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity lEntity = (LivingEntity) entity;
|
||||
DamageCause cause = event.getCause();
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (lEntity instanceof Player) {
|
||||
/* Check for invincibility */
|
||||
if (livingEntity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
if (profile.getGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Misc.isInvincible(player, event)) {
|
||||
if (cause == DamageCause.FALL && !player.isInsideVehicle() && !(player.getItemInHand().getType() == Material.ENDER_PEARL)) {
|
||||
AcrobaticsManager acroManager = new AcrobaticsManager(player);
|
||||
acroManager.rollCheck(event);
|
||||
if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) {
|
||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
|
||||
acrobaticsManager.rollCheck(event);
|
||||
}
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) {
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.demolitionsExpertise(event);
|
||||
}
|
||||
|
||||
@@ -180,12 +181,13 @@ public class EntityListener implements Listener {
|
||||
profile.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
} else if (lEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) lEntity;
|
||||
}
|
||||
else if (livingEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) livingEntity;
|
||||
AnimalTamer owner = pet.getOwner();
|
||||
|
||||
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (owner instanceof Player) && pet instanceof Wolf) {
|
||||
TamingManager tamingManager = new TamingManager((Player) owner);
|
||||
if ((!Misc.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner));
|
||||
tamingManager.preventDamage(event);
|
||||
}
|
||||
}
|
||||
@@ -194,46 +196,49 @@ public class EntityListener implements Listener {
|
||||
/**
|
||||
* Monitor EntityDeath events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
if (Misc.isNPCEntity(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setFireTicks(0);
|
||||
BleedTimer.remove(entity);
|
||||
Archery.arrowRetrievalCheck(entity);
|
||||
mcMMO.placeStore.removeSpawnedMob(entity);
|
||||
mcMMO.placeStore.removeSpawnedPet(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor CreatureSpawn events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (Misc.isSpawnerXPEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnReason reason = event.getSpawnReason();
|
||||
|
||||
if ((reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) && !Config.getInstance().getExperienceGainsMobspawnersEnabled()) {
|
||||
if (reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) {
|
||||
mcMMO.placeStore.addSpawnedMob(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor ExplosionPrime events.
|
||||
* Handle ExplosionPrime events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
@@ -241,7 +246,7 @@ public class EntityListener implements Listener {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
|
||||
if (Permissions.biggerBombs(player)) {
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.biggerBombs(event);
|
||||
}
|
||||
}
|
||||
@@ -249,46 +254,48 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityExplode events.
|
||||
* Handle EntityExplode events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity == null) return;
|
||||
|
||||
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.blastMiningDropProcessing(event);
|
||||
|
||||
plugin.removeFromTNTTracker(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor FoodLevelChange events.
|
||||
* Handle FoodLevelChange events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
@EventHandler (priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
|
||||
/*
|
||||
* Some foods have 3 ranks
|
||||
@@ -296,117 +303,35 @@ public class EntityListener implements Listener {
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
|
||||
int fishLevel = profile.getSkillLevel(SkillType.FISHING);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
boolean fish = false;
|
||||
boolean herb = false;
|
||||
int FoodRank1 = advancedConfig.getFarmerDietRankChange();
|
||||
int FoodRank2 = advancedConfig.getFarmerDietRankChange() * 2;
|
||||
int FoodRankMax = advancedConfig.getFarmerDietRankChange() * 5;
|
||||
|
||||
switch (food) {
|
||||
case BREAD:
|
||||
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank1;
|
||||
if (foodChange > 0) {
|
||||
switch (player.getItemInHand().getType()) {
|
||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, event);
|
||||
break;
|
||||
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank2;
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, event);
|
||||
break;
|
||||
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank2;
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, event);
|
||||
break;
|
||||
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank1;
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, event);
|
||||
break;
|
||||
|
||||
case CARROT_ITEM:
|
||||
/* CARROT RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank1;
|
||||
break;
|
||||
|
||||
case POTATO_ITEM:
|
||||
/* POTATO RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank2;
|
||||
break;
|
||||
|
||||
case BAKED_POTATO:
|
||||
/* BAKED POTATO RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank1;
|
||||
break;
|
||||
|
||||
case POISONOUS_POTATO:
|
||||
/* POISONOUS POTATO RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank2;
|
||||
break;
|
||||
|
||||
case GOLDEN_CARROT:
|
||||
/* GOLDEN CARROT RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank1;
|
||||
break;
|
||||
|
||||
case PUMPKIN_PIE:
|
||||
/* PUMPKIN PIE RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
herb = true;
|
||||
rankChange = FoodRank1;
|
||||
break;
|
||||
|
||||
case RAW_FISH:
|
||||
/* RAW FISH RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = FoodRank2;
|
||||
fish = true;
|
||||
break;
|
||||
|
||||
case COOKED_FISH:
|
||||
/* COOKED FISH RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
rankChange = FoodRank1;
|
||||
fish = true;
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (herb && !Permissions.farmersDiet(player)) {
|
||||
return;
|
||||
}
|
||||
else if (fish && !Permissions.fishermansDiet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = FoodRank1; i <= FoodRankMax; i += rankChange) {
|
||||
if ((herb && herbLevel >= i) || (fish && fishLevel >= i)) {
|
||||
foodChange++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we don't go over the max value */
|
||||
newFoodLevel = currentFoodLevel + foodChange;
|
||||
if (newFoodLevel > 20) {
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
event.setFoodLevel(newFoodLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,31 +341,15 @@ public class EntityListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.taming(player) && !mcMMO.placeStore.isSpawnedPet(event.getEntity())) {
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
int xp = 0;
|
||||
|
||||
switch (type) {
|
||||
case WOLF:
|
||||
xp = Config.getInstance().getTamingXPWolf();
|
||||
break;
|
||||
|
||||
case OCELOT:
|
||||
xp = Config.getInstance().getTamingXPOcelot();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, profile, SkillType.TAMING, xp);
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.awardTamingXP(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,29 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Hardcore;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDeath events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.hardcoremodeBypass(player)) {
|
||||
if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
Player killer = player.getKiller();
|
||||
|
||||
if (killer != null && Hardcore.vampirismEnabled) {
|
||||
Hardcore.invokeVampirism(killer, player);
|
||||
}
|
||||
|
||||
Hardcore.invokeStatPenalty(player);
|
||||
|
||||
131
src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
Normal file
131
src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InventoryListener implements Listener{
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InventoryListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
InventoryType inventoryType = event.getInventory().getType();
|
||||
|
||||
if (inventoryType == InventoryType.FURNACE) {
|
||||
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
|
||||
Furnace furnace = inventory.getHolder();
|
||||
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.addToOpenFurnaceTracker(furnaceBlock, event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
InventoryType inventoryType = event.getInventory().getType();
|
||||
|
||||
if (inventoryType == InventoryType.FURNACE) {
|
||||
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
|
||||
Furnace furnace = inventory.getHolder();
|
||||
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.removeFromFurnaceTracker(furnaceBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (player != null) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.fuelEfficiency(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (player != null) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.smeltProcessing(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack result = inventory.getResult();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) {
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(plugin.getFurnacePlayer(furnaceBlock));
|
||||
|
||||
if (event.getPlayer().equals(mcMMOPlayer.getPlayer())) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer);
|
||||
smeltingManager.vanillaXPBoost(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -8,45 +7,41 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent.State;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.Motd;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
private final mcMMO plugin;
|
||||
|
||||
public PlayerListener(final mcMMO plugin) {
|
||||
@@ -61,27 +56,20 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
if (!Permissions.mcgod(player)) {
|
||||
profile.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
if (profile.getGodMode() && !Permissions.mcgod(player)) {
|
||||
profile.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
|
||||
if (profile.inParty()) {
|
||||
if (!Permissions.party(player)) {
|
||||
profile.removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
if (profile.inParty() && !Permissions.party(player)) {
|
||||
profile.removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,54 +80,28 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
int shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.fishing(player)) {
|
||||
State state = event.getState();
|
||||
|
||||
switch (state) {
|
||||
case CAUGHT_FISH:
|
||||
Fishing.processResults(event);
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= shakeUnlockLevel && Permissions.shakeMob(player)) {
|
||||
Fishing.shakeMob(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlaterPickupItem events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
|
||||
if (event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player) || !Permissions.fishing(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||
event.setCancelled(true);
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.FISHING);
|
||||
|
||||
switch (event.getState()) {
|
||||
case CAUGHT_FISH:
|
||||
Fishing.beginFishing(Users.getPlayer(player), skillLevel, event);
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
if (skillLevel >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shakeMob(player)) {
|
||||
//TODO: Unsafe cast?
|
||||
Fishing.beginShakeMob(player, (LivingEntity) event.getCaught(), skillLevel);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +112,14 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if (event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/* We can't use the other check here because a profile hasn't been created yet.*/
|
||||
if (player == null || player.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Users.addUser(player).getProfile().actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,12 +131,12 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* GARBAGE COLLECTION */
|
||||
|
||||
//Bleed it out
|
||||
BleedTimer.bleedOut(player);
|
||||
BleedTimer.bleedOut(player); //Bleed it out
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,81 +148,86 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {plugin.getDescription().getVersion()}));
|
||||
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Config.getInstance().getHardcoreDeathStatPenaltyPercentage()}));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", new Object[] {Config.getInstance().getHardcoreVampirismStatLeechPercentage()}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOff"));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Config.getInstance().getHardcoreDeathStatPenaltyPercentage()}));
|
||||
}
|
||||
}
|
||||
|
||||
if (Permissions.xpQuadruple(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
|
||||
}
|
||||
else if (Permissions.xpTriple(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 3 }) }));
|
||||
}
|
||||
else if (Permissions.xpDoubleAndOneHalf(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 2.5 }) }));
|
||||
}
|
||||
else if (Permissions.xpDouble(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 2 }) }));
|
||||
}
|
||||
else if (Permissions.xpOneAndOneHalf(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 1.5 }) }));
|
||||
}
|
||||
|
||||
if (Permissions.cooldownsHalved(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/2" }) }));
|
||||
}
|
||||
else if (Permissions.cooldownsThirded(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/3" }) }));
|
||||
}
|
||||
else if (Permissions.cooldownsQuartered(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/4" }) }));
|
||||
}
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 12 }) }));
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 8 }) }));
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 4 }) }));
|
||||
}
|
||||
|
||||
if (Permissions.luckyAcrobatics(player) || Permissions.luckyArchery(player) || Permissions.luckyAxes(player) || Permissions.luckyFishing(player) || Permissions.luckyHerbalism(player) || Permissions.luckyMining(player) || Permissions.luckyRepair(player) || Permissions.luckySwords(player) || Permissions.luckyTaming(player) || Permissions.luckyUnarmed(player) || Permissions.luckyWoodcutting(player)) {
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Website", new Object[] {plugin.getDescription().getWebsite()}));
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if (XprateCommand.isXpEventRunning()) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
Motd.displayAll(player);
|
||||
}
|
||||
|
||||
if (plugin.isXPEventEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().getExperienceGainsGlobalMultiplier()}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerRespawn events.
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if (event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile != null) {
|
||||
profile.actualizeRespawnATS();
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
profile.actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PlayerInteract events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
int blockID = block.getTypeId();
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.anvilID && Permissions.repair(player) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||
mcMMO.repairManager.handleRepair(Users.getPlayer(player), heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) {
|
||||
Salvage.handleSalvage(player, block.getLocation(), heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
/* BLAST MINING CHECK */
|
||||
else if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.detonate(event);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.detonate(event);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,72 +236,41 @@ public class PlayerListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Action action = event.getAction();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Material material;
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* Fix for NPE on interacting with air */
|
||||
if (block == null) {
|
||||
material = Material.AIR;
|
||||
}
|
||||
else {
|
||||
material = block.getType();
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (Permissions.repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
||||
if (mcMMO.repairManager.isRepairable(inHand)) {
|
||||
mcMMO.repairManager.handleRepair(player, inHand);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
if (Permissions.salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
|
||||
if (Salvage.isSalvageable(inHand)) {
|
||||
final Location location = block.getLocation();
|
||||
Salvage.handleSalvage(player, location, inHand);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
/* ACTIVATION & ITEM CHECKS */
|
||||
if (BlockChecks.canActivateAbilities(block)) {
|
||||
if (SkillTools.abilitiesEnabled) {
|
||||
if (BlockChecks.canActivateHerbalism(block)) {
|
||||
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
||||
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
SkillTools.activationCheck(player, SkillType.AXES);
|
||||
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillTools.activationCheck(player, SkillType.MINING);
|
||||
SkillTools.activationCheck(player, SkillType.SWORDS);
|
||||
SkillTools.activationCheck(player, SkillType.UNARMED);
|
||||
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
Skills.activationCheck(player, SkillType.AXES);
|
||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
||||
Skills.activationCheck(player, SkillType.MINING);
|
||||
Skills.activationCheck(player, SkillType.SWORDS);
|
||||
Skills.activationCheck(player, SkillType.UNARMED);
|
||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
||||
ChimaeraWing.activationCheck(player);
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(inHand, player, block);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
Item.itemChecks(player);
|
||||
}
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) {
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
miningManager.detonate(event);
|
||||
if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(heldItem, player, block);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -336,24 +278,18 @@ public class PlayerListener implements Listener {
|
||||
case RIGHT_CLICK_AIR:
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
Skills.activationCheck(player, SkillType.AXES);
|
||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
Skills.activationCheck(player, SkillType.MINING);
|
||||
Skills.activationCheck(player, SkillType.SWORDS);
|
||||
Skills.activationCheck(player, SkillType.UNARMED);
|
||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
||||
if (SkillTools.abilitiesEnabled) {
|
||||
SkillTools.activationCheck(player, SkillType.AXES);
|
||||
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||
SkillTools.activationCheck(player, SkillType.MINING);
|
||||
SkillTools.activationCheck(player, SkillType.SWORDS);
|
||||
SkillTools.activationCheck(player, SkillType.UNARMED);
|
||||
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
Item.itemChecks(player);
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) {
|
||||
MiningManager miningManager = new MiningManager(player);
|
||||
miningManager.detonate(event);
|
||||
}
|
||||
ChimaeraWing.activationCheck(player);
|
||||
|
||||
break;
|
||||
|
||||
@@ -362,14 +298,14 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* CALL OF THE WILD CHECKS */
|
||||
if (player.isSneaking()) {
|
||||
Material type = inHand.getType();
|
||||
Material type = heldItem.getType();
|
||||
|
||||
if (type == Material.RAW_FISH) {
|
||||
TamingManager tamingManager = new TamingManager(player);
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.summonOcelot();
|
||||
}
|
||||
else if (type == Material.BONE) {
|
||||
TamingManager tamingManager = new TamingManager(player);
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.summonWolf();
|
||||
}
|
||||
}
|
||||
@@ -389,12 +325,9 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -406,62 +339,12 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String partyName = party.getName();
|
||||
String playerName = player.getName();
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + chatEvent.getMessage());
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (profile.getAdminChatMode()) {
|
||||
String playerName = player.getName();
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerCommandPreprocess events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String message = event.getMessage();
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
String lowerCaseCommand = command.toLowerCase();
|
||||
|
||||
if (plugin.commandIsAliased(lowerCaseCommand)) {
|
||||
//We should find a better way to avoid string replacement where the alias is equals to the command
|
||||
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setMessage(message.replace(command, plugin.getCommandAlias(lowerCaseCommand)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
* Listener for listening to our own events, only really useful for catching errors
|
||||
*/
|
||||
public class SelfListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor internal XP gain events.
|
||||
*
|
||||
|
||||
@@ -3,8 +3,13 @@ package com.gmail.nossr50.listeners;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -15,11 +20,16 @@ import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.blockstoreconversion.BlockStoreConversionMain;
|
||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||
private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||
|
||||
/**
|
||||
* Monitor StructureGrow events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onStructureGrow(StructureGrowEvent event) {
|
||||
TreeType species = event.getSpecies();
|
||||
@@ -31,46 +41,68 @@ public class WorldListener implements Listener {
|
||||
if (mcMMO.placeStore.isTrue(event.getLocation().getBlock())) {
|
||||
for (BlockState block : event.getBlocks()) {
|
||||
mcMMO.placeStore.setFalse(block.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/**
|
||||
* Monitor WorldInit events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
|
||||
if (!dataDir.exists()) {
|
||||
World world = event.getWorld();
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
|
||||
if (!dataDir.exists() || mcMMO.p == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.p == null)
|
||||
return;
|
||||
mcMMO.p.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
||||
|
||||
mcMMO.p.getLogger().info("Converting block storage for " + event.getWorld().getName() + " to a new format.");
|
||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(event.getWorld());
|
||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
|
||||
converter.run();
|
||||
converters.add(converter);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/**
|
||||
* Monitor WorldUnload events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
mcMMO.placeStore.unloadWorld(event.getWorld());
|
||||
}
|
||||
|
||||
// This gets called every 45 seconds, by default.
|
||||
// The call can and does result in excessive lag, especially on larger servers.
|
||||
//@EventHandler
|
||||
//public void onWorldSave(WorldSaveEvent event) {
|
||||
// mcMMO.placeStore.saveWorld(event.getWorld());
|
||||
//}
|
||||
|
||||
@EventHandler
|
||||
/**
|
||||
* Monitor ChunkUnload events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
|
||||
Chunk chunk = event.getChunk();
|
||||
|
||||
mcMMO.placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/**
|
||||
* Monitor ChunkLoad events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if (event.getChunk().getEntities().length > 0)
|
||||
mcMMO.placeStore.loadChunk(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
|
||||
Chunk chunk = event.getChunk();
|
||||
Entity[] entities = chunk.getEntities();
|
||||
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof LivingEntity || entity instanceof FallingBlock) {
|
||||
mcMMO.placeStore.loadChunk(chunk.getX(), chunk.getZ(), event.getWorld(), entities);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ import org.bukkit.ChatColor;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
|
||||
public class LocaleLoader {
|
||||
public final class LocaleLoader {
|
||||
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
|
||||
private static ResourceBundle RESOURCE_BUNDLE = null;
|
||||
|
||||
private LocaleLoader() {};
|
||||
|
||||
public static String getString(String key) {
|
||||
return getString(key, null);
|
||||
}
|
||||
|
||||
@@ -15,105 +15,95 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import com.gmail.nossr50.commands.general.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.general.AddxpCommand;
|
||||
import com.gmail.nossr50.commands.general.InspectCommand;
|
||||
import com.gmail.nossr50.commands.general.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoupdateCommand;
|
||||
import com.gmail.nossr50.commands.general.SkillResetCommand;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.commands.mc.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.mc.MccCommand;
|
||||
import com.gmail.nossr50.commands.mc.McgodCommand;
|
||||
import com.gmail.nossr50.commands.mc.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.mc.McpurgeCommand;
|
||||
import com.gmail.nossr50.commands.mc.McrankCommand;
|
||||
import com.gmail.nossr50.commands.mc.McrefreshCommand;
|
||||
import com.gmail.nossr50.commands.mc.McremoveCommand;
|
||||
import com.gmail.nossr50.commands.mc.MctopCommand;
|
||||
import com.gmail.nossr50.commands.party.ACommand;
|
||||
import com.gmail.nossr50.commands.party.AcceptCommand;
|
||||
import com.gmail.nossr50.commands.party.InviteCommand;
|
||||
import com.gmail.nossr50.commands.party.PCommand;
|
||||
import com.gmail.nossr50.commands.party.PartyCommand;
|
||||
import com.gmail.nossr50.commands.party.PtpCommand;
|
||||
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.commands.skills.ArcheryCommand;
|
||||
import com.gmail.nossr50.commands.skills.AxesCommand;
|
||||
import com.gmail.nossr50.commands.skills.ExcavationCommand;
|
||||
import com.gmail.nossr50.commands.skills.FishingCommand;
|
||||
import com.gmail.nossr50.commands.skills.HerbalismCommand;
|
||||
import com.gmail.nossr50.commands.skills.MiningCommand;
|
||||
import com.gmail.nossr50.commands.skills.RepairCommand;
|
||||
import com.gmail.nossr50.commands.skills.SwordsCommand;
|
||||
import com.gmail.nossr50.commands.skills.TamingCommand;
|
||||
import com.gmail.nossr50.commands.skills.UnarmedCommand;
|
||||
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
|
||||
import com.gmail.nossr50.commands.spout.MchudCommand;
|
||||
import com.gmail.nossr50.commands.spout.XplockCommand;
|
||||
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
import com.gmail.nossr50.chat.commands.ACommand;
|
||||
import com.gmail.nossr50.chat.commands.PCommand;
|
||||
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
||||
import com.gmail.nossr50.commands.admin.AddxpCommand;
|
||||
import com.gmail.nossr50.commands.admin.McgodCommand;
|
||||
import com.gmail.nossr50.commands.admin.McrefreshCommand;
|
||||
import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.admin.SkillResetCommand;
|
||||
import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.player.MccCommand;
|
||||
import com.gmail.nossr50.commands.player.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.player.McrankCommand;
|
||||
import com.gmail.nossr50.commands.player.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.player.MctopCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.config.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.commands.McpurgeCommand;
|
||||
import com.gmail.nossr50.database.commands.McremoveCommand;
|
||||
import com.gmail.nossr50.database.commands.MmoupdateCommand;
|
||||
import com.gmail.nossr50.database.runnables.UserPurgeTask;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.HardcoreListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.party.commands.PartyCommand;
|
||||
import com.gmail.nossr50.party.commands.PtpCommand;
|
||||
import com.gmail.nossr50.runnables.MobStoreCleaner;
|
||||
import com.gmail.nossr50.runnables.SaveTimer;
|
||||
import com.gmail.nossr50.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.runnables.SpoutStart;
|
||||
import com.gmail.nossr50.runnables.UserPurgeTask;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.SpoutTools;
|
||||
import com.gmail.nossr50.spout.commands.MchudCommand;
|
||||
import com.gmail.nossr50.spout.commands.XplockCommand;
|
||||
import com.gmail.nossr50.util.Anniversary;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Metrics.Graph;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
private final PlayerListener playerListener = new PlayerListener(this);
|
||||
private final BlockListener blockListener = new BlockListener(this);
|
||||
private final EntityListener entityListener = new EntityListener(this);
|
||||
private final InventoryListener inventoryListener = new InventoryListener(this);
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
||||
|
||||
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
||||
|
||||
private static Database database;
|
||||
public static mcMMO p;
|
||||
|
||||
public static ChunkManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
|
||||
/* Jar Stuff */
|
||||
// Jar Stuff
|
||||
public static File mcmmo;
|
||||
|
||||
//File Paths
|
||||
// File Paths
|
||||
private static String mainDirectory;
|
||||
private static String flatFileDirectory;
|
||||
private static String usersFile;
|
||||
private static String modDirectory;
|
||||
|
||||
//Spout Check
|
||||
public static boolean spoutEnabled;
|
||||
// Spout Check
|
||||
public static boolean spoutEnabled = false;
|
||||
|
||||
// XP Event Check
|
||||
private boolean xpEventEnabled = false;
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
@@ -123,11 +113,23 @@ public class mcMMO extends JavaPlugin {
|
||||
p = this;
|
||||
setupFilePaths();
|
||||
|
||||
//Force the loading of config files
|
||||
// Check for Spout
|
||||
if (getServer().getPluginManager().isPluginEnabled("Spout")) {
|
||||
spoutEnabled = true;
|
||||
|
||||
SpoutConfig.getInstance();
|
||||
SpoutTools.setupSpoutConfigs();
|
||||
SpoutTools.registerCustomEvent();
|
||||
SpoutTools.preCacheFiles();
|
||||
SpoutTools.reloadSpoutPlayers(); // Handle spout players after a /reload
|
||||
}
|
||||
|
||||
// Force the loading of config files
|
||||
Config configInstance = Config.getInstance();
|
||||
TreasuresConfig.getInstance();
|
||||
HiddenConfig.getInstance();
|
||||
AdvancedConfig.getInstance();
|
||||
PartyManager.loadParties();
|
||||
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
@@ -143,13 +145,13 @@ public class mcMMO extends JavaPlugin {
|
||||
CustomBlocksConfig.getInstance();
|
||||
}
|
||||
|
||||
//Load repair configs, make manager, and register them at this time
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||
repairManager.registerRepairables(repairables);
|
||||
|
||||
//Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
||||
getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!");
|
||||
}
|
||||
@@ -160,10 +162,11 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
//Register events
|
||||
// Register events
|
||||
pluginManager.registerEvents(playerListener, this);
|
||||
pluginManager.registerEvents(blockListener, this);
|
||||
pluginManager.registerEvents(entityListener, this);
|
||||
pluginManager.registerEvents(inventoryListener, this);
|
||||
pluginManager.registerEvents(worldListener, this);
|
||||
|
||||
if (configInstance.getHardcoreEnabled()) {
|
||||
@@ -172,36 +175,36 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
|
||||
//Setup the leader boards
|
||||
// Setup the leader boards
|
||||
if (configInstance.getUseMySQL()) {
|
||||
database = new Database(this);
|
||||
database.createStructure();
|
||||
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
||||
Database.checkConnected();
|
||||
Database.createStructure();
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards();
|
||||
}
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //In case of reload add all users back into PlayerProfile
|
||||
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
||||
}
|
||||
|
||||
getLogger().info("Version " + pdfFile.getVersion() + " is enabled!");
|
||||
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
|
||||
//Schedule Spout Activation 1 second after start-up
|
||||
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
||||
//Periodic save timer (Saves every 10 minutes by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
||||
//Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
||||
//Bleed timer (Runs every two seconds)
|
||||
// Periodic save timer (Saves every 10 minutes by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), 0, configInstance.getSaveInterval() * 1200);
|
||||
// Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 0, 20);
|
||||
// Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
||||
|
||||
//Old & Powerless User remover
|
||||
// Old & Powerless User remover
|
||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||
|
||||
if (purgeInterval == 0) {
|
||||
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); //Start 2 seconds after startup.
|
||||
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
|
||||
}
|
||||
else if (purgeInterval > 0) {
|
||||
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, purgeInterval * 60L * 60L * 20L);
|
||||
@@ -212,7 +215,6 @@ public class mcMMO extends JavaPlugin {
|
||||
if (configInstance.getStatsTrackingEnabled()) {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
Graph graph = metrics.createGraph("Percentage of servers using timings");
|
||||
|
||||
if (pluginManager.useTimings()) {
|
||||
@@ -239,15 +241,10 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Get our ChunkletManager
|
||||
placeStore = ChunkManagerFactory.getChunkManager();
|
||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||
|
||||
// Automatically starts and stores itself
|
||||
new MobStoreCleaner();
|
||||
|
||||
// Create Anniversary files
|
||||
Anniversary anniversary = new Anniversary();
|
||||
anniversary.createAnniversaryFile();
|
||||
new MobStoreCleaner(); // Automatically starts and stores itself
|
||||
Anniversary.createAnniversaryFile(); // Create Anniversary files
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,22 +300,21 @@ public class mcMMO extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Users.saveAll(); //Make sure to save player information if the server shuts down
|
||||
PartyManager.getInstance().saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
placeStore.saveAll(); //Save our metadata
|
||||
placeStore.cleanUp(); //Cleanup empty metadata stores
|
||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
|
||||
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMObackup();
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
Anniversary anniversary = new Anniversary();
|
||||
anniversary.saveAnniversaryFiles();
|
||||
|
||||
Anniversary.saveAnniversaryFiles();
|
||||
getLogger().info("Was disabled."); //How informative!
|
||||
}
|
||||
|
||||
@@ -326,158 +322,41 @@ public class mcMMO extends JavaPlugin {
|
||||
* Register the commands.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
|
||||
//Skills commands
|
||||
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
|
||||
aliasMap.put(LocaleLoader.getString("Archery.SkillName").toLowerCase(), "archery");
|
||||
aliasMap.put(LocaleLoader.getString("Axes.SkillName").toLowerCase(), "axes");
|
||||
aliasMap.put(LocaleLoader.getString("Excavation.SkillName").toLowerCase(), "excavation");
|
||||
aliasMap.put(LocaleLoader.getString("Fishing.SkillName").toLowerCase(), "fishing");
|
||||
aliasMap.put(LocaleLoader.getString("Herbalism.SkillName").toLowerCase(), "herbalism");
|
||||
aliasMap.put(LocaleLoader.getString("Mining.SkillName").toLowerCase(), "mining");
|
||||
aliasMap.put(LocaleLoader.getString("Repair.SkillName").toLowerCase(), "repair");
|
||||
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
||||
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
||||
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
||||
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").toLowerCase(), "woodcutting");
|
||||
|
||||
//Register commands
|
||||
//Skills commands
|
||||
getCommand("acrobatics").setExecutor(new AcrobaticsCommand());
|
||||
getCommand("archery").setExecutor(new ArcheryCommand());
|
||||
getCommand("axes").setExecutor(new AxesCommand());
|
||||
getCommand("excavation").setExecutor(new ExcavationCommand());
|
||||
getCommand("fishing").setExecutor(new FishingCommand());
|
||||
getCommand("herbalism").setExecutor(new HerbalismCommand());
|
||||
getCommand("mining").setExecutor(new MiningCommand());
|
||||
getCommand("repair").setExecutor(new RepairCommand());
|
||||
getCommand("swords").setExecutor(new SwordsCommand());
|
||||
getCommand("taming").setExecutor(new TamingCommand());
|
||||
getCommand("unarmed").setExecutor(new UnarmedCommand());
|
||||
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
|
||||
|
||||
CommandRegistrationHelper.registerSkillCommands();
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
//mc* commands
|
||||
if (configInstance.getCommandMCPurgeEnabled()) {
|
||||
getCommand("mcpurge").setExecutor(new McpurgeCommand());
|
||||
}
|
||||
if (configInstance.getCommandMCRemoveEnabled()) {
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand(this));
|
||||
}
|
||||
// mc* commands
|
||||
getCommand("mcpurge").setExecutor(new McpurgeCommand());
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand());
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand());
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
getCommand("mcrank").setExecutor(new McrankCommand());
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
|
||||
if (configInstance.getCommandMCAbilityEnabled()) {
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
}
|
||||
// Party commands
|
||||
getCommand("a").setExecutor(new ACommand());
|
||||
getCommand("party").setExecutor(new PartyCommand());
|
||||
getCommand("p").setExecutor(new PCommand(this));
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
|
||||
if (configInstance.getCommandMCCEnabled()) {
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCGodEnabled()) {
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandmcMMOEnabled()) {
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCRefreshEnabled()) {
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCTopEnabled()) {
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
}
|
||||
|
||||
if(configInstance.getCommandMCRankEnabled()) {
|
||||
getCommand("mcrank").setExecutor(new McrankCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCStatsEnabled()) {
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandSkillResetEnabled()) {
|
||||
getCommand("skillreset").setExecutor(new SkillResetCommand());
|
||||
}
|
||||
|
||||
//Party commands
|
||||
if (configInstance.getCommandAcceptEnabled()) {
|
||||
getCommand("accept").setExecutor(new AcceptCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandAdminChatAEnabled()) {
|
||||
getCommand("a").setExecutor(new ACommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandInviteEnabled()) {
|
||||
getCommand("invite").setExecutor(new InviteCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandPartyEnabled()) {
|
||||
getCommand("party").setExecutor(new PartyCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandPartyChatPEnabled()) {
|
||||
getCommand("p").setExecutor(new PCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandPTPEnabled()) {
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
}
|
||||
|
||||
//Other commands
|
||||
if (configInstance.getCommandAddXPEnabled()) {
|
||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandAddLevelsEnabled()) {
|
||||
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMmoeditEnabled()) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandInspectEnabled()) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandXPRateEnabled()) {
|
||||
getCommand("xprate").setExecutor(new XprateCommand(this));
|
||||
}
|
||||
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
|
||||
|
||||
//Spout commands
|
||||
if (configInstance.getCommandXPLockEnabled()) {
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
}
|
||||
// Other commands
|
||||
getCommand("addxp").setExecutor(new AddxpCommand());
|
||||
CommandRegistrationHelper.registerAddlevelsCommand();
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
getCommand("inspect").setExecutor(new InspectCommand());
|
||||
getCommand("xprate").setExecutor(new XprateCommand());
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||
getCommand("skillreset").setExecutor(new SkillResetCommand());
|
||||
|
||||
// Spout commands
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
getCommand("mchud").setExecutor(new MchudCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the alias map contains the given key.
|
||||
*
|
||||
* @param command The command to check
|
||||
* @return true if the command is in the map, false otherwise
|
||||
*/
|
||||
public boolean commandIsAliased(String command) {
|
||||
return aliasMap.containsKey(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alias of a given command.
|
||||
*
|
||||
* @param command The command to retrieve the alias of
|
||||
* @return the alias of the command
|
||||
*/
|
||||
public String getCommandAlias(String command) {
|
||||
return aliasMap.get(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of values to the TNT tracker.
|
||||
*
|
||||
@@ -517,6 +396,22 @@ public class mcMMO extends JavaPlugin {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public void addToOpenFurnaceTracker(Block furnace, String playerName) {
|
||||
furnaceTracker.put(furnace, playerName);
|
||||
}
|
||||
|
||||
public boolean furnaceIsTracked(Block furnace) {
|
||||
return furnaceTracker.containsKey(furnace);
|
||||
}
|
||||
|
||||
public void removeFromFurnaceTracker(Block furnace) {
|
||||
furnaceTracker.remove(furnace);
|
||||
}
|
||||
|
||||
public Player getFurnacePlayer(Block furnace) {
|
||||
return getServer().getPlayer(furnaceTracker.get(furnace));
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
@@ -525,7 +420,7 @@ public class mcMMO extends JavaPlugin {
|
||||
return flatFileDirectory;
|
||||
}
|
||||
|
||||
public static String getUsersFile() {
|
||||
public static String getUsersFilePath() {
|
||||
return usersFile;
|
||||
}
|
||||
|
||||
@@ -533,8 +428,12 @@ public class mcMMO extends JavaPlugin {
|
||||
return modDirectory;
|
||||
}
|
||||
|
||||
public static Database getPlayerDatabase() {
|
||||
return database;
|
||||
public boolean isXPEventEnabled() {
|
||||
return xpEventEnabled;
|
||||
}
|
||||
|
||||
public void setXPEventEnabled(boolean enabled) {
|
||||
this.xpEventEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
package com.gmail.nossr50.util;
|
||||
package com.gmail.nossr50.mods;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomItem;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
|
||||
public class ModChecks {
|
||||
public final class ModChecks {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||
|
||||
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
||||
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
||||
private ModChecks() {}
|
||||
|
||||
/**
|
||||
* Get the custom armor associated with an item.
|
||||
@@ -29,7 +27,7 @@ public class ModChecks {
|
||||
* @return the armor if it exists, null otherwise
|
||||
*/
|
||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
||||
return armorInstance.customArmor.get(item.getTypeId());
|
||||
return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +37,7 @@ public class ModChecks {
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
return toolInstance.customTools.get(item.getTypeId());
|
||||
return CustomToolsConfig.getInstance().customTools.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,11 +49,11 @@ public class ModChecks {
|
||||
public static CustomBlock getCustomBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (!blocksInstance.customItems.contains(item)) {
|
||||
if (!CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CustomBlock b : blocksInstance.customBlocks) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return b;
|
||||
}
|
||||
@@ -73,8 +71,8 @@ public class ModChecks {
|
||||
public static boolean isCustomMiningBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (customBlocksEnabled && blocksInstance.customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock b : blocksInstance.customBlocks) {
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
@@ -93,8 +91,8 @@ public class ModChecks {
|
||||
public static boolean isCustomLeafBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (blocksInstance.customLeaves.contains(item)) {
|
||||
for (CustomBlock b : blocksInstance.customBlocks) {
|
||||
if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
@@ -113,8 +111,8 @@ public class ModChecks {
|
||||
public static boolean isCustomLogBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (blocksInstance.customLogs.contains(item)) {
|
||||
for (CustomBlock b : blocksInstance.customBlocks) {
|
||||
if (CustomBlocksConfig.getInstance().customLogs.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
@@ -133,8 +131,8 @@ public class ModChecks {
|
||||
public static boolean isCustomOreBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (blocksInstance.customOres.contains(item)) {
|
||||
for (CustomBlock b : blocksInstance.customBlocks) {
|
||||
if (CustomBlocksConfig.getInstance().customOres.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
@@ -147,11 +145,11 @@ public class ModChecks {
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @param item Item to check
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomTool(ItemStack item) {
|
||||
if (customToolsEnabled && toolInstance.customTools.containsKey(item.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customTools.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -161,11 +159,11 @@ public class ModChecks {
|
||||
/**
|
||||
* Checks to see if an item is custom armor.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @param item Item to check
|
||||
* @return true if the item is custom armor, false otherwise
|
||||
*/
|
||||
public static boolean isCustomArmor(ItemStack item) {
|
||||
if (customArmorEnabled && armorInstance.customArmor.containsKey(item.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -8,7 +8,7 @@ import java.util.Set;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||
|
||||
public class CustomBlocksConfig extends ConfigLoader {
|
||||
private static CustomBlocksConfig instance;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -8,7 +8,7 @@ import java.util.Set;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
package com.gmail.nossr50.mods.datatypes;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
package com.gmail.nossr50.mods.datatypes;
|
||||
|
||||
public class CustomItem {
|
||||
protected int itemID;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
package com.gmail.nossr50.mods.datatypes;
|
||||
|
||||
public class CustomTool extends CustomItem {
|
||||
private double xpMultiplier;
|
||||
@@ -13,6 +13,7 @@ public class Party {
|
||||
private String name;
|
||||
private String password;
|
||||
private boolean locked;
|
||||
private ShareHandler.XpShareMode xpShareMode;
|
||||
|
||||
public List<String> getMembers() {
|
||||
return members;
|
||||
@@ -62,4 +63,12 @@ public class Party {
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public void setXpShareMode(ShareHandler.XpShareMode xpShareMode) {
|
||||
this.xpShareMode = xpShareMode;
|
||||
}
|
||||
|
||||
public ShareHandler.XpShareMode getXpShareMode() {
|
||||
return xpShareMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,28 +10,14 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyManager {
|
||||
private static String partiesFilePath;
|
||||
public final class PartyManager {
|
||||
private static String partiesFilePath = mcMMO.p.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
|
||||
private static List<Party> parties = new ArrayList<Party>();
|
||||
private static mcMMO plugin;
|
||||
private static PartyManager instance;
|
||||
|
||||
private PartyManager() {
|
||||
plugin = mcMMO.p;
|
||||
partiesFilePath = plugin.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
|
||||
|
||||
loadParties();
|
||||
}
|
||||
|
||||
public static PartyManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PartyManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
private PartyManager() {}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
@@ -40,7 +26,7 @@ public class PartyManager {
|
||||
* @param secondPlayer The second player
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
||||
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
||||
|
||||
@@ -58,15 +44,34 @@ public class PartyManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the near party members.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param range The distance
|
||||
* @return the near party members
|
||||
*/
|
||||
public static List<Player> getNearMembers(Player player, Party party, double range) {
|
||||
List<Player> nearMembers = new ArrayList<Player>();
|
||||
if (party != null) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (player != member && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
nearMembers.add(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nearMembers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when a player joins
|
||||
*
|
||||
* @param playerName The name of the player that joins
|
||||
* @param party The concerned party
|
||||
*/
|
||||
private void informPartyMembersJoin(String playerName, Party party) {
|
||||
private static void informPartyMembersJoin(String playerName, Party party) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
if (!member.getName().equals(playerName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
|
||||
}
|
||||
}
|
||||
@@ -78,9 +83,9 @@ public class PartyManager {
|
||||
* @param playerName The name of the player that quits
|
||||
* @param party The concerned party
|
||||
*/
|
||||
private void informPartyMembersQuit(String playerName, Party party) {
|
||||
private static void informPartyMembersQuit(String playerName, Party party) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
if (!member.getName().equals(playerName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
|
||||
}
|
||||
}
|
||||
@@ -92,7 +97,7 @@ public class PartyManager {
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public List<String> getAllMembers(Player player) {
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
Party party = Users.getProfile(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
@@ -108,7 +113,7 @@ public class PartyManager {
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public List<Player> getOnlineMembers(String partyName) {
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
Party party = getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
@@ -124,7 +129,7 @@ public class PartyManager {
|
||||
* @param player The player to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public List<Player> getOnlineMembers(Player player) {
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return getOnlineMembers(player.getName());
|
||||
}
|
||||
|
||||
@@ -134,7 +139,7 @@ public class PartyManager {
|
||||
* @param partyName The party name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getParty(String partyName) {
|
||||
public static Party getParty(String partyName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getName().equals(partyName)) {
|
||||
return party;
|
||||
@@ -150,13 +155,12 @@ public class PartyManager {
|
||||
* @param playerName The member name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getPlayerParty(String playerName) {
|
||||
public static Party getPlayerParty(String playerName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getMembers().contains(playerName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -165,7 +169,7 @@ public class PartyManager {
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public List<Party> getParties() {
|
||||
public static List<Party> getParties() {
|
||||
return parties;
|
||||
}
|
||||
|
||||
@@ -175,7 +179,7 @@ public class PartyManager {
|
||||
* @param playerName The name of the player to remove
|
||||
* @param party The party
|
||||
*/
|
||||
public void removeFromParty(String playerName, Party party) {
|
||||
public static void removeFromParty(String playerName, Party party) {
|
||||
List<String> members = party.getMembers();
|
||||
|
||||
members.remove(playerName);
|
||||
@@ -184,8 +188,10 @@ public class PartyManager {
|
||||
parties.remove(party);
|
||||
}
|
||||
else {
|
||||
//If the leaving player was the party leader, appoint a new leader from the party members
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
party.setLocked(false);
|
||||
String newLeader = members.get(0);
|
||||
party.setLeader(newLeader);
|
||||
}
|
||||
|
||||
informPartyMembersQuit(playerName, party);
|
||||
@@ -198,6 +204,65 @@ public class PartyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param party The party to remove
|
||||
*/
|
||||
public static void disbandParty(Party party) {
|
||||
List<String> members = party.getMembers();
|
||||
|
||||
for (String member : party.getMembers()) {
|
||||
PlayerProfile playerProfile = Users.getProfile(member);
|
||||
|
||||
if (playerProfile != null) {
|
||||
playerProfile.removeParty();
|
||||
}
|
||||
}
|
||||
|
||||
members.clear();
|
||||
if (members.isEmpty()) {
|
||||
parties.remove(party);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new party
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password the password for this party, null if there was no password
|
||||
*/
|
||||
public static void createParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||
partyName = partyName.replace(".", "");
|
||||
Party party = getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
|
||||
party.setName(partyName);
|
||||
party.setLeader(playerName);
|
||||
party.setXpShareMode(ShareHandler.XpShareMode.NONE);
|
||||
party.setLocked(true);//Parties are now invite-only by default, can be set to open with /party unlock
|
||||
|
||||
if (password != null) {
|
||||
party.setPassword(password);
|
||||
party.setLocked(true);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.Set", new Object[] {password}));
|
||||
}
|
||||
parties.add(party);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists"));
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", new Object[] {party.getName()}));
|
||||
addToParty(player.getName(), playerProfile, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
*
|
||||
@@ -206,7 +271,7 @@ public class PartyManager {
|
||||
* @param partyName The party to add the player to
|
||||
* @param password the password for this party, null if there was no password
|
||||
*/
|
||||
public void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||
public static void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||
partyName = partyName.replace(".", "");
|
||||
Party party = getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
@@ -236,19 +301,19 @@ public class PartyManager {
|
||||
* Check if a player can join a party
|
||||
*
|
||||
* @param player The player trying to join a party
|
||||
* @param playerProfile The profile of the player
|
||||
* @param party The party
|
||||
* @param password The password provided by the player
|
||||
* @return true if the player can join the party
|
||||
*/
|
||||
public boolean checkJoinability(Player player, Party party, String password) {
|
||||
public static boolean checkJoinability(Player player, Party party, String password) {
|
||||
//Don't care about passwords if it isn't locked
|
||||
if (party.isLocked()) {
|
||||
String partyPassword = party.getPassword();
|
||||
|
||||
if (partyPassword != null) {
|
||||
if (password == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.None"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.3", new Object[] {"party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"}));
|
||||
return false;
|
||||
}
|
||||
else if (!password.equals(partyPassword)) {
|
||||
@@ -271,7 +336,7 @@ public class PartyManager {
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player
|
||||
*/
|
||||
public void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
||||
public static void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
||||
Party invite = playerProfile.getInvite();
|
||||
|
||||
if (!parties.contains(invite)) {
|
||||
@@ -290,7 +355,7 @@ public class PartyManager {
|
||||
* @param playerProfile The profile of the player
|
||||
* @param party The party
|
||||
*/
|
||||
public void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
||||
public static void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
||||
informPartyMembersJoin(playerName, party);
|
||||
playerProfile.setParty(party);
|
||||
party.getMembers().add(playerName);
|
||||
@@ -302,7 +367,7 @@ public class PartyManager {
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public String getPartyLeader(String partyName) {
|
||||
public static String getPartyLeader(String partyName) {
|
||||
Party party = getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
@@ -318,14 +383,14 @@ public class PartyManager {
|
||||
* @param playerName The name of the player to set as leader
|
||||
* @param party The party
|
||||
*/
|
||||
public void setPartyLeader(String playerName, Party party) {
|
||||
public static void setPartyLeader(String playerName, Party party) {
|
||||
String leaderName = party.getLeader();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
|
||||
}
|
||||
else if (member.equals(leaderName)) {
|
||||
else if (member.getName().equals(leaderName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
|
||||
}
|
||||
else {
|
||||
@@ -343,7 +408,7 @@ public class PartyManager {
|
||||
* @param playerProfile The profile of the given player
|
||||
* @return true if the player can invite
|
||||
*/
|
||||
public boolean canInvite(Player player, PlayerProfile playerProfile) {
|
||||
public static boolean canInvite(Player player, PlayerProfile playerProfile) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
|
||||
@@ -359,7 +424,7 @@ public class PartyManager {
|
||||
* @param partyName The party name to check
|
||||
* @return true if this is a valid party, false otherwise
|
||||
*/
|
||||
public boolean isParty(String partyName) {
|
||||
public static boolean isParty(String partyName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getName().equals(partyName)) {
|
||||
return true;
|
||||
@@ -372,7 +437,7 @@ public class PartyManager {
|
||||
/**
|
||||
* Load party file.
|
||||
*/
|
||||
private void loadParties() {
|
||||
public static void loadParties() {
|
||||
File file = new File(partiesFilePath);
|
||||
|
||||
if (!file.exists()) {
|
||||
@@ -394,6 +459,7 @@ public class PartyManager {
|
||||
party.setLeader(partiesFile.getString(partyName + ".Leader"));
|
||||
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
party.setXpShareMode(ShareHandler.XpShareMode.getFromString(partiesFile.getString(partyName + ".ExpShareMode")));
|
||||
party.getMembers().addAll(partiesFile.getStringList(partyName + ".Members"));
|
||||
|
||||
parties.add(party);
|
||||
@@ -403,7 +469,7 @@ public class PartyManager {
|
||||
/**
|
||||
* Save party file.
|
||||
*/
|
||||
public void saveParties() {
|
||||
public static void saveParties() {
|
||||
File file = new File(partiesFilePath);
|
||||
|
||||
if (file.exists()) {
|
||||
@@ -418,6 +484,7 @@ public class PartyManager {
|
||||
partiesFile.set(partyName + ".Leader", party.getLeader());
|
||||
partiesFile.set(partyName + ".Password", party.getPassword());
|
||||
partiesFile.set(partyName + ".Locked", party.isLocked());
|
||||
partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString());
|
||||
partiesFile.set(partyName + ".Members", party.getMembers());
|
||||
|
||||
try {
|
||||
|
||||
73
src/main/java/com/gmail/nossr50/party/ShareHandler.java
Normal file
73
src/main/java/com/gmail/nossr50/party/ShareHandler.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class ShareHandler {
|
||||
public enum XpShareMode {
|
||||
NONE,
|
||||
EQUAL;
|
||||
|
||||
public static XpShareMode getFromString(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException exception) {
|
||||
return NONE;
|
||||
}
|
||||
catch (NullPointerException exception) {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static boolean running; // Used to prevent permanent sharing, McMMOPlayer.addXp() uses it
|
||||
|
||||
private ShareHandler() {}
|
||||
|
||||
/**
|
||||
* Distribute Xp amongst party members.
|
||||
*
|
||||
* @param xp Xp without party sharing
|
||||
* @param mcMMOPlayer Player initiating the Xp gain
|
||||
* @param skillType Skill being used
|
||||
* @return True is the xp has been shared
|
||||
*/
|
||||
public static boolean handleEqualXpShare(int xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||
running = true;
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getXpShareMode() == XpShareMode.EQUAL) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
running = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
double partySize = nearMembers.size() + 1;
|
||||
double splitXp = xp / partySize * Config.getInstance().getPartyShareBonus();
|
||||
int roundedXp = (int) Math.ceil(splitXp);
|
||||
|
||||
for (Player member : nearMembers) {
|
||||
Users.getPlayer(member).addXp(skillType, roundedXp);
|
||||
}
|
||||
|
||||
mcMMOPlayer.addXp(skillType, roundedXp);
|
||||
}
|
||||
|
||||
running = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
}
|
||||
695
src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java
Normal file
695
src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java
Normal file
@@ -0,0 +1,695 @@
|
||||
package com.gmail.nossr50.party.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
private Player player;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.player = (Player) sender;
|
||||
this.playerProfile = Users.getProfile(player);
|
||||
|
||||
if (args.length < 1 || args[0].equalsIgnoreCase("info")) {
|
||||
return party();
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("join")) {
|
||||
return join(args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("accept")) {
|
||||
return accept();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("create")) {
|
||||
return create(args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) {
|
||||
return printHelp();
|
||||
}
|
||||
|
||||
if (playerProfile.inParty()) {
|
||||
if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave")) {
|
||||
return quit();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("expshare")) {
|
||||
return shareExp(args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("itemshare")) {
|
||||
return shareItem();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("invite")) {
|
||||
return invite(args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("kick")) {
|
||||
return kick(args[1]);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("disband")) {
|
||||
return disband();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("owner")) {
|
||||
return changeOwner(args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lock")) {
|
||||
return lock();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
return unlock();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("password")) {
|
||||
return changePassword(args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("rename")) {
|
||||
return rename(args);
|
||||
}
|
||||
else {
|
||||
return printUsage();
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return printUsage();
|
||||
}
|
||||
|
||||
private boolean printUsage() {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean party() {
|
||||
if (playerProfile.inParty()) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
Server server = mcMMO.p.getServer();
|
||||
String leader = party.getLeader();
|
||||
StringBuilder tempList = new StringBuilder();
|
||||
|
||||
int membersNear = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()).size();
|
||||
int membersOnline = party.getOnlineMembers().size() - 1;
|
||||
|
||||
String ItemShare = "";
|
||||
String ExpShare = "";
|
||||
String Split = "";
|
||||
String itemShareMode = "NONE";
|
||||
|
||||
for (String otherPlayerName : party.getMembers()) {
|
||||
if (leader.equals(otherPlayerName)) {
|
||||
tempList.append(ChatColor.GOLD);
|
||||
}
|
||||
else if (server.getPlayer(otherPlayerName) != null) {
|
||||
tempList.append(ChatColor.WHITE);
|
||||
}
|
||||
else {
|
||||
tempList.append(ChatColor.GRAY);
|
||||
}
|
||||
tempList.append(otherPlayerName).append(" ");
|
||||
}
|
||||
|
||||
String status = LocaleLoader.getString("Party.Status.Locked");
|
||||
if (!party.isLocked()) {
|
||||
status = LocaleLoader.getString("Party.Status.Unlocked");
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", new Object[] {party.getName(), status}));
|
||||
|
||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||
|
||||
if (xpShareEnabled) {
|
||||
ExpShare = LocaleLoader.getString("Commands.Party.ExpShare", new Object[] { party.getXpShareMode().toString() });
|
||||
}
|
||||
|
||||
if (itemShareEnabled) {
|
||||
ItemShare = LocaleLoader.getString("Commands.Party.ItemShare", new Object[] { itemShareMode });
|
||||
}
|
||||
|
||||
if (xpShareEnabled && itemShareEnabled) {
|
||||
Split = ChatColor.DARK_GRAY + " || ";
|
||||
}
|
||||
|
||||
if (xpShareEnabled || itemShareEnabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + ExpShare + Split + ItemShare);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", new Object[] { membersNear, membersOnline }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
|
||||
}
|
||||
else {
|
||||
return printUsage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean join(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.join")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMO.p.getServer().getPlayer(args[1]);
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOnline", new Object[] {args[1]}));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Users.getProfile(target).inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", new Object[] {args[1]}));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.equals(target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (party != null && party.equals(Users.getProfile(target).getParty())) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String password = null;
|
||||
|
||||
if (args.length > 2) {
|
||||
password = args[2];
|
||||
}
|
||||
|
||||
String partyTarget = PartyManager.getPlayerParty(target.getName()).getName();
|
||||
Party newParty = PartyManager.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !PartyManager.checkJoinability(player, newParty, null)) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), partyTarget, EventReason.CHANGED_PARTIES);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(playerName, party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyTarget, EventReason.JOINED_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PartyManager.joinParty(player, playerProfile, partyTarget, password);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean accept() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.accept")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerProfile.hasPartyInvite()) {
|
||||
if (playerProfile.inParty()) {
|
||||
Party party = playerProfile.getParty();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(player.getName(), party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PartyManager.joinInvitedParty(player, playerProfile);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean create(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.create")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyname = args[1];
|
||||
String password = null;
|
||||
|
||||
if (args.length > 2) {
|
||||
password = args[2];
|
||||
}
|
||||
|
||||
Party newParty = PartyManager.getParty(partyname);
|
||||
// Check to see if the party exists, and if it does cancel creating a new party
|
||||
if (newParty != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {partyname}));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerProfile.inParty()) {
|
||||
String oldPartyName = party.getName();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, partyname, EventReason.CHANGED_PARTIES);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(playerName, party);
|
||||
PartyManager.createParty(player, playerProfile, partyname, password);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyname, EventReason.JOINED_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.createParty(player, playerProfile, partyname, password);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean quit() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.quit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
PartyManager.removeFromParty(playerName, party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean shareExp(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.expshare")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "expshare", "[sharemode]"}));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("false")) {
|
||||
party.setXpShareMode(ShareHandler.XpShareMode.NONE);
|
||||
|
||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||
onlineMembers.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", new Object[] {LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode.NoShare")}));
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
||||
party.setXpShareMode(ShareHandler.XpShareMode.EQUAL);
|
||||
|
||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||
onlineMembers.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", new Object[] {LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode.Equal")}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean shareItem() {
|
||||
return (!CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.itemshare"));
|
||||
}
|
||||
|
||||
private boolean printHelp() {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.4"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.5"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.6"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.8"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean invite(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.invite")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!playerProfile.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMO.p.getServer().getPlayer(args[1]);
|
||||
|
||||
if (target != null) {
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.InSameParty"));
|
||||
return true;
|
||||
}
|
||||
if (PartyManager.canInvite(player, playerProfile)) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
Users.getProfile(target).setInvite(party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"}));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick a party member
|
||||
*/
|
||||
private boolean kick(String targetName) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.kick")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(targetName)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {targetName}));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMO.p.getServer().getOfflinePlayer(targetName).getPlayer();
|
||||
|
||||
if (target != null) {
|
||||
String partyName = party.getName();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] {partyName}));
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(targetName, party);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband the current party, kicks out all party members.
|
||||
*/
|
||||
private boolean disband() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.disband")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(party);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the owner of the current party
|
||||
*/
|
||||
private boolean changeOwner(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.owner")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"}));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.setPartyLeader(args[1], party);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the current party
|
||||
*/
|
||||
private boolean lock() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.lock")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
|
||||
}
|
||||
else {
|
||||
party.setLocked(true);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the current party
|
||||
*/
|
||||
private boolean unlock() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.unlock")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
||||
}
|
||||
else {
|
||||
party.setLocked(false);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean changePassword(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.password")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (!party.getLeader().equals(playerName)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
party.setLocked(true);
|
||||
party.setPassword(null);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
|
||||
return true;
|
||||
}
|
||||
|
||||
party.setLocked(true);
|
||||
party.setPassword(args[1]);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.Set", new Object[] {args[1]}));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the current party
|
||||
*/
|
||||
private boolean rename(String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.rename")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
String leader = party.getLeader();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"}));
|
||||
return true;
|
||||
}
|
||||
|
||||
String newPartyName = args[1];
|
||||
|
||||
// This is to prevent party leaders from spamming other players with the rename message
|
||||
if (!party.getName().equals(newPartyName)) {
|
||||
Party newParty = PartyManager.getParty(newPartyName);
|
||||
|
||||
// Check to see if the party exists, and if it does cancel renaming the party
|
||||
if (newParty != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {newPartyName}));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), newPartyName, EventReason.CHANGED_PARTIES);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!onlineMembers.getName().equals(leader)) {
|
||||
onlineMembers.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", new Object[] {leader, newPartyName}));
|
||||
}
|
||||
}
|
||||
|
||||
party.setName(newPartyName);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Rename", new Object[] {newPartyName}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
187
src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java
Normal file
187
src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java
Normal file
@@ -0,0 +1,187 @@
|
||||
package com.gmail.nossr50.party.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
private Player player;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
public PtpCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] { "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">" });
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
this.player = (Player) sender;
|
||||
this.playerProfile = Users.getProfile(player);
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return togglePartyTeleportation();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
return acceptAnyTeleportRequest();
|
||||
}
|
||||
|
||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||
|
||||
if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { ptpCooldown }));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept")) {
|
||||
return acceptTeleportRequest();
|
||||
}
|
||||
|
||||
return sendTeleportRequest(args[0]);
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sendTeleportRequest(String args) {
|
||||
Player target = plugin.getServer().getPlayer(args);
|
||||
|
||||
if (player.equals(target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isDead()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
PlayerProfile targetProfile = Users.getProfile(target);
|
||||
|
||||
if (!targetProfile.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", new Object[] { target.getName() }));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Users.getProfile(target).getPtpConfirmRequired()) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, playerProfile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player.teleport(target);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { player.getName() }));
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { target.getName() }));
|
||||
playerProfile.setRecentlyHurt(System.currentTimeMillis());
|
||||
} else {
|
||||
targetProfile.setPtpRequest(player);
|
||||
targetProfile.actualizePtpTimeout();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
|
||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", new Object[] { player.getName() }));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", new Object[] { ptpRequestExpire }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean acceptTeleportRequest() {
|
||||
if (!playerProfile.hasPtpRequest()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
|
||||
return true;
|
||||
}
|
||||
|
||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||
|
||||
if ((playerProfile.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
|
||||
playerProfile.removePtpRequest();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = playerProfile.getPtpRequest();
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isDead()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, playerProfile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
target.teleport(player);
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { player.getName() }));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { target.getName() }));
|
||||
playerProfile.setRecentlyHurt(System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean acceptAnyTeleportRequest() {
|
||||
if (playerProfile.getPtpConfirmRequired()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
|
||||
}
|
||||
|
||||
playerProfile.togglePtpConfirmRequired();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean togglePartyTeleportation() {
|
||||
if (playerProfile.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
|
||||
}
|
||||
|
||||
playerProfile.togglePtpUse();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
private PlayerProfile profile = null;
|
||||
private double baseXp = 0;
|
||||
private SkillType skillType = null;
|
||||
private LivingEntity target = null;
|
||||
private int baseHealth = 0;
|
||||
|
||||
public GainXp(Player player, PlayerProfile profile, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
this.player = player;
|
||||
this.profile = profile;
|
||||
this.skillType = skillType;
|
||||
this.baseXp = baseXp;
|
||||
this.target = target;
|
||||
baseHealth = target.getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int health = target.getHealth();
|
||||
int damage = baseHealth - health;
|
||||
|
||||
//May avoid negative xp, we don't know what other plugins do with the entity health
|
||||
if (damage <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Don't reward the player for overkills
|
||||
if (health < 0) {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,12 @@ import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class McRankAsync implements Runnable {
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
private final String playerName;
|
||||
private final CommandSender sender;
|
||||
|
||||
@@ -23,22 +21,26 @@ public class McRankAsync implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Map<String, Integer> skills = database.readSQLRank(playerName);
|
||||
final Map<String, Integer> skills = Database.readSQLRank(playerName);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skillType.equals(SkillType.ALL))
|
||||
continue; // We want the overall ranking to be at the bottom
|
||||
|
||||
if (skills.get(skillType.name()) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} ));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} ));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), skills.get(skillType.name())} ));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), skills.get(skillType.name())} ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import java.lang.Runnable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class MobStoreCleaner implements Runnable
|
||||
{
|
||||
public class MobStoreCleaner implements Runnable {
|
||||
private int taskID;
|
||||
|
||||
public MobStoreCleaner()
|
||||
{
|
||||
public MobStoreCleaner() {
|
||||
taskID = -1;
|
||||
start();
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
if (taskID >= 0)
|
||||
public void start() {
|
||||
if (taskID >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||
taskID = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if(taskID < 0)
|
||||
public void stop() {
|
||||
if (taskID < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
||||
taskID = -1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
mcMMO.placeStore.cleanMobLists();
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,17 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SaveTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SaveTimer(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
|
||||
BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler();
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) {
|
||||
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(mcMMOPlayer), count);
|
||||
bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new ProfileSaveTask(mcMMOPlayer), count);
|
||||
count++;
|
||||
}
|
||||
|
||||
PartyManager.getInstance().saveParties();
|
||||
PartyManager.saveParties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.FileManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class SpoutStart implements Runnable{
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SpoutStart(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) {
|
||||
mcMMO.spoutEnabled = true;
|
||||
}
|
||||
else {
|
||||
mcMMO.spoutEnabled = false;
|
||||
}
|
||||
|
||||
//Spout Stuff
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutConfig.getInstance();
|
||||
SpoutStuff.setupSpoutConfigs();
|
||||
SpoutStuff.registerCustomEvent();
|
||||
SpoutStuff.extractFiles(); //Extract source materials
|
||||
|
||||
FileManager FM = SpoutManager.getFileManager();
|
||||
FM.addToPreLoginCache(plugin, SpoutStuff.getFiles());
|
||||
|
||||
//Handle spout players after a /reload
|
||||
SpoutStuff.reloadSpoutPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,18 @@ public class StickyPistonTracker implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Block originalBlock = event.getRetractLocation().getBlock();
|
||||
Block newBlock = event.getBlock().getRelative(event.getDirection());
|
||||
Block originalBlock = newBlock.getRelative(event.getDirection());
|
||||
|
||||
if (originalBlock.getType() == Material.AIR && mcMMO.placeStore.isTrue(originalBlock)) {
|
||||
Block newBlock = originalBlock.getRelative(event.getDirection().getOppositeFace());
|
||||
|
||||
mcMMO.placeStore.setFalse(originalBlock);
|
||||
mcMMO.placeStore.setTrue(newBlock);
|
||||
if (originalBlock.getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(originalBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.placeStore.setFalse(originalBlock);
|
||||
mcMMO.placeStore.setTrue(newBlock);
|
||||
}
|
||||
}
|
||||
|
||||
173
src/main/java/com/gmail/nossr50/skills/SkillCommand.java
Normal file
173
src/main/java/com/gmail/nossr50/skills/SkillCommand.java
Normal file
@@ -0,0 +1,173 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
private SkillType skill;
|
||||
private String skillString;
|
||||
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected float skillValue;
|
||||
protected boolean isLucky;
|
||||
protected boolean hasEndurance;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
protected DecimalFormat decimal = new DecimalFormat("##0.00");
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
this.skillString = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
isLucky = Permissions.lucky(player, skill);
|
||||
hasEndurance = (Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player));
|
||||
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
|
||||
|
||||
if (!skill.isChildSkill()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
|
||||
}
|
||||
|
||||
if (effectsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
effectsDisplay();
|
||||
|
||||
if (statsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
statsDisplay();
|
||||
|
||||
SkillGuide.grabGuidePageForSkill(skill, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String calculateRank(int maxLevel, int rankChangeLevel) {
|
||||
if (skillValue >= maxLevel) {
|
||||
return String.valueOf(maxLevel / rankChangeLevel);
|
||||
}
|
||||
|
||||
return String.valueOf((int) (skillValue / rankChangeLevel));
|
||||
}
|
||||
|
||||
protected String[] calculateAbilityDisplayValues(double chance) {
|
||||
if (isLucky) {
|
||||
double luckyChance = chance * 1.3333D;
|
||||
|
||||
if (luckyChance >= 100D) {
|
||||
return new String[] { percent.format(chance / 100.0D), percent.format(1.0D) };
|
||||
}
|
||||
|
||||
return new String[] { percent.format(chance / 100.0D), percent.format(luckyChance / 100.0D) };
|
||||
}
|
||||
|
||||
return new String[] { percent.format(chance / 100.0D), null };
|
||||
}
|
||||
|
||||
protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) {
|
||||
double abilityChance;
|
||||
|
||||
if (skillValue >= maxBonusLevel) {
|
||||
abilityChance = maxChance;
|
||||
}
|
||||
else {
|
||||
abilityChance = (maxChance / maxBonusLevel) * skillValue;
|
||||
}
|
||||
|
||||
if (isLucky) {
|
||||
double luckyChance = abilityChance * 1.3333D;
|
||||
|
||||
if (luckyChance >= 100D) {
|
||||
return new String[] { percent.format(abilityChance / 100.0D), percent.format(1.0D) };
|
||||
}
|
||||
|
||||
return new String[] { percent.format(abilityChance / 100.0D), percent.format(luckyChance / 100.0D) };
|
||||
}
|
||||
|
||||
return new String[] { percent.format(abilityChance / 100.0D), null };
|
||||
}
|
||||
|
||||
protected String[] calculateLengthDisplayValues() {
|
||||
int maxLength = skill.getAbility().getMaxTicks();
|
||||
int length = 2 + (int) (skillValue / Misc.abilityLengthIncreaseLevel);
|
||||
int enduranceLength = 0;
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
enduranceLength = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
enduranceLength = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
enduranceLength = length + 4;
|
||||
}
|
||||
|
||||
if (maxLength != 0) {
|
||||
if (length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
|
||||
if (enduranceLength > maxLength) {
|
||||
enduranceLength = maxLength;
|
||||
}
|
||||
}
|
||||
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
}
|
||||
|
||||
protected void luckyEffectsDisplay() {
|
||||
if (isLucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { SkillTools.localizeSkillName(skill) }) }));
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void dataCalculations();
|
||||
|
||||
protected abstract void permissionsCheck();
|
||||
|
||||
protected abstract boolean effectsHeaderPermissions();
|
||||
|
||||
protected abstract void effectsDisplay();
|
||||
|
||||
protected abstract boolean statsHeaderPermissions();
|
||||
|
||||
protected abstract void statsDisplay();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user