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

Compare commits

...

46 Commits

Author SHA1 Message Date
GJ
663d54d31f OOP is good. 2013-05-21 15:56:09 -04:00
GJ
9a5f4b638f Little more cleaning. 2013-05-21 14:15:28 -04:00
GJ
9aa49a09da Little more cleanup. 2013-05-21 14:03:00 -04:00
GJ
bf8945ac59 Try to clean CombatUtils a bit... 2013-05-21 13:36:44 -04:00
GJ
d9926bab4e Try to clean up our poor EntityListener... 2013-05-21 13:27:52 -04:00
GJ
38ba2c21e5 Back to normal development. 2013-05-21 12:22:11 -04:00
GJ
a48fb30edf New beta! 2013-05-21 12:20:50 -04:00
GJ
92ec04bd46 Better boolean handling. 2013-05-21 11:44:16 -04:00
GJ
0b6372a6ea Don't run these calculations twice. Also, pretty sure one of these was
bugged.
2013-05-21 11:41:39 -04:00
GJ
4f8b66f94d Clean up our block listener some. 2013-05-21 11:11:55 -04:00
GJ
0c52b3016c We've got these functions, might as well use them. 2013-05-21 10:02:09 -04:00
GJ
a2f80569e3 Fire McMMOPlayerLevelUp events for our experience commands, when
applicable. Fixes #921
2013-05-21 09:31:25 -04:00
GJ
87df536a1f Only check for kraken if you're actually fishing. 2013-05-21 09:14:54 -04:00
T00thpick1
12e70490d8 Cooldowns messages need to be affected by perks too 2013-05-20 22:35:34 -04:00
TfT_02
23b1518dc0 More formatting :) 2013-05-20 17:28:02 -04:00
T00thpick1
6dbf2e0d95 FishingTreasureEvent, FishingShakeEvent and MagicHunterEvent 2013-05-20 17:27:59 -04:00
GJ
60304e9643 Because Minecraft does stupid things with "/" in the chat.
Fixes #994
2013-05-20 08:56:02 -04:00
GJ
614557e2fa It'd be nice if Ice Fishing actually worked. 2013-05-20 08:07:39 -04:00
TfT_02
e312e95aed Refactor to a more descriptive name,
also fixes a small typo.
2013-05-20 10:55:17 +02:00
t00thpick1
2ee919b51f Update gravatar 2013-05-19 18:18:55 -03:00
T00thpick1
22f6ae858b Update inventories after chimera wing 2013-05-19 16:13:19 -04:00
T00thpick1
3c3b4af2c4 No salvaging chainmail - FIXES 1118 2013-05-19 12:55:18 -04:00
T00thpick1
feb0d1fe5d Things that should never happen, but are. 2013-05-18 22:15:32 -04:00
TfT_02
2d66b8ed12 Cleanup - fixing various formatting issues 2013-05-18 22:41:42 +02:00
TfT_02
483f348403 Fixed bug with Blast Mining where the Ability refreshed message was being send too early 2013-05-18 22:27:17 +02:00
TfT_02
a8a5100f58 Update the changelog
Also made a minor edit to a comment about the powerlevel display
2013-05-18 14:27:14 +02:00
TfT_02
1f9dc70bb1 I forgot to remove the setting from advanced.yml 2013-05-18 14:12:45 +02:00
TfT_02
7f1ef61657 Get rid of the SuccessModifier
There's no need for this modifier, because the user can define the
exact chance for Rolls and Gracefull Rolls in the config file. This
means that the ratio between the two is already configurable.
2013-05-18 14:12:07 +02:00
TfT_02
2e74c079b0 Set the enchant buff level to 1 if it's lower than 0
Prevents issue #1006 from happening again.

If a user wants to disable SuperBreaker, they should do this using
permissions and not by setting the Enchant Buff level to zero.
2013-05-18 11:37:40 +02:00
TfT_02
ce4295289a Changed powerlevel display setting to disabled by default.
Because scoreboards are being cached by Minecraft in scoreboard.dat it
is no user friendly to enabled this by default. Users will have to
manually delete this file in order to actually disable this.
Described in #1105
2013-05-18 11:27:17 +02:00
T00thpick1
7fde04851d Typo 2013-05-17 18:44:23 -04:00
riking
71d030e5ad Change rounding strategy to ceiling for mob healthbars 2013-05-17 00:19:59 -04:00
T00thpick1
b08649d0a4 Not much help if not static 2013-05-16 23:58:49 -04:00
T00thpick1
0a11a9a2c8 More methods for SkillType 2013-05-16 22:00:40 -04:00
T00thpick1
068f47b523 Option for any distance 2013-05-16 19:53:58 -04:00
T00thpick1
79aab57abc Configure the inspect distance 2013-05-16 19:31:12 -04:00
T00thpick1
2cf58f1b5b Why break when we can return? 2013-05-16 18:04:14 -04:00
T00thpick1
9678875b4b We do enjoy killing off orphans 2013-05-16 17:26:16 -04:00
GJ
d1a7ce827a Back to active development. Again. 2013-05-16 16:24:19 -04:00
GJ
9b2f4b7bde Because the old beta broke all the things. 2013-05-16 16:23:12 -04:00
GJ
24e5147a2a This was never an issue. 2013-05-16 16:13:53 -04:00
T00thpick1
0423a7831d Those were right the first time... 2013-05-16 15:55:25 -04:00
T00thpick1
feea22b3a4 Correctly order 2013-05-16 15:52:49 -04:00
T00thpick1
7f40a9f284 Explicitely state columns wanted to account for altered tables 2013-05-16 15:50:19 -04:00
GJ
bc706109e0 Fix issue with tables without party names. 2013-05-16 13:37:22 -04:00
GJ
a25bddba5e Back to active development. 2013-05-16 10:55:13 -04:00
73 changed files with 847 additions and 663 deletions

View File

@@ -6,7 +6,7 @@ Key:
= Fix = Fix
! Change ! Change
- Removal - Removal
Version 1.4.06-dev Version 1.4.06-dev
+ Added "Ice Fishing" ability to Fishing + Added "Ice Fishing" ability to Fishing
+ Added global scoreboards to track skill rankings (display using /mctop) + Added global scoreboards to track skill rankings (display using /mctop)
@@ -46,6 +46,8 @@ Version 1.4.06-dev
= Fixed bug with removing players from mySQL database = Fixed bug with removing players from mySQL database
= Fixed bug with empty metadata lists and Smelting = Fixed bug with empty metadata lists and Smelting
= Fixed bug where Blast Mining would drop wrong items = Fixed bug where Blast Mining would drop wrong items
= Fixed bug with Blast Mining where the Ability refreshed message was being send too early
= Fixed bug where the chance of a successful Gracefull Roll was twice as high as displayed
! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig ! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig
! Changed Berserk to add items to inventory rather than denying pickup ! Changed Berserk to add items to inventory rather than denying pickup
! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this) ! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)

View File

@@ -29,7 +29,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/shatteredbeam) (https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)] [![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)]
(https://github.com/TfT-02) (https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/??.png)] [![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1) (https://github.com/t00thpick1)
## Compiling ## Compiling

View File

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

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.api;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -22,7 +23,7 @@ public final class ChatAPI {
* @param message The message to send * @param message The message to send
*/ */
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) { public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, displayName, message); ChatManager.handlePartyChat(plugin, mcMMO.getPartyManager().getParty(party), sender, displayName, message);
} }
/** /**
@@ -36,7 +37,7 @@ public final class ChatAPI {
* @param message The message to send * @param message The message to send
*/ */
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) { public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message); ChatManager.handlePartyChat(plugin, mcMMO.getPartyManager().getParty(party), sender, sender, message);
} }
/** /**
@@ -138,7 +139,7 @@ public final class ChatAPI {
* *
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void toggleAdminChat(String playerName){ public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName)); UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName));
} }
} }

View File

@@ -119,7 +119,7 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier())); UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
} }
/** /**
@@ -506,11 +506,7 @@ public final class ExperienceAPI {
int powerLevel = 0; int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.values()) { for (SkillType type : SkillType.nonChildSkills()) {
if (type.isChildSkill()) {
continue;
}
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getSkillLevel(type);
} }

View File

@@ -53,7 +53,7 @@ public final class PartyAPI {
* @return true if the two players are in the same party, false otherwise * @return true if the two players are in the same party, false otherwise
*/ */
public static boolean inSameParty(Player playera, Player playerb) { public static boolean inSameParty(Player playera, Player playerb) {
return PartyManager.inSameParty(playera, playerb); return mcMMO.getPartyManager().inSameParty(playera, playerb);
} }
/** /**
@@ -64,7 +64,7 @@ public final class PartyAPI {
* @return the list of parties. * @return the list of parties.
*/ */
public static List<Party> getParties() { public static List<Party> getParties() {
return PartyManager.getParties(); return mcMMO.getPartyManager().getParties();
} }
/** /**
@@ -76,7 +76,7 @@ public final class PartyAPI {
* @param partyName The party to add the player to * @param partyName The party to add the player to
*/ */
public static void addToParty(Player player, String partyName) { public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName); Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) { if (party == null) {
party = new Party(); party = new Party();
@@ -84,7 +84,7 @@ public final class PartyAPI {
party.setLeader(player.getName()); party.setLeader(player.getName());
} }
PartyManager.addToParty(player, UserManager.getPlayer(player), party); mcMMO.getPartyManager().addToParty(player, party);
} }
/** /**
@@ -95,7 +95,7 @@ public final class PartyAPI {
* @param player The player to remove * @param player The player to remove
*/ */
public static void removeFromParty(Player player) { public static void removeFromParty(Player player) {
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty()); mcMMO.getPartyManager().removeFromParty(player, UserManager.getPlayer(player).getParty());
} }
/** /**
@@ -107,7 +107,7 @@ public final class PartyAPI {
* @return the leader of the party * @return the leader of the party
*/ */
public static String getPartyLeader(String partyName) { public static String getPartyLeader(String partyName) {
return PartyManager.getPartyLeader(partyName); return mcMMO.getPartyManager().getPartyLeader(partyName);
} }
/** /**
@@ -119,7 +119,7 @@ public final class PartyAPI {
* @param player The player to set as leader * @param player The player to set as leader
*/ */
public static void setPartyLeader(String partyName, String player) { public static void setPartyLeader(String partyName, String player) {
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName)); mcMMO.getPartyManager().setPartyLeader(player, mcMMO.getPartyManager().getParty(partyName));
} }
/** /**
@@ -134,7 +134,7 @@ public final class PartyAPI {
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) { public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
List<OfflinePlayer> members = new ArrayList<OfflinePlayer>(); List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
for (String memberName : PartyManager.getAllMembers(player)) { for (String memberName : mcMMO.getPartyManager().getAllMembers(UserManager.getPlayer(player).getParty())) {
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName); OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName);
members.add(member); members.add(member);
} }
@@ -150,7 +150,7 @@ public final class PartyAPI {
* @return all the player names in the player's party * @return all the player names in the player's party
*/ */
public static LinkedHashSet<String> getMembers(Player player) { public static LinkedHashSet<String> getMembers(Player player) {
return PartyManager.getAllMembers(player); return mcMMO.getPartyManager().getAllMembers(UserManager.getPlayer(player).getParty());
} }
/** /**
@@ -162,7 +162,7 @@ public final class PartyAPI {
* @return all online players in this party * @return all online players in this party
*/ */
public static List<Player> getOnlineMembers(String partyName) { public static List<Player> getOnlineMembers(String partyName) {
return PartyManager.getOnlineMembers(partyName); return mcMMO.getPartyManager().getOnlineMembers(partyName);
} }
/** /**
@@ -174,6 +174,6 @@ public final class PartyAPI {
* @return all online players in the player's party * @return all online players in the player's party
*/ */
public static List<Player> getOnlineMembers(Player player) { public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getOnlineMembers(player); return mcMMO.getPartyManager().getOnlineMembers(UserManager.getPlayer(player).getParty().getName());
} }
} }

