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

Compare commits

..

39 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
73 changed files with 789 additions and 615 deletions

View File

@@ -46,6 +46,8 @@ Version 1.4.06-dev
= Fixed bug with removing players from mySQL database
= Fixed bug with empty metadata lists and Smelting
= 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 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)

View File

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

View File

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

View File

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

View File

@@ -119,7 +119,7 @@ public final class ExperienceAPI {
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;
PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
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
*/
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.
*/
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
*/
public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName);
Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) {
party = new Party();
@@ -84,7 +84,7 @@ public final class PartyAPI {
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
*/
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
*/
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
*/
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) {
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);
members.add(member);
}
@@ -150,7 +150,7 @@ public final class PartyAPI {
* @return all the player names in the player's party
*/
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
*/
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
*/
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;
public final class ChatManager {
public ChatManager () {}
public ChatManager() {}
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean 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) {
if (Permissions.party(sender)) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
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 quit " + LocaleLoader.getString("Commands.Party.Quit"));
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 quit " + LocaleLoader.getString("Commands.Party.Quit"));
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 accept " + LocaleLoader.getString("Commands.Party.Accept"));
sender.sendMessage(" /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage(" /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
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) {
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
sender.sendMessage(" /mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage(" /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
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)) {
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
sender.sendMessage(" /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (Permissions.adminChat(sender)) {
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
sender.sendMessage(" /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.inspect(sender)) {
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
sender.sendMessage(" /inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.mmoedit(sender)) {
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
sender.sendMessage(" /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
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;
}
Party party = PartyManager.getParty(args[0]);
Party party = mcMMO.getPartyManager().getParty(args[0]);
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
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.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -17,22 +17,20 @@ public class PartyCreateCommand implements CommandExecutor {
switch (args.length) {
case 2:
case 3:
Party newParty = PartyManager.getParty(args[1]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
Player player = mcMMOPlayer.getPlayer();
// 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;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
return true;
}
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
mcMMO.getPartyManager().createParty(player, args[1], getPassword(args));
return true;
default:

View File

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

View File

@@ -104,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
}
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;
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.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -32,14 +33,14 @@ public class PartyInviteCommand implements CommandExecutor {
return true;
}
if (PartyManager.inSameParty(player, target)) {
if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.canInvite(player, playerParty)) {
if (!mcMMO.getPartyManager().canInvite(player)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}

View File

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

View File

@@ -30,14 +30,14 @@ public class PartyKickCommand implements CommandExecutor {
Player onlineTarget = target.getPlayer();
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;
}
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(target, playerParty);
mcMMO.getPartyManager().removeFromParty(target, playerParty);
return true;
default:

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -19,11 +20,11 @@ public class PartyQuitCommand implements CommandExecutor {
Player player = (Player) sender;
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;
}
PartyManager.removeFromParty(player, playerParty);
mcMMO.getPartyManager().removeFromParty(player, playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
@@ -30,17 +31,16 @@ public class PartyRenameCommand implements CommandExecutor {
}
Player player = mcMMOPlayer.getPlayer();
Party newParty = PartyManager.getParty(newPartyName);
// 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;
}
String leaderName = playerParty.getLeader();
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;
}

View File

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

View File

@@ -20,7 +20,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */
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 */
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 int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
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 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 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 */
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 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
*/
@@ -294,5 +297,5 @@ public class Config extends AutoUpdateConfigLoader {
/* XP Formula Multiplier */
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;
try {
outputStream = new FileOutputStream(configFile);
outputStream = new FileOutputStream(configFile);
int read;
byte[] bytes = new byte[1024];

View File

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

View File

@@ -151,6 +151,7 @@ public final class SQLDatabaseManager {
checkDatabaseStructure(DatabaseUpdateType.INDEX);
checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS);
checkDatabaseStructure(DatabaseUpdateType.PARTY_NAMES);
checkDatabaseStructure(DatabaseUpdateType.KILL_ORPHANS);
}
/**
@@ -414,11 +415,7 @@ public final class SQLDatabaseManager {
if (checkConnected()) {
try {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = skillType.name().toLowerCase();
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 " +
@@ -563,7 +560,7 @@ public final class SQLDatabaseManager {
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
}
break;
return;
case MOB_HEALTHBARS:
sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30";
@@ -571,7 +568,35 @@ public final class SQLDatabaseManager {
case PARTY_NAMES:
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
break;
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:
break;

View File

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

View File

@@ -94,7 +94,7 @@ public class McMMOPlayer {
this.player = player;
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),
@@ -441,11 +441,7 @@ public class McMMOPlayer {
public int getPowerLevel() {
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
}
@@ -513,7 +509,7 @@ public class McMMOPlayer {
return;
}
if (!Permissions.skillEnabled(player, skillType)) {
return;
}

View File

@@ -49,11 +49,7 @@ public class PlayerProfile {
skillsDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0F);
}
@@ -257,7 +253,7 @@ public class PlayerProfile {
* @return the Xp remaining until next level
*/
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) {
@@ -325,12 +321,17 @@ public class PlayerProfile {
"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 = e.user_id) " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"WHERE u.user = '" + playerName + "'"
).get(1);
// Should never happen but just in case
if (playerData == null || playerData.size() == 0) {
return false;
}
}
userId = Integer.valueOf(playerData.get(0));
@@ -374,8 +375,20 @@ public class PlayerProfile {
// Acrobatics 35 - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(playerData.get(36)));
hudType = HudType.valueOf(playerData.get(37));
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(38));
try {
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;
return true;

View File

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

View File

@@ -108,7 +108,7 @@ public enum SkillType {
}
public double getXpModifier() {
return Config.getInstance().getForumulaMultiplier(this);
return Config.getInstance().getFormulaSkillModifier(this);
}
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() {
return runescapeColor;
}
@@ -151,7 +170,7 @@ public enum SkillType {
return type;
}
}
return null;
}
}

View File

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

View File

@@ -14,7 +14,7 @@ public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
super(player, skill);
this.ability = skill.getAbility();
}
public AbilityType getAbility() {
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.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
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.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils;
@@ -72,9 +70,11 @@ public class BlockListener implements Listener {
}
for (Block b : blocks) {
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(b.getRelative(direction));
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin);
Block nextBlock = b.getRelative(direction);
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();
int blockId = blockState.getTypeId();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState);
}
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId);
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
}
}
@@ -323,41 +322,31 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getItemInHand();
Block block = event.getBlock();
BlockState blockState = block.getState();
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/*
* ABILITY TRIGGER CHECKS
*
* 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 (herbalismManager.processGreenTerra(blockState)) {
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
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 (heldItem.getType() == Material.AIR) {
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
event.setInstaBreak(true);
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 (BlockUtils.affectedByBlockCracker(blockState)) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
else if (Permissions.blockCracker(player) && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
}
else if (BlockUtils.isLeaves(blockState)) {
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);
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) {
ItemStack bow = event.getBow();
if (bow != null) {
Entity projectile = event.getProjectile();
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())));
}
if (bow == null) {
return;
}
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
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof FallingBlock)) {
@@ -107,7 +111,13 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
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;
}
@@ -117,13 +127,14 @@ public class EntityListener implements Listener {
return;
}
Entity attacker = event.getDamager();
LivingEntity target = (LivingEntity) defender;
if (CombatUtils.isInvincible(target, event.getDamage())) {
if (CombatUtils.isInvincible(target, damage)) {
return;
}
Entity attacker = event.getDamager();
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
}
@@ -144,7 +155,7 @@ public class EntityListener implements Listener {
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);
return;
}
@@ -160,7 +171,13 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
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;
}
@@ -170,13 +187,14 @@ public class EntityListener implements Listener {
return;
}
DamageCause cause = event.getCause();
LivingEntity livingEntity = (LivingEntity) entity;
if (CombatUtils.isInvincible(livingEntity, event.getDamage())) {
if (CombatUtils.isInvincible(livingEntity, damage)) {
return;
}
DamageCause cause = event.getCause();
if (livingEntity instanceof Player) {
Player player = (Player) entity;
@@ -309,7 +327,6 @@ public class EntityListener implements Listener {
return;
}
entity.setFireTicks(0);
BleedTimerTask.remove(entity);
Archery.arrowRetrievalCheck(entity);
}
@@ -348,19 +365,21 @@ public class EntityListener implements Listener {
public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
if (Misc.isNPCEntity(player)) {
return;
}
// We can make this assumption because we (should) be the only ones using this exact metadata
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()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
}
}
@@ -373,20 +392,22 @@ public class EntityListener implements Listener {
public void onEnitityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
if (Misc.isNPCEntity(player)) {
return;
}
// We can make this assumption because we (should) be the only ones using this exact metadata
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.blastMiningDropProcessing(event.getYield(), event.blockList());
event.setYield(0);
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
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) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
if (!(entity instanceof Player)) {
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;
}
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
int foodChange = newFoodLevel - currentFoodLevel;
if (foodChange <= 0) {
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
}
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;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
if (Permissions.fishermansDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
}
return;
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, 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;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
if (Permissions.fishermansDiet(player)) {
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;
}
default:
return;
}
}

View File

@@ -180,10 +180,10 @@ public class PlayerListener implements Listener {
case FISHING:
if (!Permissions.krakenBypass(player)) {
event.setCancelled(fishingManager.exploitPrevention());
}
if (event.isCancelled()) {
return;
if (event.isCancelled()) {
return;
}
}
if (fishingManager.canMasterAngler()) {
@@ -209,7 +209,7 @@ public class PlayerListener implements Listener {
case IN_GROUND:
Fish hook = event.getHook();
Block block = hook.getLocation().getBlock();
Block block = event.getPlayer().getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) {
event.setCancelled(true);
@@ -355,7 +355,7 @@ public class PlayerListener implements Listener {
}
}
/* 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();
event.setCancelled(true);

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
@@ -19,8 +18,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
public class WorldListener implements Listener {
private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
private final mcMMO plugin;
public WorldListener(final mcMMO plugin) {
@@ -34,12 +32,12 @@ public class WorldListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
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()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
}
@@ -51,9 +49,8 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
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;
}

View File

@@ -57,6 +57,7 @@ public class mcMMO extends JavaPlugin {
private static ChunkManager placeStore;
private static RepairableManager repairableManager;
private static DatabaseManager databaseManager;
private static PartyManager partyManager;
/* File Paths */
private static String mainDirectory;
@@ -114,7 +115,7 @@ public class mcMMO extends JavaPlugin {
registerEvents();
registerCustomRecipes();
PartyManager.loadParties();
partyManager = new PartyManager(this);
for (Player player : getServer().getOnlinePlayers()) {
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() {
try {
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.cleanUp(); // Cleanup empty metadata stores
}
@@ -235,6 +236,10 @@ public class mcMMO extends JavaPlugin {
return repairableManager;
}
public static PartyManager getPartyManager() {
return partyManager;
}
public static boolean isSpoutEnabled() {
return spoutEnabled;
}

View File

@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
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.player.UserManager;
public final class PartyManager {
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
private static List<Party> parties = new ArrayList<Party>();
private static File partyFile = new File(partiesFilePath);
public class PartyManager {
private final mcMMO plugin;
private final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
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) {
if (party == null) {
loadParties();
}
public boolean checkPartyExistence(Player player, String partyName) {
if (getParty(partyName) == null) {
return false;
}
@@ -34,8 +40,12 @@ public final class PartyManager {
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()) {
Party oldParty = mcMMOPlayer.getParty();
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false;
}
@@ -56,7 +66,7 @@ public final class PartyManager {
* @param secondPlayer The second player
* @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 secondMcMMOPlayer = UserManager.getPlayer(secondPlayer);
@@ -81,15 +91,20 @@ public final class PartyManager {
* @param range The distance
* @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>();
Party party = UserManager.getPlayer(player).getParty();
if (party != null) {
Location playerLocation = player.getLocation();
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);
}
}
}
return nearMembers;
}
@@ -99,9 +114,7 @@ public final class PartyManager {
* @param player The player to check
* @return all the players in the player's party
*/
public static LinkedHashSet<String> getAllMembers(Player player) {
Party party = UserManager.getPlayer(player).getParty();
public LinkedHashSet<String> getAllMembers(Party party) {
if (party == null) {
return null;
}
@@ -115,7 +128,7 @@ public final class PartyManager {
* @param partyName The party to check
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(String partyName) {
public List<Player> getOnlineMembers(String partyName) {
Party party = getParty(partyName);
if (party == null) {
@@ -125,29 +138,13 @@ public final class PartyManager {
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
*
* @param partyName The party name
* @return the existing party, null otherwise
*/
public static Party getParty(String partyName) {
public Party getParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return party;
@@ -163,7 +160,7 @@ public final class PartyManager {
* @param playerName The member name
* @return the existing party, null otherwise
*/
public static Party getPlayerParty(String playerName) {
public Party getPlayerParty(String playerName) {
for (Party party : parties) {
for (String memberName : party.getMembers()) {
if (memberName.equalsIgnoreCase(playerName)) {
@@ -180,7 +177,7 @@ public final class PartyManager {
*
* @return the list of parties.
*/
public static List<Party> getParties() {
public List<Party> getParties() {
return parties;
}
@@ -190,7 +187,7 @@ public final class PartyManager {
* @param player The player to remove
* @param party The party
*/
public static void removeFromParty(OfflinePlayer player, Party party) {
public void removeFromParty(OfflinePlayer player, Party party) {
LinkedHashSet<String> members = party.getMembers();
members.remove(player.getName());
@@ -201,20 +198,13 @@ public final class PartyManager {
else {
// If the leaving player was the party leader, appoint a new leader from the party members
if (party.getLeader().equalsIgnoreCase(player.getName())) {
String newLeader = members.iterator().next();
party.setLeader(newLeader);
party.setLeader(members.iterator().next());
}
informPartyMembersQuit(player, party);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player.getName());
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
processPlayerLeaving(UserManager.getPlayer(player));
}
/**
@@ -222,17 +212,11 @@ public final class PartyManager {
*
* @param party The party to remove
*/
public static void disbandParty(Party party) {
public void disbandParty(Party party) {
LinkedHashSet<String> members = party.getMembers();
for (String memberName : members) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(memberName);
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
processPlayerLeaving(UserManager.getPlayer(memberName));
}
members.clear();
@@ -243,11 +227,10 @@ public final class PartyManager {
* Create a new 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 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(".", "");
Party party = getParty(partyName);
@@ -271,7 +254,7 @@ public final class PartyManager {
}
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 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)) {
return;
}
if (mcMMOPlayer.getParty() == party) {
return;
}
// // Pretty sure this isn't possible.
// if (mcMMOPlayer.getParty() == party) {
// return;
// }
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
* @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
if (party.isLocked()) {
String partyPassword = party.getPassword();
@@ -333,20 +317,22 @@ public final class PartyManager {
* @param Player The plaer 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();
if (mcMMOPlayer.getParty() == invite) {
return;
}
if (!parties.contains(invite)) {
parties.add(invite);
}
// // Pretty sure this isn't possible
// if (!parties.contains(invite)) {
// parties.add(invite);
// }
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
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 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) {
return;
}
if (!parties.contains(party)) {
parties.add(party);
}
informPartyMembersJoin(player, party);
mcMMOPlayer.setParty(party);
@@ -373,7 +365,7 @@ public final class PartyManager {
* @param partyName The party name
* @return the leader of the party
*/
public static String getPartyLeader(String partyName) {
public String getPartyLeader(String partyName) {
Party party = getParty(partyName);
if (party == null) {
@@ -389,7 +381,7 @@ public final class PartyManager {
* @param playerName The name of the player to set as leader
* @param party The party
*/
public static void setPartyLeader(String playerName, Party party) {
public void setPartyLeader(String playerName, Party party) {
String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) {
@@ -414,7 +406,9 @@ public final class PartyManager {
* @param mcMMOPlayer The player to check
* @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())) {
return false;
}
@@ -422,26 +416,10 @@ public final class PartyManager {
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.
*/
public static void loadParties() {
private void loadParties() {
if (!partyFile.exists()) {
return;
}
@@ -472,7 +450,7 @@ public final class PartyManager {
/**
* Save party file.
*/
public static void saveParties() {
public void saveParties() {
if (partyFile.exists()) {
partyFile.delete();
}
@@ -516,7 +494,7 @@ public final class PartyManager {
* @param reason The reason for changing parties
* @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);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -529,7 +507,7 @@ public final class PartyManager {
* @param player The player that joins
* @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()) {
if (!member.equals(player)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
@@ -543,11 +521,21 @@ public final class PartyManager {
* @param player The player that quits
* @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()) {
if (!member.equals(player)) {
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.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.datatypes.party.ItemShareType;
@@ -53,12 +54,10 @@ public final class ShareHandler {
* @return True is the xp has been shared
*/
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
Party party = mcMMOPlayer.getParty();
switch (party.getXpShareMode()) {
switch (mcMMOPlayer.getParty().getXpShareMode()) {
case EQUAL:
Player player = mcMMOPlayer.getPlayer();
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;
@@ -112,7 +111,7 @@ public final class ShareHandler {
switch (party.getItemShareMode()) {
case EQUAL:
McMMOPlayer mcMMOTarget;
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;
@@ -159,7 +158,7 @@ public final class ShareHandler {
return true;
case RANDOM:
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;

View File

@@ -19,6 +19,6 @@ public class SaveTimerTask extends BukkitRunnable {
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.Player", playerName));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (player != null && !Permissions.skillEnabled(player, skill)) {
continue;
}

View File

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

View File

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

View File

@@ -27,7 +27,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
long currentTime = System.currentTimeMillis();
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();
for (String memberName : party.getMembers()) {
@@ -44,7 +44,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
}
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.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AbilityDisableTask extends BukkitRunnable {
@@ -59,6 +60,6 @@ public class AbilityDisableTask extends BukkitRunnable {
}
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 gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
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);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) {
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -103,7 +103,7 @@ public class AcrobaticsManager extends SkillManager {
private int gracefulRollCheck(int damage) {
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"));
applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -116,8 +116,8 @@ public class AcrobaticsManager extends SkillManager {
return damage;
}
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
}
private boolean isFatal(int damage) {

View File

@@ -19,44 +19,42 @@ public class ChildConfig extends AutoUpdateConfigLoader {
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
plugin.debug("Finding parents of " + skill.name());
for (SkillType skill : SkillType.childSkills()) {
plugin.debug("Finding parents of " + skill.name());
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
for (String name : parentNames) {
try {
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
FamilyTree.enforceNotChildSkill(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;
}
for (String name : parentNames) {
try {
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
}
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
/* 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()));
}
catch (IllegalArgumentException ex) {
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
useDefaults = true;
break;
}
}
// Register them
for (SkillType parentSkill : parentSkills) {
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
FamilyTree.registerParent(skill, parentSkill);
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
/* 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();

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
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.ShakeTreasure;
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.runnables.skills.KrakenAttackTask;
import com.gmail.nossr50.skills.SkillManager;
@@ -138,12 +143,12 @@ public class FishingManager extends SkillManager {
}
public boolean exploitPrevention() {
if (!AdvancedConfig.getInstance().getKrakenEnabled()) {
if (!AdvancedConfig.getInstance().getKrakenEnabled() || !getPlayer().getTargetBlock(null, 100).isLiquid()) {
return false;
}
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);
fishingTimestamp = currentTime;
@@ -219,7 +224,7 @@ public class FishingManager extends SkillManager {
// Make a hole
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++) {
Block relative = block.getRelative(x, 0, z);
@@ -269,13 +274,43 @@ public class FishingManager extends SkillManager {
treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
McMMOPlayerFishingTreasureEvent event;
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
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
if (treasureDrop != null) {
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);
@@ -351,6 +386,14 @@ public class FishingManager extends SkillManager {
break;
}
McMMOPlayerShakeEvent event = new McMMOPlayerShakeEvent(getPlayer(), drop);
drop = event.getDrop();
if (event.isCancelled() || drop == null) {
return;
}
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.
}
@@ -399,7 +442,7 @@ public class FishingManager extends SkillManager {
* @param treasureDrop The {@link ItemStack} to enchant
* @return true if the item has been enchanted
*/
private boolean handleMagicHunter(ItemStack treasureDrop) {
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer();
int activationChance = this.activationChance;
@@ -407,8 +450,10 @@ public class FishingManager extends SkillManager {
activationChance *= Fishing.STORM_MODIFIER;
}
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
return false;
return enchants;
}
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
Collections.shuffle(possibleEnchantments, Misc.getRandom());
boolean enchanted = false;
int specificChance = 1;
for (Enchantment possibleEnchantment : possibleEnchantments) {
@@ -424,13 +468,12 @@ public class FishingManager extends SkillManager {
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++;
enchanted = true;
}
return enchanted;
return enchants;
}
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.skills.SkillUtils;
public class MiningManager extends SkillManager{
public class MiningManager extends SkillManager {
public MiningManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING);
}
@@ -109,7 +109,7 @@ public class MiningManager extends SkillManager{
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
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;
int cooldown = AbilityType.BLAST_MINING.getCooldown();
int timeRemaining = SkillUtils.calculateTimeLeft(oldTime, cooldown, player);
if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player)));
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return false;
}

View File

@@ -195,7 +195,7 @@ public class RepairManager extends SkillManager {
Player player = getPlayer();
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
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();
if (dropAmount + itemAmount <= itemMax) {
if (dropAmount + itemAmount <= itemMax) {
drop.remove();
addStack.setAmount(dropAmount + itemAmount);
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.NetherWarts;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.repair.Repair;
public final class BlockUtils {
private BlockUtils() {}
@@ -306,9 +306,9 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check
* @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();
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
*/
public static void activationCheck(Player player) {
if (!Config.getInstance().getChimaeraEnabled()) {
return;
}
ItemStack inHand = player.getItemInHand();
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) {
if (!ItemUtils.isChimaeraWing(inHand)) {
return;
}
@@ -48,36 +52,48 @@ public final class ChimaeraWing {
mcMMOPlayer = UserManager.getPlayer(player);
location = player.getLocation();
int amount = inHand.getAmount();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
long lastTeleport = mcMMOPlayer.getLastTeleport();
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
return;
}
if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) {
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;
}
int amount = inHand.getAmount();
if (amount < Config.getInstance().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
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 (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0));
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10));
mcMMOPlayer.actualizeLastTeleport();
@@ -115,6 +131,7 @@ public final class ChimaeraWing {
}
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.updateInventory();
UserManager.getPlayer(player).actualizeLastTeleport();
if (Config.getInstance().getStatsTrackingEnabled()) {
MetricsManager.chimeraWingUsed();

View File

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

View File

@@ -660,6 +660,6 @@ public class ItemUtils {
}
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 first.distanceSquared(second) < (maxDistance * maxDistance);
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
}
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.
*
* @param profile The
* @param target
* @param damage
* @param player the attacking player
* @param target the targetted entity
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(Player player, LivingEntity target, int damage) {
if (!Permissions.mobHealthDisplay(player)) {
@@ -132,7 +132,7 @@ public final class MobHealthbarUtils {
return null;
}
int coloredDisplay = (int) (fullDisplay * (healthPercentage / 100.0D));
int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
int grayDisplay = fullDisplay - coloredDisplay;
String healthbar = color + "";

View File

@@ -11,11 +11,7 @@ public class StringUtils {
* @return the capitalized string
*/
public static String getCapitalized(String target) {
String firstLetter = target.substring(0, 1);
String remainder = target.substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
return capitalized;
return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase();
}
/**
@@ -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
*
@@ -131,5 +111,4 @@ public class StringUtils {
return false;
}
}
}

View File

@@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
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) {
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"));
return true;
}

View File

@@ -182,8 +182,8 @@ public class ScoreboardManager {
PlayerProfile profile = mcMMOPlayer.getProfile();
Server server = mcMMO.p.getServer();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@@ -201,8 +201,8 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@@ -228,11 +228,7 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
rank = skills.get(skill.name());
if (rank != null) {
@@ -257,8 +253,8 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(target, skill)) {
continue;
}
@@ -277,11 +273,7 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skillLevel = targetProfile.getSkillLevel(skill);
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(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.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
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.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
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) {
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) {
damageAmount = 1;
}
while (numberOfTargets > 0) {
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)) {
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
continue;
LivingEntity livingEntity = (LivingEntity) entity;
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(attacker));
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;
}
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;
}
@@ -575,16 +568,11 @@ public final class CombatUtils {
* @return true if the entity is invincible, false otherwise
*/
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 yeah, this is for that.
*/
if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) {
return true;
}
return false;
return (entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage());
}
/**
@@ -601,7 +589,7 @@ public final class CombatUtils {
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner == attacker || PartyManager.inSameParty(attacker, owner)) {
if (owner == attacker || mcMMO.getPartyManager().inSameParty(attacker, owner)) {
return true;
}
}
@@ -611,15 +599,6 @@ public final class CombatUtils {
}
public static boolean shouldProcessSkill(Entity target, SkillType skill) {
boolean process;
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
process = skill.getPVPEnabled();
}
else {
process = skill.getPVEEnabled();
}
return process;
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? skill.getPVPEnabled() : skill.getPVEEnabled();
}
}

View File

@@ -55,25 +55,6 @@ public class SkillUtils {
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.
*
@@ -96,15 +77,14 @@ public class SkillUtils {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.getAbilityUse()) {
return;
}
@@ -116,6 +96,8 @@ public class SkillUtils {
}
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
/*
* 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 (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(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)));
int timeRemaining = 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;
}
}
@@ -202,11 +186,7 @@ public class SkillUtils {
return isLocalizedSkill(skillName);
}
if (SkillType.getSkill(skillName) != null) {
return true;
}
return false;
return SkillType.getSkill(skillName) != null;
}
private static boolean isLocalizedSkill(String skillName) {
@@ -234,15 +214,11 @@ public class SkillUtils {
* @return true if the player has combat skills, false otherwise
*/
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.SWORDS)
|| Permissions.skillEnabled(player, SkillType.TAMING)
|| Permissions.skillEnabled(player, SkillType.UNARMED)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.UNARMED);
}
/**
@@ -252,15 +228,11 @@ public class SkillUtils {
* @return true if the player has gathering skills, false otherwise
*/
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.HERBALISM)
|| Permissions.skillEnabled(player, SkillType.MINING)
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING);
}
/**
@@ -270,13 +242,9 @@ public class SkillUtils {
* @return true if the player has misc skills, false otherwise
*/
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.REPAIR)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.REPAIR);
}
/**
@@ -294,18 +262,20 @@ public class SkillUtils {
Player player = mcMMOPlayer.getPlayer();
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.
* We show them the too tired message when they take action.
*/
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(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;
}
}
if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) {
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining <= 0) {
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, type);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -347,6 +317,7 @@ public class SkillUtils {
switch (ability) {
case BERSERK:
case BLOCK_CRACKER:
case LEAF_BLOWER:
if (!ability.blockCheck(block.getState())) {
activate = false;
@@ -505,11 +476,7 @@ public class SkillUtils {
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
pluginManger.callEvent(breakEvent);
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
return true;
}
return false;
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
}
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {

View File

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

View File

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

View File

@@ -56,9 +56,9 @@ Scoreboards:
Skillname:
Use: true
Display_Time: 10
# Should mcMMO display power levels on scoreboards?
# Should mcMMO display power levels on scoreboards? (below player name-tags)
Power_Level:
Use: true
Use: false
Mob_Healthbar:
# Default display for mob health bars - HEARTS, BAR, or DISABLED
@@ -394,6 +394,8 @@ Experience:
Commands:
mcmmo:
Donate_Message: true
inspect:
Max_Distance: 30
ptp:
Cooldown: 120
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.Skill.Invalid=[[RED]]That is not a valid skillname!
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=[[RED]]- View your mcMMO stats
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.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
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
Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=-