View File

@@ -12,7 +12,7 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public final class ChatManager { public final class ChatManager {
public ChatManager () {} public ChatManager() {}
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) { public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync); McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);

View File

@@ -62,52 +62,52 @@ public class McmmoCommand implements CommandExecutor {
private void displayPartyCommands(CommandSender sender) { private void displayPartyCommands(CommandSender sender) {
if (Permissions.party(sender)) { if (Permissions.party(sender)) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1")); sender.sendMessage(" /party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2")); sender.sendMessage(" /party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit")); sender.sendMessage(" /party quit " + LocaleLoader.getString("Commands.Party.Quit"));
if (Permissions.partyChat(sender)) { if (Permissions.partyChat(sender)) {
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle")); sender.sendMessage(" /party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
} }
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite")); sender.sendMessage(" /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept")); sender.sendMessage(" /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) { if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport")); sender.sendMessage(" /party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
} }
} }
} }
private void displayOtherCommands(CommandSender sender) { private void displayOtherCommands(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Other")); sender.sendMessage(LocaleLoader.getString("Commands.Other"));
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats")); sender.sendMessage(" /mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards")); sender.sendMessage(" /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.skillreset(sender)) { if (Permissions.skillreset(sender)) {
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset")); sender.sendMessage(" /skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
} }
if (Permissions.mcability(sender)) { if (Permissions.mcability(sender)) {
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility")); sender.sendMessage(" /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
} }
if (Permissions.adminChat(sender)) { if (Permissions.adminChat(sender)) {
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle")); sender.sendMessage(" /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
} }
if (Permissions.inspect(sender)) { if (Permissions.inspect(sender)) {
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect")); sender.sendMessage(" /inspect " + LocaleLoader.getString("Commands.Inspect"));
} }
if (Permissions.mmoedit(sender)) { if (Permissions.mmoedit(sender)) {
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit")); sender.sendMessage(" /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
} }
if (Permissions.mcgod(sender)) { if (Permissions.mcgod(sender)) {
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod")); sender.sendMessage(" /mcgod " + LocaleLoader.getString("Commands.mcgod"));
} }
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo")); sender.sendMessage(" /<skill>" + LocaleLoader.getString("Commands.SkillInfo"));
} }
} }

View File

@@ -35,7 +35,7 @@ public class PartyChatCommand extends ChatCommand {
return; return;
} }
Party party = PartyManager.getParty(args[0]); Party party = mcMMO.getPartyManager().getParty(args[0]);
if (party == null) { if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName")); sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
@@ -21,6 +23,10 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(SkillType skill) {
profile.addLevels(skill, value); profile.addLevels(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
}
} }
@Override @Override

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
@@ -21,6 +23,10 @@ public class MmoeditCommand extends ExperienceCommand {
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(SkillType skill) {
profile.modifySkill(skill, value); profile.modifySkill(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
}
} }
@Override @Override

View File

@@ -3,8 +3,10 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
@@ -84,13 +86,11 @@ public class SkillresetCommand extends ExperienceCommand {
@Override @Override
protected boolean permissionsCheckSelf(CommandSender sender) { protected boolean permissionsCheckSelf(CommandSender sender) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
protected boolean permissionsCheckOthers(CommandSender sender) { protected boolean permissionsCheckOthers(CommandSender sender) {
// TODO Auto-generated method stub
return false; return false;
} }
@@ -102,6 +102,10 @@ public class SkillresetCommand extends ExperienceCommand {
} }
profile.modifySkill(skill, 0); profile.modifySkill(skill, 0);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
}
} }
@Override @Override

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@@ -24,11 +25,11 @@ public class PartyAcceptCommand implements CommandExecutor {
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) { if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true; return true;
} }
PartyManager.joinInvitedParty(player, mcMMOPlayer); mcMMO.getPartyManager().joinInvitedParty(player);
return true; return true;
default: default:

View File

@@ -4,6 +4,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@@ -21,7 +22,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
return true; return true;
} }
PartyManager.setPartyLeader(args[1], playerParty); mcMMO.getPartyManager().setPartyLeader(args[1], playerParty);
return true; return true;
default: default:

View File

@@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@@ -17,22 +17,20 @@ public class PartyCreateCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:
Party newParty = PartyManager.getParty(args[1]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
// Check to see if the party exists, and if it does cancel creating a new party // Check to see if the party exists, and if it does cancel creating a new party
if (PartyManager.checkPartyExistence(player, newParty, args[1])) { if (mcMMO.getPartyManager().checkPartyExistence(player, args[1])) {
return true; return true;
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) { if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
return true; return true;
} }
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args)); mcMMO.getPartyManager().createParty(player, args[1], getPassword(args));
return true; return true;
default: default:

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -20,14 +21,14 @@ public class PartyDisbandCommand implements CommandExecutor {
String partyName = playerParty.getName(); String partyName = playerParty.getName();
for (Player member : playerParty.getOnlineMembers()) { for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true; return true;
} }
member.sendMessage(LocaleLoader.getString("Party.Disband")); member.sendMessage(LocaleLoader.getString("Party.Disband"));
} }
PartyManager.disbandParty(playerParty); mcMMO.getPartyManager().disbandParty(playerParty);
return true; return true;
default: default:

View File

@@ -104,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
} }
private void displayMemberInfo() { private void displayMemberInfo() {
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size(); int membersNear = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange()).size();
int membersOnline = playerParty.getOnlineMembers().size() - 1; int membersOnline = playerParty.getOnlineMembers().size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -32,14 +33,14 @@ public class PartyInviteCommand implements CommandExecutor {
return true; return true;
} }
if (PartyManager.inSameParty(player, target)) { if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName())); sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
return true; return true;
} }
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.canInvite(player, playerParty)) { if (!mcMMO.getPartyManager().canInvite(player)) {
player.sendMessage(LocaleLoader.getString("Party.Locked")); player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true; return true;
} }

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -37,16 +38,16 @@ public class PartyJoinCommand implements CommandExecutor {
String password = getPassword(args); String password = getPassword(args);
// Make sure party passwords match // Make sure party passwords match
if (!PartyManager.checkPartyPassword(player, targetParty, password)) { if (!mcMMO.getPartyManager().checkPartyPassword(player, targetParty, password)) {
return true; return true;
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) { if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, targetParty.getName())) {
return true; return true;
} }
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password); mcMMO.getPartyManager().joinParty(player, targetParty, password);
return true; return true;
default: default:

View File

@@ -30,14 +30,14 @@ public class PartyKickCommand implements CommandExecutor {
Player onlineTarget = target.getPlayer(); Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName(); String partyName = playerParty.getName();
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true; return true;
} }
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
} }
PartyManager.removeFromParty(target, playerParty); mcMMO.getPartyManager().removeFromParty(target, playerParty);
return true; return true;
default: default:

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -19,11 +20,11 @@ public class PartyQuitCommand implements CommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
Party playerParty = UserManager.getPlayer(player).getParty(); Party playerParty = UserManager.getPlayer(player).getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true; return true;
} }
PartyManager.removeFromParty(player, playerParty); mcMMO.getPartyManager().removeFromParty(player, playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true; return true;

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
@@ -30,17 +31,16 @@ public class PartyRenameCommand implements CommandExecutor {
} }
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
Party newParty = PartyManager.getParty(newPartyName);
// Check to see if the party exists, and if it does cancel renaming the party // Check to see if the party exists, and if it does cancel renaming the party
if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) { if (mcMMO.getPartyManager().checkPartyExistence(player, newPartyName)) {
return true; return true;
} }
String leaderName = playerParty.getLeader(); String leaderName = playerParty.getLeader();
for (Player member : playerParty.getOnlineMembers()) { for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true; return true;
} }

View File

@@ -55,11 +55,15 @@ public class PtpCommand implements TabExecutor {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) { if (hurtCooldown > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player))); int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
return true;
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return true;
}
} }
if (args[0].equalsIgnoreCase("accept")) { if (args[0].equalsIgnoreCase("accept")) {
@@ -74,9 +78,13 @@ public class PtpCommand implements TabExecutor {
int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long lastTeleport = mcMMOPlayer.getLastTeleport(); long lastTeleport = mcMMOPlayer.getLastTeleport();
if (!SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)) { if (ptpCooldown > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player))); int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
return true;
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return true;
}
} }
sendTeleportRequest(sender, player, args[0]); sendTeleportRequest(sender, player, args[0]);
@@ -138,7 +146,7 @@ public class PtpCommand implements TabExecutor {
return false; return false;
} }
if (!PartyManager.inSameParty(player, target)) { if (!mcMMO.getPartyManager().inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false; return false;
} }

View File

@@ -20,7 +20,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */ /* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); } public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); } public int getEnchantBuff() {
int buff = config.getInt("Skills.General.Ability_EnchantBuff", 5);
return (buff <= 0) ? 1 : buff;
}
/* ACROBATICS */ /* ACROBATICS */
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); } public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
@@ -34,7 +37,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); } public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); } public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); } public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); }
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); } public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); } public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }

View File

@@ -80,7 +80,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); } public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); } public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", true); } public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
/* Database Purging */ /* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); } public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
@@ -172,6 +172,9 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); } public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); } public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
/* /*
* ABILITY SETTINGS * ABILITY SETTINGS
*/ */
@@ -294,5 +297,5 @@ public class Config extends AutoUpdateConfigLoader {
/* XP Formula Multiplier */ /* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); } public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); } public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
} }

View File

@@ -57,7 +57,7 @@ public abstract class ConfigLoader {
OutputStream outputStream = null; OutputStream outputStream = null;
try { try {
outputStream = new FileOutputStream(configFile); outputStream = new FileOutputStream(configFile);
int read; int read;
byte[] bytes = new byte[1024]; byte[] bytes = new byte[1024];

View File

@@ -294,11 +294,7 @@ public final class FlatfileDatabaseManager {
Map<String, Integer> skills = new HashMap<String, Integer>(); Map<String, Integer> skills = new HashMap<String, Integer>();
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill()) {
continue;
}
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill))); skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
} }

View File

@@ -150,6 +150,8 @@ public final class SQLDatabaseManager {
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING); checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
checkDatabaseStructure(DatabaseUpdateType.INDEX); checkDatabaseStructure(DatabaseUpdateType.INDEX);
checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS); checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS);
checkDatabaseStructure(DatabaseUpdateType.PARTY_NAMES);
checkDatabaseStructure(DatabaseUpdateType.KILL_ORPHANS);
} }
/** /**
@@ -170,7 +172,9 @@ public final class SQLDatabaseManager {
return true; return true;
} }
catch (SQLException ex) { catch (SQLException ex) {
printErrors(ex); if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
printErrors(ex);
}
return false; return false;
} }
finally { finally {
@@ -411,11 +415,7 @@ public final class SQLDatabaseManager {
if (checkConnected()) { if (checkConnected()) {
try { try {
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.isChildSkill()) {
continue;
}
String skillName = skillType.name().toLowerCase(); String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " + String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + "AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
@@ -560,12 +560,44 @@ public final class SQLDatabaseManager {
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, " + "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;"); + "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
} }
break; return;
case MOB_HEALTHBARS: case MOB_HEALTHBARS:
sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30"; sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30";
break; break;
case PARTY_NAMES:
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
return;
case KILL_ORPHANS:
mcMMO.p.getLogger().info("Killing orphans");
write(
"DELETE FROM " + tablePrefix + "experience " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "experience.user_id = u.id);"
);
write(
"DELETE FROM " + tablePrefix + "huds " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "huds.user_id = u.id);"
);
write(
"DELETE FROM " + tablePrefix + "cooldowns " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "cooldowns.user_id = u.id);"
);
write(
"DELETE FROM " + tablePrefix + "skills " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "skills.user_id = u.id);"
);
return;
default: default:
break; break;
} }

View File

@@ -4,5 +4,8 @@ public enum DatabaseUpdateType {
FISHING, FISHING,
BLAST_MINING, BLAST_MINING,
INDEX, INDEX,
MOB_HEALTHBARS; MOB_HEALTHBARS,
PARTY_NAMES,
KILL_ORPHANS,
;
} }

View File

@@ -94,7 +94,7 @@ public class McMMOPlayer {
this.player = player; this.player = player;
profile = new PlayerProfile(playerName, true); profile = new PlayerProfile(playerName, true);
party = PartyManager.getPlayerParty(playerName); party = mcMMO.getPartyManager().getPlayerParty(playerName);
/* /*
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually), * I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
@@ -441,11 +441,7 @@ public class McMMOPlayer {
public int getPowerLevel() { public int getPowerLevel() {
int powerLevel = 0; int powerLevel = 0;
for (SkillType type : SkillType.values()) { for (SkillType type : SkillType.nonChildSkills()) {
if (type.isChildSkill()) {
continue;
}
if (Permissions.skillEnabled(player, type)) { if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getSkillLevel(type);
} }
@@ -513,7 +509,7 @@ public class McMMOPlayer {
return; return;
} }
if (!Permissions.skillEnabled(player, skillType)) { if (!Permissions.skillEnabled(player, skillType)) {
return; return;
} }

View File

@@ -49,11 +49,7 @@ public class PlayerProfile {
skillsDATS.put(abilityType, 0); skillsDATS.put(abilityType, 0);
} }
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.isChildSkill()) {
continue;
}
skills.put(skillType, 0); skills.put(skillType, 0);
skillsXp.put(skillType, 0F); skillsXp.put(skillType, 0F);
} }
@@ -257,7 +253,7 @@ public class PlayerProfile {
* @return the Xp remaining until next level * @return the Xp remaining until next level
*/ */
public int getXpToLevel(SkillType skillType) { public int getXpToLevel(SkillType skillType) {
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
} }
private int getChildSkillLevel(SkillType skillType) { private int getChildSkillLevel(SkillType skillType) {
@@ -288,7 +284,13 @@ public class PlayerProfile {
String tablePrefix = Config.getInstance().getMySQLTablePrefix(); String tablePrefix = Config.getInstance().getMySQLTablePrefix();
ArrayList<String> playerData = SQLDatabaseManager.read( ArrayList<String> playerData = SQLDatabaseManager.read(
"SELECT * FROM " + tablePrefix + "users u " + "SELECT " +
"u.id, " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " +
"h.hudtype, h.mobhealthbar " +
"FROM " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " + "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
@@ -312,68 +314,81 @@ public class PlayerProfile {
// Re-read data // Re-read data
playerData = SQLDatabaseManager.read( playerData = SQLDatabaseManager.read(
"SELECT * FROM " + tablePrefix + "users u " + "SELECT " +
"u.id, " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " +
"h.hudtype, h.mobhealthbar " +
"FROM " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " + "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " + "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"WHERE u.user = '" + playerName + "'" "WHERE u.user = '" + playerName + "'"
).get(1); ).get(1);
// Should never happen but just in case
if (playerData == null || playerData.size() == 0) {
return false;
}
} }
// Remove from list the user_id's from various tables
playerData.remove(43);
playerData.remove(30);
playerData.remove(17);
playerData.remove(4);
userId = Integer.valueOf(playerData.get(0)); userId = Integer.valueOf(playerData.get(0));
// UserName 1 - Already loaded
// LastLogin 2 - Doesn't need to be loaded
// PartyName 3 - Loaded elsewhere I believe
skills.put(SkillType.TAMING, Integer.valueOf(playerData.get(4))); skills.put(SkillType.TAMING, Integer.valueOf(playerData.get(1)));
skills.put(SkillType.MINING, Integer.valueOf(playerData.get(5))); skills.put(SkillType.MINING, Integer.valueOf(playerData.get(2)));
skills.put(SkillType.REPAIR, Integer.valueOf(playerData.get(6))); skills.put(SkillType.REPAIR, Integer.valueOf(playerData.get(3)));
skills.put(SkillType.WOODCUTTING, Integer.valueOf(playerData.get(7))); skills.put(SkillType.WOODCUTTING, Integer.valueOf(playerData.get(4)));
skills.put(SkillType.UNARMED, Integer.valueOf(playerData.get(8))); skills.put(SkillType.UNARMED, Integer.valueOf(playerData.get(5)));
skills.put(SkillType.HERBALISM, Integer.valueOf(playerData.get(9))); skills.put(SkillType.HERBALISM, Integer.valueOf(playerData.get(6)));
skills.put(SkillType.EXCAVATION, Integer.valueOf(playerData.get(10))); skills.put(SkillType.EXCAVATION, Integer.valueOf(playerData.get(7)));
skills.put(SkillType.ARCHERY, Integer.valueOf(playerData.get(11))); skills.put(SkillType.ARCHERY, Integer.valueOf(playerData.get(8)));
skills.put(SkillType.SWORDS, Integer.valueOf(playerData.get(12))); skills.put(SkillType.SWORDS, Integer.valueOf(playerData.get(9)));
skills.put(SkillType.AXES, Integer.valueOf(playerData.get(13))); skills.put(SkillType.AXES, Integer.valueOf(playerData.get(10)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(playerData.get(14))); skills.put(SkillType.ACROBATICS, Integer.valueOf(playerData.get(11)));
skills.put(SkillType.FISHING, Integer.valueOf(playerData.get(15))); skills.put(SkillType.FISHING, Integer.valueOf(playerData.get(12)));
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(playerData.get(16))); skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(playerData.get(13)));
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(playerData.get(17))); skillsXp.put(SkillType.MINING, (float) Integer.valueOf(playerData.get(14)));
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(playerData.get(18))); skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(playerData.get(15)));
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(playerData.get(19))); skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(playerData.get(16)));
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(playerData.get(20))); skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(playerData.get(17)));
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(playerData.get(21))); skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(playerData.get(18)));
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(playerData.get(22))); skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(playerData.get(19)));
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(playerData.get(23))); skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(playerData.get(20)));
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(playerData.get(24))); skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(playerData.get(21)));
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(playerData.get(25))); skillsXp.put(SkillType.AXES, (float) Integer.valueOf(playerData.get(22)));
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(playerData.get(26))); skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(playerData.get(23)));
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(playerData.get(27))); skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(playerData.get(24)));
// Taming 28 - Unused // Taming 25 - Unused
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(playerData.get(29))); skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(playerData.get(26)));
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(playerData.get(30))); // Repair 27 - Unused
// Repair 31 - Unused skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(playerData.get(28)));
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(playerData.get(32))); skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(playerData.get(29)));
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(playerData.get(33))); skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(playerData.get(30)));
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(playerData.get(34))); skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(playerData.get(31)));
// Archery 35 - Unused // Archery 32 - Unused
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(playerData.get(36))); skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(playerData.get(33)));
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(playerData.get(37))); skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(playerData.get(34)));
// Acrobatics 38 - Unused // Acrobatics 35 - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(playerData.get(39))); skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(playerData.get(36)));
hudType = HudType.valueOf(playerData.get(40)); try {
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(41)); hudType = HudType.valueOf(playerData.get(37));
}
catch (Exception e) {
// Shouldn't happen unless database is being tampered with
hudType = HudType.STANDARD;
}
try {
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(38));
}
catch (Exception e) {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
}
loaded = true; loaded = true;
return true; return true;

View File

@@ -68,6 +68,13 @@ public enum AbilityType {
null), null),
LEAF_BLOWER( LEAF_BLOWER(
null,
null,
null,
null,
null),
BLOCK_CRACKER(
null, null,
null, null,
null, null,
@@ -144,7 +151,6 @@ public enum AbilityType {
* @return true if the player has permissions, false otherwise * @return true if the player has permissions, false otherwise
*/ */
public boolean getPermissions(Player player) { public boolean getPermissions(Player player) {
switch (this) { switch (this) {
case BERSERK: case BERSERK:
return Permissions.berserk(player); return Permissions.berserk(player);
@@ -152,6 +158,9 @@ public enum AbilityType {
case BLAST_MINING: case BLAST_MINING:
return Permissions.remoteDetonation(player); return Permissions.remoteDetonation(player);
case BLOCK_CRACKER:
return Permissions.blockCracker(player);
case GIGA_DRILL_BREAKER: case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(player); return Permissions.gigaDrillBreaker(player);
@@ -189,6 +198,9 @@ public enum AbilityType {
case BERSERK: case BERSERK:
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW); return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case BLOCK_CRACKER:
return BlockUtils.affectedByBlockCracker(blockState);
case GIGA_DRILL_BREAKER: case GIGA_DRILL_BREAKER:
return BlockUtils.affectedByGigaDrillBreaker(blockState); return BlockUtils.affectedByGigaDrillBreaker(blockState);

View File

@@ -108,7 +108,7 @@ public enum SkillType {
} }
public double getXpModifier() { public double getXpModifier() {
return Config.getInstance().getForumulaMultiplier(this); return Config.getInstance().getFormulaSkillModifier(this);
} }
public static SkillType getSkill(String skillName) { public static SkillType getSkill(String skillName) {
@@ -141,6 +141,25 @@ public enum SkillType {
} }
} }
public static SkillType[] nonChildSkills() {
return new SkillType[] {SkillType.ACROBATICS,
SkillType.ARCHERY,
SkillType.AXES,
SkillType.EXCAVATION,
SkillType.FISHING,
SkillType.HERBALISM,
SkillType.MINING,
SkillType.REPAIR,
SkillType.SWORDS,
SkillType.TAMING,
SkillType.UNARMED,
SkillType.WOODCUTTING };
}
public static SkillType[] childSkills() {
return new SkillType[] { SkillType.SMELTING };
}
public Color getRunescapeModeColor() { public Color getRunescapeModeColor() {
return runescapeColor; return runescapeColor;
} }
@@ -151,7 +170,7 @@ public enum SkillType {
return type; return type;
} }
} }
return null; return null;
} }
} }

View File

@@ -17,7 +17,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) { public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
super(player, skill); super(player, skill);
this.setLevelsGained(levelsGained); this.levelsGained = levelsGained;
} }
/** /**

View File

@@ -14,7 +14,7 @@ public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
super(player, skill); super(player, skill);
this.ability = skill.getAbility(); this.ability = skill.getAbility();
} }
public AbilityType getAbility() { public AbilityType getAbility() {
return ability; return ability;
} }

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
private ItemStack treasure;
private int xp;
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
super(player, SkillType.FISHING);
this.treasure = treasure;
this.xp = xp;
}
public ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
this.treasure = item;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.events.skills.fishing;
import java.util.Map;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private Map<Enchantment, Integer> enchants;
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
super(player, treasure, xp);
this.enchants = enchants;
}
public Map<Enchantment, Integer> getEnchantments() {
return enchants;
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
private ItemStack drop;
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
super(player, SkillType.FISHING);
this.drop = drop;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public ItemStack getDrop() {
return drop;
}
public void setDrop(ItemStack drop) {
this.drop = drop;
}
}

View File

@@ -28,14 +28,12 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTrackerTask; import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
@@ -72,9 +70,11 @@ public class BlockListener implements Listener {
} }
for (Block b : blocks) { for (Block b : blocks) {
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) { Block nextBlock = b.getRelative(direction);
mcMMO.getPlaceStore().setTrue(b.getRelative(direction));
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin); if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, plugin);
} }
} }
} }
@@ -106,15 +106,14 @@ public class BlockListener implements Listener {
} }
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
int blockId = blockState.getTypeId();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) { if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState); mcMMO.getPlaceStore().setTrue(blockState);
} }
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) { if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId); UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
} }
} }
@@ -323,41 +322,31 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getItemInHand(); ItemStack heldItem = player.getItemInHand();
Block block = event.getBlock(); Block block = event.getBlock();
BlockState blockState = block.getState(); BlockState blockState = block.getState();
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/* /*
* ABILITY TRIGGER CHECKS * ABILITY TRIGGER CHECKS
* *
* We don't need to check permissions here because they've already been checked for the ability to even activate. * We don't need to check permissions here because they've already been checked for the ability to even activate.
*/ */
if (herbalismManager.canGreenTerraBlock(blockState)) { if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (herbalismManager.processGreenTerra(blockState)) { if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
blockState.update(true); blockState.update(true);
} }
} }
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) { else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) { if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
if (heldItem.getType() == Material.AIR) { event.setInstaBreak(true);
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player)); player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
} }
// Another perm check for the cracked blocks activation else if (Permissions.blockCracker(player) && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
else if (BlockUtils.affectedByBlockCracker(blockState)) { if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
blockState.update(); blockState.update();
} }
} }
} }
else if (BlockUtils.isLeaves(blockState)) { else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) { event.setInstaBreak(true);
event.setInstaBreak(true); player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
} }
} }
} }

View File

@@ -61,18 +61,22 @@ public class EntityListener implements Listener {
public void onEntityShootBow(EntityShootBowEvent event) { public void onEntityShootBow(EntityShootBowEvent event) {
ItemStack bow = event.getBow(); ItemStack bow = event.getBow();
if (bow != null) { if (bow == null) {
Entity projectile = event.getProjectile(); return;
if (projectile instanceof Arrow) {
if (bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
}
} }
Entity projectile = event.getProjectile();
if (!(projectile instanceof Arrow)) {
return;
}
if (bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
} }
/** /**
@@ -81,7 +85,7 @@ public class EntityListener implements Listener {
* @param event The event to watch * @param event The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof FallingBlock)) { if (!(entity instanceof FallingBlock)) {
@@ -107,7 +111,13 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event instanceof FakeEntityDamageByEntityEvent || event.getDamage() <= 0) { if (event instanceof FakeEntityDamageByEntityEvent) {
return;
}
int damage = event.getDamage();
if (damage <= 0) {
return; return;
} }
@@ -117,13 +127,14 @@ public class EntityListener implements Listener {
return; return;
} }
Entity attacker = event.getDamager();
LivingEntity target = (LivingEntity) defender; LivingEntity target = (LivingEntity) defender;
if (CombatUtils.isInvincible(target, event.getDamage())) { if (CombatUtils.isInvincible(target, damage)) {
return; return;
} }
Entity attacker = event.getDamager();
if (attacker instanceof Projectile) { if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter(); attacker = ((Projectile) attacker).getShooter();
} }
@@ -144,7 +155,7 @@ public class EntityListener implements Listener {
return; return;
} }
if (PartyManager.inSameParty(defendingPlayer, attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { if (mcMMO.getPartyManager().inSameParty(defendingPlayer, attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@@ -160,7 +171,13 @@ public class EntityListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (event instanceof FakeEntityDamageEvent || event.getDamage() <= 0) { if (event instanceof FakeEntityDamageEvent) {
return;
}
int damage = event.getDamage();
if (damage <= 0) {
return; return;
} }
@@ -170,13 +187,14 @@ public class EntityListener implements Listener {
return; return;
} }
DamageCause cause = event.getCause();
LivingEntity livingEntity = (LivingEntity) entity; LivingEntity livingEntity = (LivingEntity) entity;
if (CombatUtils.isInvincible(livingEntity, event.getDamage())) { if (CombatUtils.isInvincible(livingEntity, damage)) {
return; return;
} }
DamageCause cause = event.getCause();
if (livingEntity instanceof Player) { if (livingEntity instanceof Player) {
Player player = (Player) entity; Player player = (Player) entity;
@@ -309,7 +327,6 @@ public class EntityListener implements Listener {
return; return;
} }
entity.setFireTicks(0);
BleedTimerTask.remove(entity); BleedTimerTask.remove(entity);
Archery.arrowRetrievalCheck(entity); Archery.arrowRetrievalCheck(entity);
} }
@@ -348,19 +365,21 @@ public class EntityListener implements Listener {
public void onExplosionPrime(ExplosionPrimeEvent event) { public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
// We can make this assumption because we (should) be the only ones using this exact metadata return;
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); }
if (Misc.isNPCEntity(player)) { // We can make this assumption because we (should) be the only ones using this exact metadata
return; Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); if (Misc.isNPCEntity(player)) {
return;
}
if (miningManager.canUseBiggerBombs()) { MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
event.setRadius(miningManager.biggerBombs(event.getRadius()));
} if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
} }
} }
@@ -373,20 +392,22 @@ public class EntityListener implements Listener {
public void onEnitityExplode(EntityExplodeEvent event) { public void onEnitityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
// We can make this assumption because we (should) be the only ones using this exact metadata return;
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); }
if (Misc.isNPCEntity(player)) { // We can make this assumption because we (should) be the only ones using this exact metadata
return; Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager(); if (Misc.isNPCEntity(player)) {
return;
}
if (miningManager.canUseBlastMining()) { MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
event.setYield(0); if (miningManager.canUseBlastMining()) {
} miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
event.setYield(0);
} }
} }
@@ -399,63 +420,65 @@ public class EntityListener implements Listener {
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof Player) { if (!(entity instanceof Player)) {
Player player = (Player) entity; return;
}
if (Misc.isNPCEntity(player)) { Player player = (Player) entity;
if (Misc.isNPCEntity(player)) {
return;
}
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
int foodChange = newFoodLevel - currentFoodLevel;
if (foodChange <= 0) {
return;
}
/*
* Some foods have 3 ranks
* Some foods have 5 ranks
* The number of ranks is based on how 'common' the item is
* We can adjust this quite easily if we find something is giving too much of a bonus
*/
switch (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 */
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
}
return; return;
}
int currentFoodLevel = player.getFoodLevel(); case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
int newFoodLevel = event.getFoodLevel(); case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
int foodChange = newFoodLevel - currentFoodLevel; case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (foodChange <= 0) { if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
}
return; return;
}
/* case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
* Some foods have 3 ranks if (Permissions.fishermansDiet(player)) {
* Some foods have 5 ranks event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
* 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 return;
*/
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 */
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
}
return;
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ if (Permissions.fishermansDiet(player)) {
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ }
if (Permissions.farmersDiet(player)) { return;
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
}
return;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ default:
if (Permissions.fishermansDiet(player)) { return;
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
}
return;
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
if (Permissions.fishermansDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
}
return;
default:
return;
}
} }
} }

View File

@@ -180,10 +180,10 @@ public class PlayerListener implements Listener {
case FISHING: case FISHING:
if (!Permissions.krakenBypass(player)) { if (!Permissions.krakenBypass(player)) {
event.setCancelled(fishingManager.exploitPrevention()); event.setCancelled(fishingManager.exploitPrevention());
}
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
}
} }
if (fishingManager.canMasterAngler()) { if (fishingManager.canMasterAngler()) {
@@ -209,7 +209,7 @@ public class PlayerListener implements Listener {
case IN_GROUND: case IN_GROUND:
Fish hook = event.getHook(); Fish hook = event.getHook();
Block block = hook.getLocation().getBlock(); Block block = event.getPlayer().getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) { if (fishingManager.canIceFish(block)) {
event.setCancelled(true); event.setCancelled(true);
@@ -355,7 +355,7 @@ public class PlayerListener implements Listener {
} }
} }
/* SALVAGE CHECKS */ /* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) { else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true); event.setCancelled(true);

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -19,8 +18,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
public class WorldListener implements Listener { public class WorldListener implements Listener {
private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>(); private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
private final mcMMO plugin; private final mcMMO plugin;
public WorldListener(final mcMMO plugin) { public WorldListener(final mcMMO plugin) {
@@ -34,12 +32,12 @@ public class WorldListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) { public void onStructureGrow(StructureGrowEvent event) {
Location location = event.getLocation(); if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
return;
}
if (mcMMO.getPlaceStore().isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) { for (BlockState blockState : event.getBlocks()) {
for (BlockState blockState : event.getBlocks()) { mcMMO.getPlaceStore().setFalse(blockState);
mcMMO.getPlaceStore().setFalse(blockState);
}
} }
} }
@@ -51,9 +49,8 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) { public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld(); World world = event.getWorld();
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
if (!dataDir.exists() || plugin == null) { if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || plugin == null) {
return; return;
} }

View File

@@ -57,6 +57,7 @@ public class mcMMO extends JavaPlugin {
private static ChunkManager placeStore; private static ChunkManager placeStore;
private static RepairableManager repairableManager; private static RepairableManager repairableManager;
private static DatabaseManager databaseManager; private static DatabaseManager databaseManager;
private static PartyManager partyManager;
/* File Paths */ /* File Paths */
private static String mainDirectory; private static String mainDirectory;
@@ -114,7 +115,7 @@ public class mcMMO extends JavaPlugin {
registerEvents(); registerEvents();
registerCustomRecipes(); registerCustomRecipes();
PartyManager.loadParties(); partyManager = new PartyManager(this);
for (Player player : getServer().getOnlinePlayers()) { for (Player player : getServer().getOnlinePlayers()) {
UserManager.addUser(player); // In case of reload add all users back into UserManager UserManager.addUser(player); // In case of reload add all users back into UserManager
@@ -156,7 +157,7 @@ public class mcMMO extends JavaPlugin {
public void onDisable() { public void onDisable() {
try { try {
UserManager.saveAll(); // Make sure to save player information if the server shuts down UserManager.saveAll(); // Make sure to save player information if the server shuts down
PartyManager.saveParties(); // Save our parties partyManager.saveParties(); // Save our parties
placeStore.saveAll(); // Save our metadata placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores placeStore.cleanUp(); // Cleanup empty metadata stores
} }
@@ -235,6 +236,10 @@ public class mcMMO extends JavaPlugin {
return repairableManager; return repairableManager;
} }
public static PartyManager getPartyManager() {
return partyManager;
}
public static boolean isSpoutEnabled() { public static boolean isSpoutEnabled() {
return spoutEnabled; return spoutEnabled;
} }

View File

@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -18,15 +19,20 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public final class PartyManager { public class PartyManager {
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; private final mcMMO plugin;
private static List<Party> parties = new ArrayList<Party>(); private final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
private static File partyFile = new File(partiesFilePath); private final List<Party> parties = new ArrayList<Party>();
private final File partyFile = new File(partiesFilePath);
private PartyManager() {} public PartyManager(final mcMMO plugin) {
this.plugin = plugin;
public static boolean checkPartyExistence(Player player, Party party, String partyName) { loadParties();
if (party == null) { }
public boolean checkPartyExistence(Player player, String partyName) {
if (getParty(partyName) == null) {
return false; return false;
} }
@@ -34,8 +40,12 @@ public final class PartyManager {
return true; return true;
} }
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, Player player, Party oldParty, String newPartyName) { public boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
Player player = mcMMOPlayer.getPlayer();
if (mcMMOPlayer.inParty()) { if (mcMMOPlayer.inParty()) {
Party oldParty = mcMMOPlayer.getParty();
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false; return false;
} }
@@ -56,7 +66,7 @@ public final class PartyManager {
* @param secondPlayer The second player * @param secondPlayer The second player
* @return true if they are in the same party, false otherwise * @return true if they are in the same party, false otherwise
*/ */
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) { public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
McMMOPlayer firstMcMMOPlayer = UserManager.getPlayer(firstPlayer); McMMOPlayer firstMcMMOPlayer = UserManager.getPlayer(firstPlayer);
McMMOPlayer secondMcMMOPlayer = UserManager.getPlayer(secondPlayer); McMMOPlayer secondMcMMOPlayer = UserManager.getPlayer(secondPlayer);
@@ -81,15 +91,20 @@ public final class PartyManager {
* @param range The distance * @param range The distance
* @return the near party members * @return the near party members
*/ */
public static List<Player> getNearMembers(Player player, Party party, double range) { public List<Player> getNearbyPartyMembers(Player player, double range) {
List<Player> nearMembers = new ArrayList<Player>(); List<Player> nearMembers = new ArrayList<Player>();
Party party = UserManager.getPlayer(player).getParty();
if (party != null) { if (party != null) {
Location playerLocation = player.getLocation();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!player.getName().equalsIgnoreCase(member.getName()) && !member.isDead() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.equals(member) && !member.isValid() && Misc.isNear(playerLocation, member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
} }
} }
return nearMembers; return nearMembers;
} }
@@ -99,9 +114,7 @@ public final class PartyManager {
* @param player The player to check * @param player The player to check
* @return all the players in the player's party * @return all the players in the player's party
*/ */
public static LinkedHashSet<String> getAllMembers(Player player) { public LinkedHashSet<String> getAllMembers(Party party) {
Party party = UserManager.getPlayer(player).getParty();
if (party == null) { if (party == null) {
return null; return null;
} }
@@ -115,7 +128,7 @@ public final class PartyManager {
* @param partyName The party to check * @param partyName The party to check
* @return all online players in this party * @return all online players in this party
*/ */
public static List<Player> getOnlineMembers(String partyName) { public List<Player> getOnlineMembers(String partyName) {
Party party = getParty(partyName); Party party = getParty(partyName);
if (party == null) { if (party == null) {
@@ -125,29 +138,13 @@ public final class PartyManager {
return party.getOnlineMembers(); return party.getOnlineMembers();
} }
/**
* Get a list of all online players in this party.
*
* @param player The player to check
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(Player player) {
Party party = getPlayerParty(player.getName());
if (party == null) {
return null;
}
return getOnlineMembers(party.getName());
}
/** /**
* Retrieve a party by its name * Retrieve a party by its name
* *
* @param partyName The party name * @param partyName The party name
* @return the existing party, null otherwise * @return the existing party, null otherwise
*/ */
public static Party getParty(String partyName) { public Party getParty(String partyName) {
for (Party party : parties) { for (Party party : parties) {
if (party.getName().equals(partyName)) { if (party.getName().equals(partyName)) {
return party; return party;
@@ -163,7 +160,7 @@ public final class PartyManager {
* @param playerName The member name * @param playerName The member name
* @return the existing party, null otherwise * @return the existing party, null otherwise
*/ */
public static Party getPlayerParty(String playerName) { public Party getPlayerParty(String playerName) {
for (Party party : parties) { for (Party party : parties) {
for (String memberName : party.getMembers()) { for (String memberName : party.getMembers()) {
if (memberName.equalsIgnoreCase(playerName)) { if (memberName.equalsIgnoreCase(playerName)) {
@@ -180,7 +177,7 @@ public final class PartyManager {
* *
* @return the list of parties. * @return the list of parties.
*/ */
public static List<Party> getParties() { public List<Party> getParties() {
return parties; return parties;
} }
@@ -190,7 +187,7 @@ public final class PartyManager {
* @param player The player to remove * @param player The player to remove
* @param party The party * @param party The party
*/ */
public static void removeFromParty(OfflinePlayer player, Party party) { public void removeFromParty(OfflinePlayer player, Party party) {
LinkedHashSet<String> members = party.getMembers(); LinkedHashSet<String> members = party.getMembers();
members.remove(player.getName()); members.remove(player.getName());
@@ -201,20 +198,13 @@ public final class PartyManager {
else { else {
// If the leaving player was the party leader, appoint a new leader from the party members // If the leaving player was the party leader, appoint a new leader from the party members
if (party.getLeader().equalsIgnoreCase(player.getName())) { if (party.getLeader().equalsIgnoreCase(player.getName())) {
String newLeader = members.iterator().next(); party.setLeader(members.iterator().next());
party.setLeader(newLeader);
} }
informPartyMembersQuit(player, party); informPartyMembersQuit(player, party);
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player.getName()); processPlayerLeaving(UserManager.getPlayer(player));
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
} }
/** /**
@@ -222,17 +212,11 @@ public final class PartyManager {
* *
* @param party The party to remove * @param party The party to remove
*/ */
public static void disbandParty(Party party) { public void disbandParty(Party party) {
LinkedHashSet<String> members = party.getMembers(); LinkedHashSet<String> members = party.getMembers();
for (String memberName : members) { for (String memberName : members) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(memberName); processPlayerLeaving(UserManager.getPlayer(memberName));
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
} }
members.clear(); members.clear();
@@ -243,11 +227,10 @@ public final class PartyManager {
* Create a new party * Create a new party
* *
* @param player The player to add to the party * @param player The player to add to the party
* @param mcMMOPlayer The player to add to the party
* @param partyName The party to add the player to * @param partyName The party to add the player to
* @param password The password for this party, null if there was no password * @param password The password for this party, null if there was no password
*/ */
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) { public void createParty(Player player, String partyName, String password) {
partyName = partyName.replace(".", ""); partyName = partyName.replace(".", "");
Party party = getParty(partyName); Party party = getParty(partyName);
@@ -271,7 +254,7 @@ public final class PartyManager {
} }
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName())); player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
addToParty(player, mcMMOPlayer, party); addToParty(player, party);
} }
/** /**
@@ -282,17 +265,18 @@ public final class PartyManager {
* @param party The party to add the player to * @param party The party to add the player to
* @param password the password for this party, null if there was no password * @param password the password for this party, null if there was no password
*/ */
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, Party party, String password) { public void joinParty(Player player, Party party, String password) {
if (!checkPartyPassword(player, party, password)) { if (!checkPartyPassword(player, party, password)) {
return; return;
} }
if (mcMMOPlayer.getParty() == party) { // // Pretty sure this isn't possible.
return; // if (mcMMOPlayer.getParty() == party) {
} // return;
// }
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName())); player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
addToParty(player, mcMMOPlayer, party); addToParty(player, party);
} }
/** /**
@@ -303,7 +287,7 @@ public final class PartyManager {
* @param password The password provided by the player * @param password The password provided by the player
* @return true if the player can join the party * @return true if the player can join the party
*/ */
public static boolean checkPartyPassword(Player player, Party party, String password) { public boolean checkPartyPassword(Player player, Party party, String password) {
// Don't care about passwords if it isn't locked // Don't care about passwords if it isn't locked
if (party.isLocked()) { if (party.isLocked()) {
String partyPassword = party.getPassword(); String partyPassword = party.getPassword();
@@ -333,20 +317,22 @@ public final class PartyManager {
* @param Player The plaer to add to the party * @param Player The plaer to add to the party
* @param mcMMOPlayer The player to add to the party * @param mcMMOPlayer The player to add to the party
*/ */
public static void joinInvitedParty(Player player, McMMOPlayer mcMMOPlayer) { public void joinInvitedParty(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party invite = mcMMOPlayer.getPartyInvite(); Party invite = mcMMOPlayer.getPartyInvite();
if (mcMMOPlayer.getParty() == invite) { if (mcMMOPlayer.getParty() == invite) {
return; return;
} }
if (!parties.contains(invite)) { // // Pretty sure this isn't possible
parties.add(invite); // if (!parties.contains(invite)) {
} // parties.add(invite);
// }
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName())); player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
mcMMOPlayer.removePartyInvite(); mcMMOPlayer.removePartyInvite();
addToParty(player, mcMMOPlayer, invite); addToParty(player, invite);
} }
/** /**
@@ -356,11 +342,17 @@ public final class PartyManager {
* @param mcMMOPlayer The player to add to the party * @param mcMMOPlayer The player to add to the party
* @param party The party * @param party The party
*/ */
public static void addToParty(OfflinePlayer player, McMMOPlayer mcMMOPlayer, Party party) { public void addToParty(OfflinePlayer player, Party party) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getParty() == party) { if (mcMMOPlayer.getParty() == party) {
return; return;
} }
if (!parties.contains(party)) {
parties.add(party);
}
informPartyMembersJoin(player, party); informPartyMembersJoin(player, party);
mcMMOPlayer.setParty(party); mcMMOPlayer.setParty(party);
@@ -373,7 +365,7 @@ public final class PartyManager {
* @param partyName The party name * @param partyName The party name
* @return the leader of the party * @return the leader of the party
*/ */
public static String getPartyLeader(String partyName) { public String getPartyLeader(String partyName) {
Party party = getParty(partyName); Party party = getParty(partyName);
if (party == null) { if (party == null) {
@@ -389,7 +381,7 @@ public final class PartyManager {
* @param playerName The name of the player to set as leader * @param playerName The name of the player to set as leader
* @param party The party * @param party The party
*/ */
public static void setPartyLeader(String playerName, Party party) { public void setPartyLeader(String playerName, Party party) {
String leaderName = party.getLeader(); String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
@@ -414,7 +406,9 @@ public final class PartyManager {
* @param mcMMOPlayer The player to check * @param mcMMOPlayer The player to check
* @return true if the player can invite * @return true if the player can invite
*/ */
public static boolean canInvite(Player player, Party party) { public boolean canInvite(Player player) {
Party party = getPlayerParty(player.getName());
if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) { if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) {
return false; return false;
} }
@@ -422,26 +416,10 @@ public final class PartyManager {
return true; return true;
} }
/**
* Check if a string is a valid party name.
*
* @param partyName The party name to check
* @return true if this is a valid party, false otherwise
*/
public static boolean isParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return true;
}
}
return false;
}
/** /**
* Load party file. * Load party file.
*/ */
public static void loadParties() { private void loadParties() {
if (!partyFile.exists()) { if (!partyFile.exists()) {
return; return;
} }
@@ -472,7 +450,7 @@ public final class PartyManager {
/** /**
* Save party file. * Save party file.
*/ */
public static void saveParties() { public void saveParties() {
if (partyFile.exists()) { if (partyFile.exists()) {
partyFile.delete(); partyFile.delete();
} }
@@ -516,7 +494,7 @@ public final class PartyManager {
* @param reason The reason for changing parties * @param reason The reason for changing parties
* @return true if the change event was successful, false otherwise * @return true if the change event was successful, false otherwise
*/ */
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) { public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
mcMMO.p.getServer().getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -529,7 +507,7 @@ public final class PartyManager {
* @param player The player that joins * @param player The player that joins
* @param party The concerned party * @param party The concerned party
*/ */
private static void informPartyMembersJoin(OfflinePlayer player, Party party) { private void informPartyMembersJoin(OfflinePlayer player, Party party) {
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!member.equals(player)) { if (!member.equals(player)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName())); member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
@@ -543,11 +521,21 @@ public final class PartyManager {
* @param player The player that quits * @param player The player that quits
* @param party The concerned party * @param party The concerned party
*/ */
private static void informPartyMembersQuit(OfflinePlayer player, Party party) { private void informPartyMembersQuit(OfflinePlayer player, Party party) {
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!member.equals(player)) { if (!member.equals(player)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName())); member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName()));
} }
} }
} }
private void processPlayerLeaving(McMMOPlayer mcMMOPlayer) {
if (mcMMOPlayer == null) {
return;
}
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
} }

View File

@@ -6,6 +6,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.party.ItemWeightConfig; import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.ItemShareType;
@@ -53,12 +54,10 @@ public final class ShareHandler {
* @return True is the xp has been shared * @return True is the xp has been shared
*/ */
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) { public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
Party party = mcMMOPlayer.getParty(); switch (mcMMOPlayer.getParty().getXpShareMode()) {
switch (party.getXpShareMode()) {
case EQUAL: case EQUAL:
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) { if (nearMembers.isEmpty()) {
return false; return false;
@@ -112,7 +111,7 @@ public final class ShareHandler {
switch (party.getItemShareMode()) { switch (party.getItemShareMode()) {
case EQUAL: case EQUAL:
McMMOPlayer mcMMOTarget; McMMOPlayer mcMMOTarget;
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) { if (nearMembers.isEmpty()) {
return false; return false;
@@ -159,7 +158,7 @@ public final class ShareHandler {
return true; return true;
case RANDOM: case RANDOM:
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()); nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) { if (nearMembers.isEmpty()) {
return false; return false;

View File

@@ -19,6 +19,6 @@ public class SaveTimerTask extends BukkitRunnable {
count++; count++;
} }
PartyManager.saveParties(); mcMMO.getPartyManager().saveParties();
} }
} }

View File

@@ -31,8 +31,8 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) { if (player != null && !Permissions.skillEnabled(player, skill)) {
continue; continue;
} }

View File

@@ -28,8 +28,6 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
private void checkChimaeraWingTeleport() { private void checkChimaeraWingTeleport() {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation(); Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
ItemStack inHand = player.getItemInHand();
mcMMOPlayer.setTeleportCommenceLocation(null); mcMMOPlayer.setTeleportCommenceLocation(null);
@@ -38,16 +36,23 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
return; return;
} }
ItemStack inHand = player.getItemInHand();
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) { if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name"))); player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
return; return;
} }
int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown(); long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) { if (hurtCooldown > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player))); int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
return;
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
} }
ChimaeraWing.chimaeraExecuteTeleport(); ChimaeraWing.chimaeraExecuteTeleport();

View File

@@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.party.teleport.PtpCommand; import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -37,7 +38,7 @@ public class TeleportationWarmup extends BukkitRunnable {
mcMMOPlayer.setTeleportCommenceLocation(null); mcMMOPlayer.setTeleportCommenceLocation(null);
if (!PartyManager.inSameParty(teleportingPlayer, targetPlayer)) { if (!mcMMO.getPartyManager().inSameParty(teleportingPlayer, targetPlayer)) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName())); teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName()));
return; return;
} }
@@ -47,11 +48,15 @@ public class TeleportationWarmup extends BukkitRunnable {
return; return;
} }
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)) { if (hurtCooldown > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer))); int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer);
return;
if (timeRemaining > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
} }
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer); PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);

View File

@@ -27,7 +27,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime(); long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
for (Iterator<Party> partyIterator = PartyManager.getParties().iterator(); partyIterator.hasNext();) { for (Iterator<Party> partyIterator = mcMMO.getPartyManager().getParties().iterator(); partyIterator.hasNext();) {
Party party = partyIterator.next(); Party party = partyIterator.next();
for (String memberName : party.getMembers()) { for (String memberName : party.getMembers()) {
@@ -44,7 +44,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
} }
for (Entry<OfflinePlayer, Party> entry : toRemove.entrySet()) { for (Entry<OfflinePlayer, Party> entry : toRemove.entrySet()) {
PartyManager.removeFromParty(entry.getKey(), entry.getValue()); mcMMO.getPartyManager().removeFromParty(entry.getKey(), entry.getValue());
} }
} }
} }

View File

@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
public class AbilityDisableTask extends BukkitRunnable { public class AbilityDisableTask extends BukkitRunnable {
@@ -59,6 +60,6 @@ public class AbilityDisableTask extends BukkitRunnable {
} }
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player)); SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, ability.getCooldown() * 20); new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * 20);
} }
} }

View File

@@ -14,7 +14,6 @@ public final class Acrobatics {
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel(); public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold(); public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax(); public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier(); public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();

View File

@@ -81,7 +81,7 @@ public class AcrobaticsManager extends SkillManager {
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold); int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) { if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text")); player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
applyXpGain(damage * Acrobatics.rollXpModifier); applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -103,7 +103,7 @@ public class AcrobaticsManager extends SkillManager {
private int gracefulRollCheck(int damage) { private int gracefulRollCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold); int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) { if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel)) {
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
applyXpGain(damage * Acrobatics.rollXpModifier); applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -116,8 +116,8 @@ public class AcrobaticsManager extends SkillManager {
return damage; return damage;
} }
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) { private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance); return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
} }
private boolean isFatal(int damage) { private boolean isFatal(int damage) {

View File

@@ -19,44 +19,42 @@ public class ChildConfig extends AutoUpdateConfigLoader {
protected void loadKeys() { protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml"))); config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.childSkills()) {
if (skill.isChildSkill()) { plugin.debug("Finding parents of " + skill.name());
plugin.debug("Finding parents of " + skill.name());
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name())); List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class); EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults boolean useDefaults = false; // If we had an error we back out and use defaults
for (String name : parentNames) { for (String name : parentNames) {
try { try {
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase()); SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill); FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill); parentSkills.add(parentSkill);
}
catch (IllegalArgumentException ex) {
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
useDefaults = true;
break;
}
} }
catch (IllegalArgumentException ex) {
if (useDefaults) { plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
parentSkills.clear(); useDefaults = true;
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) { break;
/* We do less checks in here because it's from inside our jar.
* If they're dedicated enough to have modified it, they can have the errors it may produce.
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
*/
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
}
} }
}
// Register them if (useDefaults) {
for (SkillType parentSkill : parentSkills) { parentSkills.clear();
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name()); for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
FamilyTree.registerParent(skill, parentSkill); /* We do less checks in here because it's from inside our jar.
* If they're dedicated enough to have modified it, they can have the errors it may produce.
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
*/
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
} }
} }
// Register them
for (SkillType parentSkill : parentSkills) {
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
FamilyTree.registerParent(skill, parentSkill);
}
} }
FamilyTree.closeRegistration(); FamilyTree.closeRegistration();

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@@ -37,6 +39,9 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.events.fake.FakePlayerFishEvent; import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.KrakenAttackTask; import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
@@ -138,12 +143,12 @@ public class FishingManager extends SkillManager {
} }
public boolean exploitPrevention() { public boolean exploitPrevention() {
if (!AdvancedConfig.getInstance().getKrakenEnabled()) { if (!AdvancedConfig.getInstance().getKrakenEnabled() || !getPlayer().getTargetBlock(null, 100).isLiquid()) {
return false; return false;
} }
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
boolean hasFished = currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS; boolean hasFished = (currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS);
fishingTries = hasFished ? fishingTries + 1 : Math.max(fishingTries - 1, 0); fishingTries = hasFished ? fishingTries + 1 : Math.max(fishingTries - 1, 0);
fishingTimestamp = currentTime; fishingTimestamp = currentTime;
@@ -219,7 +224,7 @@ public class FishingManager extends SkillManager {
// Make a hole // Make a hole
block.setType(Material.STATIONARY_WATER); block.setType(Material.STATIONARY_WATER);
for (int x = -1; x <= 1; x++) { for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) { for (int z = -1; z <= 1; z++) {
Block relative = block.getRelative(x, 0, z); Block relative = block.getRelative(x, 0, z);
@@ -269,13 +274,43 @@ public class FishingManager extends SkillManager {
treasureXp = treasure.getXp(); treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay? ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) { McMMOPlayerFishingTreasureEvent event;
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound")); Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop)) {
enchants = handleMagicHunter(treasureDrop);
event = new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
}
else {
event = new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp);
}
mcMMO.p.getServer().getPluginManager().callEvent(event);
treasureDrop = event.getTreasure();
treasureXp = event.getXp();
if (event.isCancelled()) {
treasureDrop = null;
treasureXp = 0;
} }
// Drop the original catch at the feet of the player and set the treasure as the real catch // Drop the original catch at the feet of the player and set the treasure as the real catch
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack()); if (treasureDrop != null) {
fishingCatch.setItemStack(treasureDrop); boolean enchanted = false;
if (!enchants.isEmpty()) {
treasureDrop.addUnsafeEnchantments(enchants);
enchanted = true;
}
if (enchanted) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
}
} }
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp); applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
@@ -351,6 +386,14 @@ public class FishingManager extends SkillManager {
break; break;
} }
McMMOPlayerShakeEvent event = new McMMOPlayerShakeEvent(getPlayer(), drop);
drop = event.getDrop();
if (event.isCancelled() || drop == null) {
return;
}
Misc.dropItem(target.getLocation(), drop); Misc.dropItem(target.getLocation(), drop);
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times. CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
} }
@@ -399,7 +442,7 @@ public class FishingManager extends SkillManager {
* @param treasureDrop The {@link ItemStack} to enchant * @param treasureDrop The {@link ItemStack} to enchant
* @return true if the item has been enchanted * @return true if the item has been enchanted
*/ */
private boolean handleMagicHunter(ItemStack treasureDrop) { private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer(); Player player = getPlayer();
int activationChance = this.activationChance; int activationChance = this.activationChance;
@@ -407,8 +450,10 @@ public class FishingManager extends SkillManager {
activationChance *= Fishing.STORM_MODIFIER; activationChance *= Fishing.STORM_MODIFIER;
} }
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) { if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
return false; return enchants;
} }
List<Enchantment> possibleEnchantments = getPossibleEnchantments(treasureDrop); List<Enchantment> possibleEnchantments = getPossibleEnchantments(treasureDrop);
@@ -416,7 +461,6 @@ public class FishingManager extends SkillManager {
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant // This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
Collections.shuffle(possibleEnchantments, Misc.getRandom()); Collections.shuffle(possibleEnchantments, Misc.getRandom());
boolean enchanted = false;
int specificChance = 1; int specificChance = 1;
for (Enchantment possibleEnchantment : possibleEnchantments) { for (Enchantment possibleEnchantment : possibleEnchantments) {
@@ -424,13 +468,12 @@ public class FishingManager extends SkillManager {
continue; continue;
} }
treasureDrop.addEnchantment(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel())); enchants.put(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel()));
specificChance++; specificChance++;
enchanted = true;
} }
return enchanted; return enchants;
} }
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) { private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {

View File

@@ -27,7 +27,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
public class MiningManager extends SkillManager{ public class MiningManager extends SkillManager {
public MiningManager(McMMOPlayer mcMMOPlayer) { public MiningManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING); super(mcMMOPlayer, SkillType.MINING);
} }
@@ -109,7 +109,7 @@ public class MiningManager extends SkillManager{
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false); mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown()); new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * 20);
} }
/** /**
@@ -287,9 +287,10 @@ public class MiningManager extends SkillManager{
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR; long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
int cooldown = AbilityType.BLAST_MINING.getCooldown(); int cooldown = AbilityType.BLAST_MINING.getCooldown();
int timeRemaining = SkillUtils.calculateTimeLeft(oldTime, cooldown, player);
if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) { if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player))); player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return false; return false;
} }

View File

@@ -195,7 +195,7 @@ public class RepairManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
long LastUse = mcMMOPlayer.getLastAnvilUse(anvilId); long LastUse = mcMMOPlayer.getLastAnvilUse(anvilId);
// Don't use SkillUtils.cooldownOver() here since that also accounts for the cooldown perks // Don't use SkillUtils.cooldownOver() here since that also accounts for the cooldown perks
if ((((LastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) { if ((((LastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) {

View File

@@ -43,7 +43,7 @@ public class Unarmed {
ItemStack addStack = itemstack.clone(); ItemStack addStack = itemstack.clone();
if (dropAmount + itemAmount <= itemMax) { if (dropAmount + itemAmount <= itemMax) {
drop.remove(); drop.remove();
addStack.setAmount(dropAmount + itemAmount); addStack.setAmount(dropAmount + itemAmount);
inventory.setItem(nextSlot, addStack); inventory.setItem(nextSlot, addStack);

View File

@@ -7,7 +7,7 @@ import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize; import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import org.bukkit.material.NetherWarts; import org.bukkit.material.NetherWarts;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.skills.repair.Repair;
public final class BlockUtils { public final class BlockUtils {
private BlockUtils() {} private BlockUtils() {}
@@ -306,9 +306,9 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check * @param blockState The {@link BlockState} of the block to check
* @return true if the block is an mcMMO anvil, false otherwise * @return true if the block is an mcMMO anvil, false otherwise
*/ */
private static boolean isMcMMOAnvil(BlockState blockState) { public static boolean isMcMMOAnvil(BlockState blockState) {
int blockId = blockState.getTypeId(); int blockId = blockState.getTypeId();
return blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId(); return blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId;
} }
} }

View File

@@ -35,9 +35,13 @@ public final class ChimaeraWing {
* @param player Player whose item usage to check * @param player Player whose item usage to check
*/ */
public static void activationCheck(Player player) { public static void activationCheck(Player player) {
if (!Config.getInstance().getChimaeraEnabled()) {
return;
}
ItemStack inHand = player.getItemInHand(); ItemStack inHand = player.getItemInHand();
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) { if (!ItemUtils.isChimaeraWing(inHand)) {
return; return;
} }
@@ -48,36 +52,48 @@ public final class ChimaeraWing {
mcMMOPlayer = UserManager.getPlayer(player); mcMMOPlayer = UserManager.getPlayer(player);
location = player.getLocation();
int amount = inHand.getAmount();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
long lastTeleport = mcMMOPlayer.getLastTeleport();
if (mcMMOPlayer.getTeleportCommenceLocation() != null) { if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
return; return;
} }
if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) { int amount = inHand.getAmount();
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)));
return;
}
int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
return;
}
if (amount < Config.getInstance().getChimaeraUseCost()) { if (amount < Config.getInstance().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name"))); player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
return; return;
} }
long lastTeleport = mcMMOPlayer.getLastTeleport();
int cooldown = Config.getInstance().getChimaeraCooldown();
if (cooldown > 0 ) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return;
}
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
}
location = player.getLocation();
if (Config.getInstance().getChimaeraPreventUseUnderground()) { if (Config.getInstance().getChimaeraPreventUseUnderground()) {
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0)); player.setVelocity(new Vector(0, 0.5D, 0));
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10)); CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10));
mcMMOPlayer.actualizeLastTeleport(); mcMMOPlayer.actualizeLastTeleport();
@@ -115,6 +131,7 @@ public final class ChimaeraWing {
} }
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost()))); player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.updateInventory();
UserManager.getPlayer(player).actualizeLastTeleport(); UserManager.getPlayer(player).actualizeLastTeleport();
if (Config.getInstance().getStatsTrackingEnabled()) { if (Config.getInstance().getStatsTrackingEnabled()) {
MetricsManager.chimeraWingUsed(); MetricsManager.chimeraWingUsed();

View File

@@ -21,11 +21,7 @@ public final class HardcoreManager {
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
int totalLost = 0; int totalLost = 0;
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.isChildSkill()) {
continue;
}
int playerSkillLevel = playerProfile.getSkillLevel(skillType); int playerSkillLevel = playerProfile.getSkillLevel(skillType);
if (playerSkillLevel <= 0) { if (playerSkillLevel <= 0) {
@@ -52,11 +48,7 @@ public final class HardcoreManager {
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile(); PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
int totalStolen = 0; int totalStolen = 0;
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.isChildSkill()) {
continue;
}
int killerSkillLevel = killerProfile.getSkillLevel(skillType); int killerSkillLevel = killerProfile.getSkillLevel(skillType);
int victimSkillLevel = victimProfile.getSkillLevel(skillType); int victimSkillLevel = victimProfile.getSkillLevel(skillType);

View File

@@ -660,6 +660,6 @@ public class ItemUtils {
} }
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
} }
} }

View File

@@ -95,7 +95,7 @@ public final class Misc {
return false; return false;
} }
return first.distanceSquared(second) < (maxDistance * maxDistance); return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
} }
public static void dropItems(Location location, Collection<ItemStack> drops) { public static void dropItems(Location location, Collection<ItemStack> drops) {

View File

@@ -35,9 +35,9 @@ public final class MobHealthbarUtils {
/** /**
* Handle the creation of mob healthbars. * Handle the creation of mob healthbars.
* *
* @param profile The * @param player the attacking player
* @param target * @param target the targetted entity
* @param damage * @param damage damage done by the attack triggering this
*/ */
public static void handleMobHealthbars(Player player, LivingEntity target, int damage) { public static void handleMobHealthbars(Player player, LivingEntity target, int damage) {
if (!Permissions.mobHealthDisplay(player)) { if (!Permissions.mobHealthDisplay(player)) {
@@ -132,7 +132,7 @@ public final class MobHealthbarUtils {
return null; return null;
} }
int coloredDisplay = (int) (fullDisplay * (healthPercentage / 100.0D)); int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
int grayDisplay = fullDisplay - coloredDisplay; int grayDisplay = fullDisplay - coloredDisplay;
String healthbar = color + ""; String healthbar = color + "";

View File

@@ -11,11 +11,7 @@ public class StringUtils {
* @return the capitalized string * @return the capitalized string
*/ */
public static String getCapitalized(String target) { public static String getCapitalized(String target) {
String firstLetter = target.substring(0, 1); return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase();
String remainder = target.substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
return capitalized;
} }
/** /**
@@ -100,22 +96,6 @@ public class StringUtils {
} }
} }
/**
* Determine if a string represents a Long
*
* @param string String to check
* @return true if the string is a Long, false otherwise
*/
public static boolean isLong(String string) {
try {
Long.parseLong(string);
return true;
}
catch (NumberFormatException nFE) {
return false;
}
}
/** /**
* Determine if a string represents a Double * Determine if a string represents a Double
* *
@@ -131,5 +111,4 @@ public class StringUtils {
return false; return false;
} }
} }
} }

View File

@@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -46,7 +47,7 @@ public final class CommandUtils {
} }
public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) {
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !hasPermission) { if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), Config.getInstance().getInspectDistance()) && !hasPermission) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true; return true;
} }

View File

@@ -182,8 +182,8 @@ public class ScoreboardManager {
PlayerProfile profile = mcMMOPlayer.getProfile(); PlayerProfile profile = mcMMOPlayer.getProfile();
Server server = mcMMO.p.getServer(); Server server = mcMMO.p.getServer();
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) { if (!Permissions.skillEnabled(player, skill)) {
continue; continue;
} }
@@ -201,8 +201,8 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName); Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) { if (!Permissions.skillEnabled(player, skill)) {
continue; continue;
} }
@@ -228,11 +228,7 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName); Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill()) {
continue;
}
rank = skills.get(skill.name()); rank = skills.get(skill.name());
if (rank != null) { if (rank != null) {
@@ -257,8 +253,8 @@ public class ScoreboardManager {
int powerLevel = 0; int powerLevel = 0;
int skillLevel; int skillLevel;
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) { if (!Permissions.skillEnabled(target, skill)) {
continue; continue;
} }
@@ -277,11 +273,7 @@ public class ScoreboardManager {
int powerLevel = 0; int powerLevel = 0;
int skillLevel; int skillLevel;
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.nonChildSkills()) {
if (skill.isChildSkill()) {
continue;
}
skillLevel = targetProfile.getSkillLevel(skill); skillLevel = targetProfile.getSkillLevel(skill);
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel); objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
powerLevel += skillLevel; powerLevel += skillLevel;

View File

@@ -15,7 +15,6 @@ import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@@ -24,6 +23,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask; import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
@@ -381,47 +381,40 @@ public final class CombatUtils {
*/ */
public static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, SkillType type) { public static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, SkillType type) {
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
int damageAmount = damage; int damageAmount = Math.max(damage, 1);
if (damageAmount < 1) { while (numberOfTargets > 0) {
damageAmount = 1; for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
} if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
continue;
}
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) { LivingEntity livingEntity = (LivingEntity) entity;
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) { mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(attacker));
continue;
switch (type) {
case SWORDS:
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
}
BleedTimerTask.add(livingEntity, Swords.serratedStrikesBleedTicks);
break;
case AXES:
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
}
break;
default:
break;
}
dealDamage(livingEntity, damageAmount, attacker);
numberOfTargets--;
} }
if (numberOfTargets <= 0) {
break;
}
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
switch (type) {
case SWORDS:
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
}
BleedTimerTask.add((LivingEntity) entity, Swords.serratedStrikesBleedTicks);
break;
case AXES:
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
}
break;
default:
break;
}
dealDamage((LivingEntity) entity, damageAmount, attacker);
numberOfTargets--;
} }
} }
@@ -541,7 +534,7 @@ public final class CombatUtils {
return false; return false;
} }
if (PartyManager.inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) { if (mcMMO.getPartyManager().inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
return false; return false;
} }
@@ -575,16 +568,11 @@ public final class CombatUtils {
* @return true if the entity is invincible, false otherwise * @return true if the entity is invincible, false otherwise
*/ */
public static boolean isInvincible(LivingEntity entity, int eventDamage) { public static boolean isInvincible(LivingEntity entity, int eventDamage) {
/* /*
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility. * So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
* So yeah, this is for that. * So yeah, this is for that.
*/ */
if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) { return (entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage());
return true;
}
return false;
} }
/** /**
@@ -601,7 +589,7 @@ public final class CombatUtils {
if (tamer instanceof Player) { if (tamer instanceof Player) {
Player owner = (Player) tamer; Player owner = (Player) tamer;
if (owner == attacker || PartyManager.inSameParty(attacker, owner)) { if (owner == attacker || mcMMO.getPartyManager().inSameParty(attacker, owner)) {
return true; return true;
} }
} }
@@ -611,15 +599,6 @@ public final class CombatUtils {
} }
public static boolean shouldProcessSkill(Entity target, SkillType skill) { public static boolean shouldProcessSkill(Entity target, SkillType skill) {
boolean process; return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? skill.getPVPEnabled() : skill.getPVEEnabled();
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
process = skill.getPVPEnabled();
}
else {
process = skill.getPVEEnabled();
}
return process;
} }
} }

View File

@@ -55,25 +55,6 @@ public class SkillUtils {
return currentFoodLevel + foodChange; return currentFoodLevel + foodChange;
} }
/**
* Checks to see if the cooldown for an item or ability is expired.
*
* @param oldTime The time the ability or item was last used
* @param cooldown The amount of time that must pass between uses
* @param player The player whose cooldown is being checked
* @return true if the cooldown is over, false otherwise
*/
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
long currentTime = System.currentTimeMillis();
int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown);
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
return true;
}
return false;
}
/** /**
* Calculate the time remaining until the cooldown expires. * Calculate the time remaining until the cooldown expires.
* *
@@ -96,15 +77,14 @@ public class SkillUtils {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
ItemStack inHand = player.getItemInHand(); ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) { if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
return; return;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.getAbilityUse()) { if (!mcMMOPlayer.getAbilityUse()) {
return; return;
} }
@@ -116,6 +96,8 @@ public class SkillUtils {
} }
PlayerProfile playerProfile = mcMMOPlayer.getProfile(); PlayerProfile playerProfile = mcMMOPlayer.getProfile();
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
/* /*
* Woodcutting & Axes need to be treated differently. * Woodcutting & Axes need to be treated differently.
@@ -123,8 +105,10 @@ public class SkillUtils {
*/ */
if (ability.getPermissions(player) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) { if (ability.getPermissions(player) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { int timeRemaining = calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return; return;
} }
} }
@@ -202,11 +186,7 @@ public class SkillUtils {
return isLocalizedSkill(skillName); return isLocalizedSkill(skillName);
} }
if (SkillType.getSkill(skillName) != null) { return SkillType.getSkill(skillName) != null;
return true;
}
return false;
} }
private static boolean isLocalizedSkill(String skillName) { private static boolean isLocalizedSkill(String skillName) {
@@ -234,15 +214,11 @@ public class SkillUtils {
* @return true if the player has combat skills, false otherwise * @return true if the player has combat skills, false otherwise
*/ */
public static boolean hasCombatSkills(Player player) { public static boolean hasCombatSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.AXES) return Permissions.skillEnabled(player, SkillType.AXES)
|| Permissions.skillEnabled(player, SkillType.ARCHERY) || Permissions.skillEnabled(player, SkillType.ARCHERY)
|| Permissions.skillEnabled(player, SkillType.SWORDS) || Permissions.skillEnabled(player, SkillType.SWORDS)
|| Permissions.skillEnabled(player, SkillType.TAMING) || Permissions.skillEnabled(player, SkillType.TAMING)
|| Permissions.skillEnabled(player, SkillType.UNARMED)) { || Permissions.skillEnabled(player, SkillType.UNARMED);
return true;
}
return false;
} }
/** /**
@@ -252,15 +228,11 @@ public class SkillUtils {
* @return true if the player has gathering skills, false otherwise * @return true if the player has gathering skills, false otherwise
*/ */
public static boolean hasGatheringSkills(Player player) { public static boolean hasGatheringSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.EXCAVATION) return Permissions.skillEnabled(player, SkillType.EXCAVATION)
|| Permissions.skillEnabled(player, SkillType.FISHING) || Permissions.skillEnabled(player, SkillType.FISHING)
|| Permissions.skillEnabled(player, SkillType.HERBALISM) || Permissions.skillEnabled(player, SkillType.HERBALISM)
|| Permissions.skillEnabled(player, SkillType.MINING) || Permissions.skillEnabled(player, SkillType.MINING)
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING)) { || Permissions.skillEnabled(player, SkillType.WOODCUTTING);
return true;
}
return false;
} }
/** /**
@@ -270,13 +242,9 @@ public class SkillUtils {
* @return true if the player has misc skills, false otherwise * @return true if the player has misc skills, false otherwise
*/ */
public static boolean hasMiscSkills(Player player) { public static boolean hasMiscSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.ACROBATICS) return Permissions.skillEnabled(player, SkillType.ACROBATICS)
|| Permissions.skillEnabled(player, SkillType.SMELTING) || Permissions.skillEnabled(player, SkillType.SMELTING)
|| Permissions.skillEnabled(player, SkillType.REPAIR)) { || Permissions.skillEnabled(player, SkillType.REPAIR);
return true;
}
return false;
} }
/** /**
@@ -294,18 +262,20 @@ public class SkillUtils {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
PlayerProfile playerProfile = mcMMOPlayer.getProfile(); PlayerProfile playerProfile = mcMMOPlayer.getProfile();
int timeRemaining = calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
/* /*
* Axes and Woodcutting are odd because they share the same tool. * Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action. * We show them the too tired message when they take action.
*/ */
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) { if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player))); player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return; return;
} }
} }
if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) { if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining <= 0) {
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, type); McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, type);
mcMMO.p.getServer().getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -347,6 +317,7 @@ public class SkillUtils {
switch (ability) { switch (ability) {
case BERSERK: case BERSERK:
case BLOCK_CRACKER:
case LEAF_BLOWER: case LEAF_BLOWER:
if (!ability.blockCheck(block.getState())) { if (!ability.blockCheck(block.getState())) {
activate = false; activate = false;
@@ -505,11 +476,7 @@ public class SkillUtils {
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player); FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
pluginManger.callEvent(breakEvent); pluginManger.callEvent(breakEvent);
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) { return !damageEvent.isCancelled() && !breakEvent.isCancelled();
return true;
}
return false;
} }
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) { public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {

View File

@@ -204,11 +204,7 @@ public class SpoutUtils {
} }
// Standard XP Icons // Standard XP Icons
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.isChildSkill()) {
continue;
}
String skillName = StringUtils.getCapitalized(skillType.toString()); String skillName = StringUtils.getCapitalized(skillType.toString());
files.add(writeFile(skillName + ".png", hudStandardDirectory)); files.add(writeFile(skillName + ".png", hudStandardDirectory));

View File

@@ -43,7 +43,6 @@ Skills:
GracefulRoll_ChanceMax: 100.0 GracefulRoll_ChanceMax: 100.0
GracefulRoll_MaxBonusLevel: 500 GracefulRoll_MaxBonusLevel: 500
GracefulRoll_DamageThreshold: 14 GracefulRoll_DamageThreshold: 14
GracefulRoll_SuccessModifier: 2
# Amount of experience for performing a dodge, roll or fall # Amount of experience for performing a dodge, roll or fall
Dodge_XP_Modifier: 120 Dodge_XP_Modifier: 120

View File

@@ -56,9 +56,9 @@ Scoreboards:
Skillname: Skillname:
Use: true Use: true
Display_Time: 10 Display_Time: 10
# Should mcMMO display power levels on scoreboards? # Should mcMMO display power levels on scoreboards? (below player name-tags)
Power_Level: Power_Level:
Use: true Use: false
Mob_Healthbar: Mob_Healthbar:
# Default display for mob health bars - HEARTS, BAR, or DISABLED # Default display for mob health bars - HEARTS, BAR, or DISABLED
@@ -394,6 +394,8 @@ Experience:
Commands: Commands:
mcmmo: mcmmo:
Donate_Message: true Donate_Message: true
inspect:
Max_Distance: 30
ptp: ptp:
Cooldown: 120 Cooldown: 120
Warmup: 5 Warmup: 5

View File

@@ -497,7 +497,7 @@ Commands.Reset.Single=[[GREEN]]Your {0} skill level has been reset successfully.
Commands.Reset=[[RED]]Reset a skill's level to 0 Commands.Reset=[[RED]]Reset a skill's level to 0
Commands.Skill.Invalid=[[RED]]That is not a valid skillname! Commands.Skill.Invalid=[[RED]]That is not a valid skillname!
Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard-- Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
Commands.SkillInfo=/<skill> [[RED]]- View detailed information about a skill Commands.SkillInfo=[[RED]]- View detailed information about a skill
Commands.Stats.Self=YOUR STATS Commands.Stats.Self=YOUR STATS
Commands.Stats=[[RED]]- View your mcMMO stats Commands.Stats=[[RED]]- View your mcMMO stats
Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click
@@ -659,7 +659,7 @@ Skills.Parents = PARENTS
Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]]) Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]])
Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s) Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
Skills.Cancelled=[[RED]]{0} cancelled! Skills.Cancelled=[[RED]]{0} cancelled!
Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0} [[GREEN]]. Left-click to cancel. Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0}[[GREEN]]. Left-click to cancel.
#STATISTICS #STATISTICS
Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=- Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=-