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

Compare commits

...

44 Commits

Author SHA1 Message Date
TfT_02
d407f85704 Update pom.xml and changelog.txt for 1.4.08 release 2014-03-29 17:06:01 +01:00
TfT_02
458dc7db42 Make database command cooldown configurable 2014-03-29 17:02:08 +01:00
TfT_02
beab794c0e Fixed some issues with the HolidayManager
Was severely lacking more lols
2014-03-29 16:52:41 +01:00
TfT_02
8256f5461c Using an axe is required to earn Woodcutting XP
Not really sure why or when this check had gone missing..
2014-03-26 09:52:59 +01:00
TfT_02
0fe3ad7432 Reworked COTW config options + made COTW item configurable
Adresses #1481 partially
2014-03-23 14:33:57 +01:00
TfT_02
04e5dda127 Actually fix Repair lucky perk with Arcane Forging downgrade chance 2014-03-23 14:33:57 +01:00
TfT_02
f65adea2f9 Added minimum jump strength requirement and config option
for horses summoned with "Call of the Wild"
2014-03-23 13:41:31 +01:00
TfT_02
cdfb0da5c9 Fixed bug where shift right clicking potion ingredients was broken 2014-03-23 12:59:43 +01:00
TfT_02
cfa3d34dff Fix important bug regarding pistons 2014-03-14 15:23:28 +01:00
TfT_02
01b7d4f742 Repair lucky perk should decrease the Arcane Forging downgrade chance,
instead of increasing it.
2014-03-14 15:16:22 +01:00
TfT_02
9a359bf42c We need to use event.getBlock() here
Fix my boo boo from previous commit
2014-03-11 13:33:54 +01:00
TfT_02
ebdf11300b We do need to use a runnable. 2014-03-10 20:51:52 +01:00
TfT_02
e1a8f02bce Make Acrobatics XP prevention cool down, after teleporting configurable
Adds #1906
2014-03-09 15:24:24 +01:00
TfT_02
862d38b587 Clean up all of the imports 2014-03-03 18:27:45 +01:00
GJ
2415767c06 Clean up imports. 2014-03-03 12:22:28 -05:00
GJ
aa59348a94 We only care about blocks that award XP.
Also, this fixes a possible issue where blocks changed by entities other than falling blocks could have been left as tracked even after they were destroyed.
2014-03-03 12:14:01 -05:00
GJ
9c925d3327 We can do this without needing a runnable. 2014-03-03 11:40:36 -05:00
GJ
30f7521a3a Handle healthbars even when skills are disabled. Fixes #1194 2014-03-03 10:29:14 -05:00
GJ
7b3869e385 Use .equals instead of deprecated ID method. 2014-03-03 09:24:24 -05:00
GJ
0e641f7c5b Clean up some of our metadata handling. 2014-03-03 08:48:16 -05:00
GJ
733d16cf35 Don't clone if it's null. Fixes #1894 2014-03-03 08:03:30 -05:00
TfT_02
833bc1b251 Fixed bug where disbanded parties could still see alliance chat 2014-02-28 22:41:47 +01:00
TfT_02
840f3d9382 Fix /party kick command 2014-02-28 22:32:09 +01:00
TfT_02
34d6d867f2 Prevent combat abilities from damaging allied players 2014-02-28 22:08:48 +01:00
TfT_02
e56d5a0454 Exclude vanished players from tab complete list
Part 2 of fixing #1745
2014-02-28 21:56:30 +01:00
TfT_02
53fdf750f4 Pretend like the player is offline when he is vanished
Part 1 of fixing #1745
2014-02-28 21:56:30 +01:00
TfT_02
f096e915cf Changed default amount of XP from mining Quartz Ore
#1886
2014-02-28 19:24:41 +01:00
GJ
ce59488e8e Add FakeEntityTameEvent to match expected behavior for an animal being tamed. 2014-02-28 12:04:00 -05:00
GJ
47db522cc1 Because Bukkit doesn't set this automatically with setTamed. Go figure. Fixes #1888 2014-02-28 11:50:36 -05:00
TfT_02
a2cac82cba Check if player has data key here as well
Fixes #272
2014-02-28 14:45:44 +01:00
GJ
2e74333eb7 Oops. 2014-02-28 08:40:00 -05:00
GJ
0056be2d5f Assorted cleanup. 2014-02-28 08:36:42 -05:00
TfT_02
1d7e034d5e Fix the updater 2014-02-27 22:26:58 +01:00
GJ
8deac175d1 Repair damaged user files. Fixes #1869 2014-02-22 09:52:36 -05:00
GJ
d0b766a2d3 Fixed bug with updating (very) old user data. 2014-02-21 11:38:22 -05:00
GJ
65692f2a83 Fixed bug with checking maximum durability of mod items. Fixes #1634 2014-02-20 12:43:11 -05:00
GJ
d0b0786284 Fixed exploit involving Call of The Wild. Fixes #1877 2014-02-20 11:50:56 -05:00
Luuk Jacobs
87ac1002de Fix potion datavalues for Splash poison II potions 2014-02-18 08:45:44 +01:00
TfT_02
c51fde7f1f Added new permission node to control who can check version number
Negate this permission node to hide the version number from /mcmmo and
motd
2014-02-17 16:31:59 +01:00
TfT_02
0a6735110f Get mod config file resources properly
Fixes #1870 for real
2014-02-16 23:32:14 +01:00
TfT_02
8a284c50a2 Rename mod files to type.default.yml
Fixes #1870
2014-02-16 23:08:22 +01:00
roblikescake
09431ef27c Check durability before repairMaterial 2014-02-16 00:18:27 +01:00
TfT_02
9f9de86d21 The defender isn't necessarily a player here
Besides, the defender doesn’t need to have the player data key anyways
2014-02-16 00:11:15 +01:00
TfT_02
d9c04a09ba No need to clone here and it's not null checked
Fixes #1864
2014-02-15 23:35:14 +01:00
85 changed files with 821 additions and 420 deletions

View File

@@ -7,7 +7,7 @@ Key:
! Change
- Removal
Version 1.4.08-dev
Version 1.4.08
+ Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
+ Added the possibility to gain experience when using Fishing "Shake"
@@ -21,6 +21,13 @@ Version 1.4.08-dev
+ Added new experience bonus perk 'mcmmo.perks.xp.customboost.<skillname>' multiplies incoming XP by the boost amount defined in the experience config
+ Added Ender Dragon, Wither, and Witch to combat experience multipliers - they do not give XP by default
+ Added support for multiple mod config files, naming can be done as either armor.<modname>.yml or <modname>.armor.yml
+ Added config options to configure the items used in "Call of the Wild"
+ Added config option to configure the database command cooldown
= Fixed bug where healthbars wouldn't display if skills were disabled
= Fixed bug with "Call of the Wild" entities despawning
= Fixed bug with updating (very) old user data.
= Fixed bug with checking maximum durability of mod items.
= Fixed exploit involving Call of The Wild.
= Fixed bug where LeafBlower permissions were ignored
= Fixed bug with toggle commands not properly displaying the success message.
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
@@ -34,9 +41,12 @@ Version 1.4.08-dev
= Fixed bug where party chat broke if the display name contained special characters
= Fixed bug where `/addlevels all` and `/skillreset all` didn't work
= Fixed bug which made it possible to gain XP by taming the same horse multiple times, if a player "untamed" that horse
= Fixed bug where some horses summoned with "Call of the Wild" were unable to jump
= Fixed bug where the /ptp request expiration time was checked wrongly - preventing players from using the command
= Fixed bug where Hylian Luck was broken
= Fixed bug where Snow would never drop treasures
= Fixed issues with commands giving away vanished players.
= Fixed bug where the Repair lucky perk would increase the Arcane Forging downgrade chance, instead of decreasing it
! Changed party system. Parties now have XP and Levels. Party features such as party teleport and party chat have to be unlocked before they can be used by the party members
! Changed appearance of party member list. Gold = party leader, White = online, Gray = offline, Italic = not nearby
! Updated localization files
@@ -46,6 +56,8 @@ Version 1.4.08-dev
! Changed /ptp config setting, Commands.ptp.Confirm_Required is now Commands.ptp.Accept.Required
! Changed config validation for UnlockLevels, they can now also be 0
! Changed config validation for Rank_Levels, successive Ranks can now be less than or equal to each other
! Changed default amount of XP gained from mining Quartz Ore. From 250 to 100 XP.
! Changed Acrobatics config setting, Skills.Acrobatics.Prevent_XP_After_Teleport is now Skills.Acrobatics.XP_After_Teleport_Cooldown
- Removed /stats alias for /mcstats
Version 1.4.07

View File

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

View File

@@ -43,9 +43,7 @@ public final class ExperienceAPI {
public static boolean isNonChildSkill(String skillType) {
SkillType skill = SkillType.getSkill(skillType);
if (skill == null) return false;
return !skill.isChildSkill();
return skill != null && !skill.isChildSkill();
}
@Deprecated

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -58,7 +57,7 @@ public class KrakenCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -30,7 +30,10 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
}
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
if (Permissions.showversion(sender)) {
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
}
mcMMO.getHolidayManager().anniversaryCheck(sender);
return true;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -62,7 +61,7 @@ public abstract class ToggleCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -9,12 +9,12 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.database;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -23,7 +22,7 @@ public class McremoveCommand implements TabExecutor {
case 1:
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true;
}
@@ -45,7 +44,7 @@ public class McremoveCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.experience;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -68,7 +67,7 @@ public abstract class ExperienceCommand implements TabExecutor {
int value = Integer.parseInt(args[2]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@@ -96,7 +95,7 @@ public abstract class ExperienceCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.experience;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -66,7 +65,7 @@ public class SkillresetCommand implements TabExecutor {
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@@ -94,7 +93,7 @@ public class SkillresetCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));

View File

@@ -1,6 +1,9 @@
package com.gmail.nossr50.commands.party;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -13,6 +16,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -175,7 +179,7 @@ public class PartyCommand implements TabExecutor {
case INVITE:
case KICK:
case OWNER:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
case XPSHARE:
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<String>(XPSHARE_COMPLETIONS.size()));
@@ -190,7 +194,10 @@ public class PartyCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
playerNames = UserManager.getPlayerNames();
Player player = (Player) sender;
Party party = UserManager.getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
}

View File

@@ -18,7 +18,7 @@ public class PartyInviteCommand implements CommandExecutor {
switch (args.length) {
case 2:
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;

View File

@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyKickCommand implements CommandExecutor {
@@ -19,13 +20,15 @@ public class PartyKickCommand implements CommandExecutor {
switch (args.length) {
case 2:
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
if (!playerParty.getMembers().contains(target.getName())) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
if (!playerParty.getMembers().contains(targetName)) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return true;
}
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
if (target.isOnline()) {
Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName();

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.alliance;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -111,7 +110,7 @@ public class PartyAllianceCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<String>(ALLIANCE_SUBCOMMANDS.size()));
if (matches.size() == 0) {
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
}

View File

@@ -18,7 +18,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
switch (args.length) {
case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.teleport;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -11,10 +10,10 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -109,7 +108,10 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
Set<String> playerNames = UserManager.getPlayerNames();
Player player = (Player) sender;
Party party = UserManager.getPlayer(player).getParty();
List<String> playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
}

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.player;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -29,7 +28,7 @@ public class InspectCommand implements TabExecutor {
switch (args.length) {
case 1:
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@@ -104,7 +103,7 @@ public class InspectCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.player;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -15,7 +14,6 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -47,7 +45,7 @@ public class McrankCommand implements TabExecutor {
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
if (mcMMOPlayer != null) {
Player player = mcMMOPlayer.getPlayer();
@@ -73,7 +71,7 @@ public class McrankCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
@@ -83,8 +81,9 @@ public class McrankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
}

View File

@@ -15,7 +15,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
@@ -85,8 +84,9 @@ public class MctopCommand implements TabExecutor {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
}

View File

@@ -0,0 +1,205 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
public class AprilCommand implements TabExecutor {
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
skillName = StringUtils.getCapitalized(label);
switch (args.length) {
case 0:
Player player = (Player) sender;
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
float skillValue = Misc.getRandom().nextInt(99);
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType)));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000)));
List<String> effectMessages = effectsDisplay(fakeSkillType);
if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
for (String message : effectMessages) {
player.sendMessage(message);
}
}
List<String> statsMessages = statsDisplay(fakeSkillType);
if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
return true;
default:
return true;
}
}
private String getXPGainString(FakeSkillType fakeSkillType) {
switch (fakeSkillType) {
case MACHO:
return "Get beaten up";
case JUMPING:
return "Kris Kross will make ya Jump Jump";
case THROWING:
return "Chuck your items on the floor";
case WRECKING:
return "I'M GONNA WRECK IT!";
case CRAFTING:
return "Craft apple pies";
case WALKING:
return "Walk around the park";
case SWIMMING:
return "Like a fish on a bicycle";
case FALLING:
return "Faceplant the floor, headbutt the ground";
case CLIMBING:
return "Climb the highest mountain";
case FLYING:
return "I believe I can fly";
case DIVING:
return "Scuba club 4000";
case PIGGY:
return "OINK! OINK!";
default:
return "Sit and wait?";
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return ImmutableList.of("?");
default:
return ImmutableList.of();
}
}
private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
List<String> messages = new ArrayList<String>();
switch (fakeSkillType) {
case MACHO:
messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
break;
case JUMPING:
messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
break;
case THROWING:
messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
break;
case WRECKING:
messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
break;
case CRAFTING:
messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
break;
case WALKING:
messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
break;
case SWIMMING:
messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
break;
case FALLING:
messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
break;
case CLIMBING:
messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
break;
case FLYING:
messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
break;
case DIVING:
messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
break;
case PIGGY:
messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
break;
}
return messages;
}
private List<String> statsDisplay(FakeSkillType fakeSkillType) {
List<String> messages = new ArrayList<String>();
switch (fakeSkillType) {
case MACHO:
messages.add(LocaleLoader.formatString("[[RED]]Damage Taken: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(77))));
break;
case JUMPING:
messages.add(LocaleLoader.formatString("[[RED]]Double Jump Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case THROWING:
messages.add(LocaleLoader.formatString("[[RED]]Drop Item Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(87))));
break;
case WRECKING:
messages.add(LocaleLoader.formatString("[[RED]]Wrecking Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(14))));
break;
case CRAFTING:
messages.add(LocaleLoader.formatString("[[RED]]Crafting Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case WALKING:
messages.add(LocaleLoader.formatString("[[RED]]Walk Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case SWIMMING:
messages.add(LocaleLoader.formatString("[[RED]]Swim Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case FALLING:
messages.add(LocaleLoader.formatString("[[RED]]Skydiving Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(37))));
break;
case CLIMBING:
messages.add(LocaleLoader.formatString("[[RED]]Rock Climber Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case FLYING:
messages.add(LocaleLoader.formatString("[[RED]]Fly Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case DIVING:
messages.add(LocaleLoader.formatString("[[RED]]Hold Breath Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case PIGGY:
messages.add(LocaleLoader.formatString("[[RED]]Carrot Turbo Boost: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
break;
}
return messages;
}
}

View File

@@ -51,7 +51,6 @@ public class FishingCommand extends SkillCommand {
@Override
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
boolean isStorming = player.getWorld().hasStorm();
// TREASURE HUNTER
if (canTreasureHunt) {
@@ -70,7 +69,7 @@ public class FishingCommand extends SkillCommand {
double totalEnchantChance = 0;
for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.TRAP || rarity != Rarity.RECORD) {
if (rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
}
}
@@ -92,7 +91,7 @@ public class FishingCommand extends SkillCommand {
// MASTER ANGLER
if (canMasterAngler) {
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
Location location = fishingManager.getHookLocation();
if (location == null) {

View File

@@ -4,7 +4,6 @@ import java.text.DecimalFormat;
import java.util.List;
import java.util.Set;
import com.gmail.nossr50.util.Motd;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -18,6 +17,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;

View File

@@ -91,9 +91,9 @@ public class TamingCommand extends SkillCommand {
if (canCallWild) {
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWCost(EntityType.OCELOT)));
messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWCost(EntityType.WOLF)));
messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWCost(EntityType.HORSE)));
}
return messages;

View File

@@ -777,6 +777,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
public double getMinHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D); }
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
/* UNARMED */

View File

@@ -182,20 +182,40 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
if (getTamingCOTWWolfCost() < 1) {
reason.add("Skills.Taming.Call_Of_The_Wild.Bones_Required should be at least 1!");
if (getTamingCOTWMaterial(EntityType.WOLF) == null) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Material is invalid!!");
}
if (getTamingCOTWOcelotCost() < 1) {
reason.add("Skills.Taming.Call_Of_The_Wild.Fish_Required should be at least 1!");
if (getTamingCOTWMaterial(EntityType.OCELOT) == null) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Material is invalid!!");
}
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot_Amount should be greater than 0!");
if (getTamingCOTWMaterial(EntityType.HORSE) == null) {
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Material is invalid!!");
}
if (getTamingCOTWCost(EntityType.WOLF) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Amount should be greater than 0!");
}
if (getTamingCOTWCost(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Amount should be greater than 0!");
}
if (getTamingCOTWCost(EntityType.HORSE) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf_Amount should be greater than 0!");
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Summon_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Summon_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.HORSE) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Summon_Amount should be greater than 0!");
}
return noErrorsInConfig(reason);
@@ -218,7 +238,6 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
@@ -229,6 +248,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
@@ -423,7 +443,7 @@ public class Config extends AutoUpdateConfigLoader {
/* Acrobatics */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
public int getXPAfterTeleportCooldown() { return config.getInt("Skills.Acrobatics.XP_After_Teleport_Cooldown", 5); }
/* Alchemy */
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
@@ -449,11 +469,10 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
/* Taming */
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
public int getTamingCOTWCost(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Amount"); }
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Summon_Amount"); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
/* Woodcutting */
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }

View File

@@ -1,11 +1,11 @@
package com.gmail.nossr50.config.mods;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
import java.io.File;
import java.util.regex.Pattern;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
public class ArmorConfigManager {
public ArmorConfigManager(mcMMO plugin) {
Pattern middlePattern = Pattern.compile("armor\\.(?:.+)\\.yml");
@@ -15,7 +15,7 @@ public class ArmorConfigManager {
ModManager modManager = mcMMO.getModManager();
if (!vanilla.exists()) {
plugin.saveResource(plugin.getDataFolder().getName() + File.separator + "armor.default.yml", false);
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "armor.default.yml", false);
}
for (String fileName : dataFolder.list()) {

View File

@@ -1,11 +1,11 @@
package com.gmail.nossr50.config.mods;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
import java.io.File;
import java.util.regex.Pattern;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
public class BlockConfigManager {
public BlockConfigManager(mcMMO plugin) {
Pattern middlePattern = Pattern.compile("blocks\\.(?:.+)\\.yml");
@@ -15,7 +15,7 @@ public class BlockConfigManager {
ModManager modManager = mcMMO.getModManager();
if (!vanilla.exists()) {
plugin.saveResource(plugin.getDataFolder().getName() + File.separator + "blocks.default.yml", false);
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "blocks.default.yml", false);
}
for (String fileName : dataFolder.list()) {

View File

@@ -1,11 +1,11 @@
package com.gmail.nossr50.config.mods;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
import java.io.File;
import java.util.regex.Pattern;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
public class EntityConfigManager {
public EntityConfigManager(mcMMO plugin) {
Pattern middlePattern = Pattern.compile("entities\\.(?:.+)\\.yml");
@@ -15,7 +15,7 @@ public class EntityConfigManager {
ModManager modManager = mcMMO.getModManager();
if (!vanilla.exists()) {
plugin.saveResource(plugin.getDataFolder().getName() + File.separator + "entities.default.yml", false);
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "entities.default.yml", false);
}
for (String fileName : dataFolder.list()) {

View File

@@ -1,11 +1,11 @@
package com.gmail.nossr50.config.mods;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
import java.io.File;
import java.util.regex.Pattern;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ModManager;
public class ToolConfigManager {
public ToolConfigManager(mcMMO plugin) {
Pattern middlePattern = Pattern.compile("tools\\.(?:.+)\\.yml");
@@ -15,7 +15,7 @@ public class ToolConfigManager {
ModManager modManager = mcMMO.getModManager();
if (!vanilla.exists()) {
plugin.saveResource(plugin.getDataFolder().getName() + File.separator + "tools.default.yml", false);
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "tools.default.yml", false);
}
for (String fileName : dataFolder.list()) {

View File

@@ -5,7 +5,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;

View File

@@ -96,6 +96,10 @@ public class RepairConfig extends ConfigLoader {
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
if (maximumDurability <= 0) {
maximumDurability = (short) config.getInt("Repairables." + key + ".MaximumDurability");
}
if (maximumDurability <= 0) {
reason.add("Maximum durability of " + key + " must be greater than 0!");
}

View File

@@ -44,7 +44,7 @@ public interface DatabaseManager {
/**
* Retrieve leaderboard info.
*
* @param skillName The skill to retrieve info on
* @param skill The skill to retrieve info on
* @param pageNumber Which page in the leaderboards to retrieve
* @param statsPerPage The number of stats per page
* @return the requested leaderboard information

View File

@@ -26,6 +26,9 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
import org.apache.commons.lang.ArrayUtils;
public final class FlatfileDatabaseManager implements DatabaseManager {
private final HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
@@ -604,7 +607,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Length checks depend on last character being ':'
if (line.charAt(line.length() - 1) != ':') {
line = line + ":";
line = line.concat(":");
}
String[] character = line.split(":");
@@ -621,29 +624,33 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
String oldVersion = null;
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
line = line.concat(" :");
character = line.split(":");
oldVersion = "1.1.06";
}
if (!character[33].isEmpty()) {
// Removal of Spout Support
// Version 1.4.07-dev2
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
line = line.replace(character[33], "");
oldVersion = "1.4.07";
if (oldVersion == null) {
oldVersion = "1.4.07";
}
}
// If they're valid, rewrite them to the file.
if (character.length > 40) {
if (character.length == 41) {
writer.append(line).append("\r\n");
continue;
}
StringBuilder newLine = new StringBuilder(line);
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
newLine.append(":");
oldVersion = "1.1.06";
}
if (character.length <= 35) {
// Introduction of Fishing
// Version 1.2.00
@@ -682,7 +689,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
oldVersion = "1.4.06";
}
}
if (character.length <= 40) {
if (character.length <= 39) {
// Addition of Alchemy
// Version 1.4.08
newLine.append("0").append(":");
@@ -692,6 +699,46 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
// Remove any blanks that shouldn't be there, and validate the other fields
String[] newCharacter = newLine.toString().split(":");
boolean corrupted = false;
for (int i = 0; i < newCharacter.length; i++) {
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33)) {
corrupted = true;
if (newCharacter.length != 41) {
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i);
}
else {
if (i == 37) {
newCharacter[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
else if (i == 38) {
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
}
else {
newCharacter[i] = "0";
}
}
}
if (StringUtils.isInt(newCharacter[i]) && i == 38) {
corrupted = true;
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
}
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38)) {
corrupted = true;
newCharacter[i] = "0";
}
}
if (corrupted) {
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]);
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":"));
}
if (oldVersion != null) {
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
}
@@ -767,7 +814,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
private PlayerProfile loadFromLine(String[] character) throws Exception {
private PlayerProfile loadFromLine(String[] character) {
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown

View File

@@ -799,7 +799,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
ResultSet resultSet;
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
PreparedStatement statement = null;
try {
@@ -811,13 +810,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
resultSet = statement.executeQuery();
while (resultSet.next()) {
ArrayList<String> column = new ArrayList<String>();
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
column.add(resultSet.getString(i));
}
rows.put(resultSet.getRow(), column);
// No reason to do anything here... we're just trying to catch exceptions
}
}
catch (SQLException ex) {

View File

@@ -7,6 +7,7 @@ import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
@@ -83,6 +84,19 @@ public class Party {
return onlineMembers;
}
public List<String> getOnlinePlayerNames(CommandSender sender) {
Player player = sender instanceof Player ? (Player) sender : null;
List<String> onlinePlayerNames = new ArrayList<String>();
for (Player onlinePlayer : getOnlineMembers()) {
if (player != null && player.canSee(onlinePlayer)) {
onlinePlayerNames.add(onlinePlayer.getName());
}
}
return onlinePlayerNames;
}
public String getName() {
return name;
}
@@ -337,9 +351,4 @@ public class Party {
return this.getName().equals(other.getName());
}
@Override
public int hashCode() {
return super.hashCode();
}
}

View File

@@ -79,7 +79,6 @@ public class McMMOPlayer {
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
private final Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
private final Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
private int recentlyHurt;
private int respawnATS;
@@ -122,7 +121,6 @@ public class McMMOPlayer {
for (ToolType toolType : ToolType.values()) {
toolMode.put(toolType, false);
toolATS.put(toolType, 0);
}
if (!profile.isLoaded()) {
@@ -340,28 +338,6 @@ public class McMMOPlayer {
toolMode.put(tool, isPrepared);
}
/**
* Get the current prep ATS of a tool.
*
* @param tool Tool to get the ATS for
* @return the ATS for the tool
*/
public long getToolPreparationATS(ToolType tool) {
return toolATS.get(tool);
}
/**
* Set the current prep ATS of a tool.
*
* @param tool Tool to set the ATS for
* @param ATS the ATS of the tool
*/
public void setToolPreparationATS(ToolType tool, long ATS) {
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
toolATS.put(tool, startTime);
}
/*
* Recently Hurt
*/
@@ -594,10 +570,6 @@ public class McMMOPlayer {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public PlayerProfile getProfile() {
return profile;
}
@@ -877,7 +849,6 @@ public class McMMOPlayer {
player.sendMessage(tool.getRaiseTool());
}
setToolPreparationATS(tool, System.currentTimeMillis());
setToolPreparationMode(tool, true);
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
}

View File

@@ -0,0 +1,14 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityTameEvent;
/**
* Called when mcMMO tames an animal via Call of the Wild
*/
public class FakeEntityTameEvent extends EntityTameEvent {
public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) {
super (entity, owner);
}
}

View File

@@ -15,6 +15,7 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
/**
* Gets the activation chance of the ability 0D being no chance, 1.0D being 100% chance
*
* @return The activation chance of the ability
*/
public double getChance() {
@@ -23,7 +24,8 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
/**
* Sets the activation chance of the ability [0D-1.0D]
* @param The activation chance of the ability
*
* @param chance The activation chance of the ability
*/
public void setChance(double chance) {
this.chance = chance;
@@ -31,7 +33,8 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
/**
* Sets the activation chance of the ability to 100% or 0%
* @param whether it should be successful or not
*
* @param success whether it should be successful or not
*/
public void setSuccessful(boolean success) {
this.chance = success ? 1.0D : 0D;

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@@ -66,7 +67,7 @@ public class BlockListener implements Listener {
for (Block b : blocks) {
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
if (b.equals(futureEmptyBlock)) {
if (b.equals(futureEmptyBlock) && futureEmptyBlock.getType() == Material.AIR) {
mcMMO.getPlaceStore().setFalse(b);
}
}
@@ -89,10 +90,14 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) {
// Needed only because under some circumstances Minecraft doesn't move the block
new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2);
if (!event.isSticky()) {
return;
}
Block movedBlock = event.getRetractLocation().getBlock();
// Needed only because under some circumstances Minecraft doesn't move the block
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
/**
@@ -132,14 +137,15 @@ public class BlockListener implements Listener {
}
BlockState blockState = event.getBlock().getState();
Location location = blockState.getLocation();
if (!BlockUtils.shouldBeWatched(blockState)) {
return;
}
/* ALCHEMY - Cancel any brew in progress for that BrewingStand */
if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(event.getBlock())) {
Alchemy.brewingStandMap.get(event.getBlock()).cancelBrew();
if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.get(location).cancelBrew();
}
Player player = event.getPlayer();
@@ -176,7 +182,7 @@ public class BlockListener implements Listener {
}
/* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {

View File

@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
@@ -30,10 +31,10 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
@@ -42,6 +43,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
@@ -51,6 +53,7 @@ import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -72,14 +75,12 @@ public class EntityListener implements Listener {
return;
}
ItemStack bow = event.getBow();
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
if (event.getBow().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())));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -91,7 +92,7 @@ public class EntityListener implements Listener {
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
}
/**
@@ -101,21 +102,29 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity();
Block block = event.getBlock();
if (!(entity instanceof FallingBlock)) {
if (!BlockUtils.shouldBeWatched(block.getState())) {
return;
}
Block block = event.getBlock();
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
Entity entity = event.getEntity();
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
if (entity instanceof FallingBlock || entity instanceof Enderman) {
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block);
}
}
else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block);
else {
if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block);
}
}
}
@@ -143,7 +152,7 @@ public class EntityListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return;
}
@@ -174,6 +183,10 @@ public class EntityListener implements Listener {
Player defendingPlayer = (Player) defender;
Player attackingPlayer = (Player) attacker;
if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) {
return;
}
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
if (defendingPlayer.equals(attackingPlayer)) {
return;
@@ -186,6 +199,7 @@ public class EntityListener implements Listener {
}
CombatUtils.processCombatAttack(event, attacker, target);
CombatUtils.handleHealthbars(attacker, target, event.getDamage());
}
/**
@@ -226,6 +240,11 @@ public class EntityListener implements Listener {
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
/* Check for invincibility */
@@ -236,7 +255,7 @@ public class EntityListener implements Listener {
switch (cause) {
case FALL:
if (Config.getInstance().getPreventXPAfterTeleport() && SkillUtils.calculateTimeLeft((long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player) > 0) {
if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
return;
}
@@ -557,6 +576,10 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
if (event instanceof FakeEntityTameEvent) {
return;
}
Player player = (Player) event.getOwner();
LivingEntity entity = event.getEntity();
@@ -603,9 +626,8 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) {
for (PotionEffect effect : ((PotionMeta) event.getEntity().getItem().getItemMeta()).getCustomEffects()) {
// (effect.getType() != PotionEffectType.SATURATION) is seemingly broken, so we use deprecated method for now.
if (effect.getType().getId() != 23) {
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
if (!effect.getType().equals(PotionEffectType.SATURATION)) {
return;
}

View File

@@ -183,7 +183,10 @@ public class InventoryListener implements Listener {
return;
}
AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), Alchemy.INGREDIENT_SLOT, click);
if (!AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), click)) {
return;
}
event.setCancelled(true);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);

View File

@@ -6,6 +6,7 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -81,7 +82,7 @@ public class PlayerListener implements Listener {
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || !Config.getInstance().getPreventXPAfterTeleport() || event.getFrom().equals(event.getTo())) {
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
return;
}
@@ -304,7 +305,7 @@ public class PlayerListener implements Listener {
ItemStack dropStack = drop.getItemStack();
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).value())) {
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
event.setCancelled(true);
}
@@ -596,21 +597,14 @@ public class PlayerListener implements Listener {
Material type = heldItem.getType();
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
switch (type) {
case APPLE:
tamingManager.summonHorse();
break;
case BONE:
tamingManager.summonWolf();
break;
case RAW_FISH:
tamingManager.summonOcelot();
break;
default:
break;
if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.WOLF)) {
tamingManager.summonWolf();
}
else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.OCELOT)) {
tamingManager.summonOcelot();
}
else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.HORSE)) {
tamingManager.summonHorse();
}
break;
@@ -633,7 +627,7 @@ public class PlayerListener implements Listener {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
if (mcMMOPlayer == null) {
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");

View File

@@ -1,16 +1,16 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.listeners;
import java.io.File;
import java.util.ArrayList;
import org.bukkit.Chunk;
import org.bukkit.World;
@@ -18,7 +17,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
public class WorldListener implements Listener {
private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
private final mcMMO plugin;
public WorldListener(final mcMMO plugin) {
@@ -56,9 +54,7 @@ public class WorldListener implements Listener {
plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
converter.run();
converters.add(converter);
new BlockStoreConversionMain(world).run();
}
/**

View File

@@ -5,11 +5,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.config.mods.ArmorConfigManager;
import com.gmail.nossr50.config.mods.BlockConfigManager;
import com.gmail.nossr50.config.mods.EntityConfigManager;
import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.util.ModManager;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.metadata.FixedMetadataValue;
@@ -19,6 +14,10 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.mods.ArmorConfigManager;
import com.gmail.nossr50.config.mods.BlockConfigManager;
import com.gmail.nossr50.config.mods.EntityConfigManager;
import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
import com.gmail.nossr50.config.treasure.TreasureConfig;
@@ -33,6 +32,7 @@ import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.metrics.MetricsManager;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.CheckDateTask;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.runnables.database.UserPurgeTask;
@@ -48,6 +48,7 @@ import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.LogFilter;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
@@ -87,9 +88,6 @@ public class mcMMO extends JavaPlugin {
/* Plugin Checks */
private static boolean combatTagEnabled;
private static boolean healthBarPluginEnabled;
private static boolean noCheatPlusPluginEnabled;
private static boolean compatNoCheatPlusPluginEnabled;
private static boolean mcpcEnabled;
// Config Validation Check
public boolean noErrorsInConfigFiles = true;
@@ -125,11 +123,9 @@ public class mcMMO extends JavaPlugin {
getLogger().setFilter(new LogFilter(this));
metadataValue = new FixedMetadataValue(this, true);
mcpcEnabled = getServer().getName().equals("MCPC+");
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
PluginManager pluginManager = getServer().getPluginManager();
combatTagEnabled = pluginManager.getPlugin("CombatTag") != null;
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
setupFilePaths();
@@ -141,7 +137,7 @@ public class mcMMO extends JavaPlugin {
return;
}
if (mcpcEnabled) {
if (getServer().getName().equals("MCPC+")) {
checkModConfigs();
}
@@ -149,7 +145,7 @@ public class mcMMO extends JavaPlugin {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
}
if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) {
if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) {
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
}
@@ -315,10 +311,6 @@ public class mcMMO extends JavaPlugin {
return healthBarPluginEnabled;
}
public static boolean isMCPCEnabled() {
return mcpcEnabled;
}
/**
* Setup the various storage file paths
*/
@@ -486,6 +478,10 @@ public class mcMMO extends JavaPlugin {
// Update power level tag scoreboards
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
if (getHolidayManager().nearingAprilFirst()) {
new CheckDateTask().runTaskTimer(this, 10L * Misc.TICK_CONVERSION_FACTOR, 1L * 60L * 60L * Misc.TICK_CONVERSION_FACTOR);
}
}
private void checkModConfigs() {

View File

@@ -260,6 +260,11 @@ public final class PartyManager {
processPartyLeaving(UserManager.getPlayer(member));
}
// Disband the alliance between the disbanded party and it's ally
if (party.getAlly() != null) {
party.getAlly().setAlly(null);
}
parties.remove(party);
}
@@ -459,16 +464,6 @@ public final class PartyManager {
return !party.isLocked() || party.getLeader().equalsIgnoreCase(mcMMOPlayer.getPlayer().getName());
}
/**
* 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) {
return getParty(partyName) != null;
}
/**
* Load party file.
*/

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.runnables;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AprilTask;
import com.gmail.nossr50.util.Misc;
public class CheckDateTask extends BukkitRunnable {
@Override
public void run() {
if (!mcMMO.getHolidayManager().isAprilFirst()) {
return;
}
// Set up jokes
new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
mcMMO.getHolidayManager().registerAprilCommand();
// Jokes deployed.
this.cancel();
}
}

View File

@@ -1,31 +1,31 @@
package com.gmail.nossr50.runnables;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
public class StickyPistonTrackerTask extends BukkitRunnable {
private BlockFace direction;
private Block block;
private Block movedBlock;
public StickyPistonTrackerTask(BlockFace direction, Block block) {
public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) {
this.direction = direction;
this.block = block;
this.movedBlock = movedBlock;
}
@Override
public void run() {
Block newBlock = block.getRelative(direction);
Block originalBlock = newBlock.getRelative(direction);
if (originalBlock.getType() != Material.AIR || !mcMMO.getPlaceStore().isTrue(originalBlock)) {
if (!BlockUtils.shouldBeWatched(movedBlock.getState()) || movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
return;
}
mcMMO.getPlaceStore().setFalse(originalBlock);
mcMMO.getPlaceStore().setTrue(newBlock);
mcMMO.getPlaceStore().setFalse(movedBlock);
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
}
}

View File

@@ -28,7 +28,7 @@ public class FormulaConversionTask extends BukkitRunnable {
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
PlayerProfile profile;
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.

View File

@@ -0,0 +1,55 @@
package com.gmail.nossr50.runnables.skills;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Misc;
public class AprilTask extends BukkitRunnable {
@Override
public void run() {
if (!mcMMO.getHolidayManager().isAprilFirst()) {
this.cancel();
return;
}
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
int betterRandom = Misc.getRandom().nextInt(2000);
if (betterRandom == 0) {
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
fireworksShow(player);
}
for (HolidayManager.FakeSkillType fakeSkillType : HolidayManager.FakeSkillType.values()) {
int random = Misc.getRandom().nextInt(250);
if (random == 0) {
mcMMO.getHolidayManager().levelUpApril(player, fakeSkillType);
break;
}
}
}
}
private void fireworksShow(final Player player) {
final int firework_amount = 10;
for (int i = 0; i < firework_amount; i++) {
int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override
public void run() {
mcMMO.getHolidayManager().spawnFireworks(player);
}
}, delay);
}
}
private String unknown(String string) {
return ChatColor.MAGIC + string + ChatColor.RESET + ChatColor.YELLOW;
}
}

View File

@@ -17,10 +17,6 @@ public abstract class SkillManager {
this.skill = skill;
}
public McMMOPlayer getMcMMOPlayer() {
return mcMMOPlayer;
}
public Player getPlayer() {
return mcMMOPlayer.getPlayer();
}

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.alchemy;
import java.util.List;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.experience.ExperienceConfig;

View File

@@ -15,8 +15,8 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.runnables.PlayerUpdateInventoryTask;
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
import com.gmail.nossr50.util.Permissions;
@@ -54,7 +54,7 @@ public final class AlchemyPotionBrewer {
}
private static boolean removeIngredient(BrewerInventory inventory, Player player) {
ItemStack ingredient = inventory.getIngredient().clone();
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
return false;
@@ -101,7 +101,7 @@ public final class AlchemyPotionBrewer {
}
for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i).clone();
ItemStack item = inventory.getItem(i);
if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) {
continue;
@@ -124,25 +124,24 @@ public final class AlchemyPotionBrewer {
}
}
public static boolean transferItems(InventoryView view, int fromSlot, int toSlot, ClickType click) {
public static boolean transferItems(InventoryView view, int fromSlot, ClickType click) {
boolean success = false;
if (click.isLeftClick()) {
success = transferItems(view, fromSlot, toSlot);
success = transferItems(view, fromSlot);
}
else if (click.isRightClick()) {
success = transferOneItem(view, fromSlot, toSlot);
success = transferOneItem(view, fromSlot);
}
return success;
}
private static boolean transferOneItem(InventoryView view, int fromSlot, int toSlot) {
private static boolean transferOneItem(InventoryView view, int fromSlot) {
ItemStack from = view.getItem(fromSlot).clone();
ItemStack to = view.getItem(toSlot).clone();
boolean emptyFrom = isEmpty(from);
ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
if (emptyFrom) {
if (isEmpty(from)) {
return false;
}
@@ -162,8 +161,8 @@ public final class AlchemyPotionBrewer {
}
from.setAmount(fromAmount - 1);
view.setItem(toSlot, emptyTo ? null : to);
view.setItem(fromSlot, emptyFrom ? null : from);
view.setItem(Alchemy.INGREDIENT_SLOT, to);
view.setItem(fromSlot, from);
return true;
}
@@ -174,15 +173,15 @@ public final class AlchemyPotionBrewer {
/**
* Transfer items between two ItemStacks, returning the leftover status
*/
private static boolean transferItems(InventoryView view, int fromSlot, int toSlot) {
private static boolean transferItems(InventoryView view, int fromSlot) {
ItemStack from = view.getItem(fromSlot).clone();
ItemStack to = view.getItem(toSlot).clone();
ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
if (isEmpty(from)) {
return false;
}
else if (isEmpty(to)) {
view.setItem(toSlot, from);
view.setItem(Alchemy.INGREDIENT_SLOT, from);
view.setItem(fromSlot, null);
return true;
@@ -196,7 +195,7 @@ public final class AlchemyPotionBrewer {
int left = fromAmount + toAmount - maxSize;
to.setAmount(maxSize);
view.setItem(toSlot, to);
view.setItem(Alchemy.INGREDIENT_SLOT, to);
from.setAmount(left);
view.setItem(fromSlot, from);
@@ -206,7 +205,7 @@ public final class AlchemyPotionBrewer {
to.setAmount(fromAmount + toAmount);
view.setItem(fromSlot, null);
view.setItem(toSlot, to);
view.setItem(Alchemy.INGREDIENT_SLOT, to);
return true;
}

View File

@@ -4,12 +4,10 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
@@ -63,14 +61,4 @@ public class Archery {
}
}
}
public static Location stringToLocation(String location) {
String[] values = location.split(",");
return new Location(mcMMO.p.getServer().getWorld(values[0]), Double.parseDouble(values[1]), Double.parseDouble(values[2]), Double.parseDouble(values[3]), Float.parseFloat(values[4]), Float.parseFloat(values[5]));
}
public static String locationToString(Location location) {
return location.getWorld().getName() + "," + location.getX() + "," + location.getY() + "," + location.getZ() + "," + location.getYaw() + "," + location.getPitch();
}
}

View File

@@ -45,7 +45,7 @@ public class ArcheryManager extends SkillManager {
* @param damager The {@link Entity} who shot the arrow
*/
public void distanceXpBonus(LivingEntity target, Entity damager) {
Location firedLocation = Archery.stringToLocation(damager.getMetadata(mcMMO.arrowDistanceKey).get(0).asString());
Location firedLocation = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
Location targetLocation = target.getLocation();
if (firedLocation.getWorld() != targetLocation.getWorld()) {

View File

@@ -3,9 +3,9 @@ package com.gmail.nossr50.skills.excavation;
import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.mcMMO;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;

View File

@@ -54,8 +54,6 @@ public final class Fishing {
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
public static final double STORM_MODIFIER = 0.909;
private Fishing() {}
/**

View File

@@ -1,10 +1,10 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;

View File

@@ -115,8 +115,8 @@ public class MiningManager extends SkillManager {
/**
* Handler for explosion drops and XP gain.
*
* @param yield
* @param blockList
* @param yield The % of blocks to drop
* @param blockList The list of blocks to drop
*/
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
List<BlockState> ores = new ArrayList<BlockState>();

View File

@@ -90,7 +90,15 @@ public class RepairManager extends SkillManager {
Material repairMaterial = repairable.getRepairMaterial();
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
short startDurability = item.getDurability();
// Do not repair if at full durability
if (startDurability <= 0) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
return;
}
// Check if they have the proper material to repair with
if (!inventory.contains(repairMaterial)) {
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial));
@@ -103,14 +111,6 @@ public class RepairManager extends SkillManager {
return;
}
short startDurability = item.getDurability();
// Do not repair if at full durability
if (startDurability <= 0) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
return;
}
// Do not repair stacked items
if (item.getAmount() != 1) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
@@ -340,7 +340,7 @@ public class RepairManager extends SkillManager {
if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
int enchantLevel = enchant.getValue();
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && (100 - getDowngradeEnchantChance()) <= Misc.getRandom().nextInt(activationChance)) {
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
downgraded = true;
}

View File

@@ -1,10 +1,10 @@
package com.gmail.nossr50.skills.smelting;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;

View File

@@ -16,6 +16,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
@@ -145,7 +146,7 @@ public class TamingManager extends SkillManager {
return;
}
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWOcelotCost());
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWCost(EntityType.OCELOT));
}
/**
@@ -156,7 +157,7 @@ public class TamingManager extends SkillManager {
return;
}
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWWolfCost());
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWCost(EntityType.WOLF));
}
/**
@@ -167,7 +168,7 @@ public class TamingManager extends SkillManager {
return;
}
callOfTheWild(EntityType.HORSE, Config.getInstance().getTamingCOTWHorseCost());
callOfTheWild(EntityType.HORSE, Config.getInstance().getTamingCOTWCost(EntityType.HORSE));
}
/**
@@ -226,8 +227,16 @@ public class TamingManager extends SkillManager {
for (int i = 0; i < amount; i++) {
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
((Tameable) entity).setOwner(player);
entity.setRemoveWhenFarAway(false);
switch (type) {
case OCELOT:
@@ -246,7 +255,7 @@ public class TamingManager extends SkillManager {
entity.setHealth(entity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength()));
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
//TODO: setSpeed, once available
break;
@@ -260,7 +269,7 @@ public class TamingManager extends SkillManager {
}
}
player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}

View File

@@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.woodcutting;
import java.util.HashSet;
import java.util.Set;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -12,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.util;
import java.util.HashSet;
import com.gmail.nossr50.mcMMO;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.NetherWartsState;
@@ -13,6 +12,7 @@ import org.bukkit.material.Crops;
import org.bukkit.material.NetherWarts;
import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.Repair;
public final class BlockUtils {

View File

@@ -19,25 +19,56 @@ import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.skills.AprilCommand;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.collect.ImmutableList;
public final class HolidayManager {
private ArrayList<String> hasCelebrated;
private int currentYear;
private final int startYear = 2011;
private static final int START_YEAR = 2011;
private static final List<Color> ALL_COLORS;
private static final List<ChatColor> ALL_CHAT_COLORS;
private static final List<ChatColor> CHAT_FORMATS;
public enum FakeSkillType {
MACHO,
JUMPING,
THROWING,
WRECKING,
CRAFTING,
WALKING,
SWIMMING,
FALLING,
CLIMBING,
FLYING,
DIVING,
PIGGY,
UNKNOWN;
public static FakeSkillType getByName(String skillName) {
for (FakeSkillType type : values()) {
if (type.name().equalsIgnoreCase(skillName)) {
return type;
}
}
return null;
}
}
static {
List<Color> colors = new ArrayList<Color>();
List<ChatColor> chatColors = new ArrayList<ChatColor>();
@@ -165,7 +196,7 @@ public final class HolidayManager {
return;
}
sender.sendMessage(ChatColor.BLUE + "Happy " + (currentYear - startYear) + " Year Anniversary! In honor of all of");
sender.sendMessage(ChatColor.BLUE + "Happy " + (currentYear - START_YEAR) + " Year Anniversary! In honor of all of");
sender.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!");
if (sender instanceof Player) {
final int firework_amount = 10;
@@ -221,11 +252,11 @@ public final class HolidayManager {
hasCelebrated.add(sender.getName());
}
private boolean getDateRange(Date date, Date start, Date end) {
public boolean getDateRange(Date date, Date start, Date end) {
return !(date.before(start) || date.after(end));
}
private void spawnFireworks(Player player) {
public void spawnFireworks(Player player) {
int power = Misc.getRandom().nextInt(3) + 1;
Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
double varX = Misc.getRandom().nextGaussian() * 3;
@@ -254,4 +285,31 @@ public final class HolidayManager {
return ret.toString();
}
public boolean isAprilFirst() {
GregorianCalendar aprilFirst = new GregorianCalendar(currentYear, Calendar.APRIL, 1);
GregorianCalendar aprilSecond = new GregorianCalendar(currentYear, Calendar.APRIL, 2);
GregorianCalendar day = new GregorianCalendar();
return getDateRange(day.getTime(), aprilFirst.getTime(), aprilSecond.getTime());
}
public boolean nearingAprilFirst() {
GregorianCalendar start = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.MARCH, 28);
GregorianCalendar end = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.APRIL, 2);
GregorianCalendar day = new GregorianCalendar();
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
}
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
int levelTotal = Misc.getRandom().nextInt(UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
}
public void registerAprilCommand() {
PluginCommand command = mcMMO.p.getCommand("mcfools");
command.setExecutor(new AprilCommand());
}
}

View File

@@ -498,11 +498,7 @@ public final class ItemUtils {
}
public static boolean isSmeltable(ItemStack item) {
if (item == null) {
return false;
}
return MaterialUtils.isOre(item.getData());
return item != null && MaterialUtils.isOre(item.getData());
}
public static boolean isSmelted(ItemStack item) {

View File

@@ -1,8 +1,9 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.mcMMO;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
public final class MaterialUtils {
private MaterialUtils() {}

View File

@@ -22,7 +22,6 @@ public final class Misc {
public static final int TIME_CONVERSION_FACTOR = 1000;
public static final int TICK_CONVERSION_FACTOR = 20;
public static final long PLAYER_DATABASE_COOLDOWN_MILLIS = 1750;
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
@@ -64,11 +63,7 @@ public final class Misc {
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
*/
public static boolean isNear(Location first, Location second, double maxDistance) {
if (first.getWorld() != second.getWorld()) {
return false;
}
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
}
public static void dropItems(Location location, Collection<ItemStack> drops) {
@@ -90,41 +85,6 @@ public final class Misc {
}
}
/**
* Randomly drop an item at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param chance The percentage chance for the item to drop
*/
public static void randomDropItem(Location location, ItemStack is, double chance) {
if (random.nextInt(100) < chance) {
dropItem(location, is);
}
}
/**
* Drop items with random quantity at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param quantity The amount of items to drop
*/
public static void randomDropItems(Location location, ItemStack is, int quantity) {
int dropCount = random.nextInt(quantity + 1);
if (dropCount > 0) {
is.setAmount(dropCount);
dropItem(location, is);
}
}
public static void randomDropItems(Location location, Collection<ItemStack> drops, double chance) {
for (ItemStack item : drops) {
randomDropItem(location, item, chance);
}
}
/**
* Drop an item at a given location.
*

View File

@@ -1,5 +1,18 @@
package com.gmail.nossr50.util;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig;
@@ -8,19 +21,7 @@ import com.gmail.nossr50.config.mods.CustomToolConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ModManager {
private List<Repairable> repairables = new ArrayList<Repairable>();

View File

@@ -34,7 +34,9 @@ public final class Motd {
* @param version Plugin version
*/
public static void displayVersion(Player player, String version) {
player.sendMessage(LocaleLoader.getString("MOTD.Version", version));
if (Permissions.showversion(player)) {
player.sendMessage(LocaleLoader.getString("MOTD.Version", version));
}
}
/**

View File

@@ -25,6 +25,7 @@ public final class Permissions {
public static boolean mobHealthDisplay(Permissible permissible) { return permissible.hasPermission("mcmmo.mobhealthdisplay"); }
public static boolean updateNotifications(Permissible permissible) {return permissible.hasPermission("mcmmo.tools.updatecheck"); }
public static boolean chimaeraWing(Permissible permissible) { return permissible.hasPermission("mcmmo.item.chimaerawing"); }
public static boolean showversion(Permissible permissible) { return permissible.hasPermission("mcmmo.showversion"); }
/* BYPASS */
public static boolean hardcoreBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.hardcoremode"); }

View File

@@ -90,6 +90,10 @@ public final class CommandUtils {
*/
public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) {
if (mcMMOPlayer != null) {
if (CommandUtils.hidden(sender, mcMMOPlayer.getPlayer(), false)) {
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return false;
}
return true;
}
@@ -216,6 +220,19 @@ public final class CommandUtils {
}
}
public static List<String> getOnlinePlayerNames(CommandSender sender) {
Player player = sender instanceof Player ? (Player) sender : null;
List<String> onlinePlayerNames = new ArrayList<String>();
for (Player onlinePlayer : mcMMO.p.getServer().getOnlinePlayers()) {
if (player != null && player.canSee(onlinePlayer)) {
onlinePlayerNames.add(onlinePlayer.getName());
}
}
return onlinePlayerNames;
}
/**
* Get a matched player name if one was found in the database.
*

View File

@@ -2,8 +2,6 @@ package com.gmail.nossr50.util.player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
@@ -60,16 +58,6 @@ public final class UserManager {
}
}
public static Set<String> getPlayerNames() {
Set<String> playerNames = new HashSet<String>();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
playerNames.add(player.getName());
}
return playerNames;
}
public static Collection<McMMOPlayer> getPlayers() {
Collection<McMMOPlayer> playerCollection = new ArrayList<McMMOPlayer>();
@@ -90,28 +78,16 @@ public final class UserManager {
return retrieveMcMMOPlayer(playerName, false);
}
/**
* Get the McMMOPlayer of a player.
*
* @param player The player whose McMMOPlayer to retrieve
* @return the player's McMMOPlayer object
*/
public static McMMOPlayer getPlayer(OfflinePlayer player) {
public static McMMOPlayer getOfflinePlayer(OfflinePlayer player) {
if (player instanceof Player) {
return getPlayer((Player) player);
}
return retrieveMcMMOPlayer(player.getName(), false);
return retrieveMcMMOPlayer(player.getName(), true);
}
public static McMMOPlayer getPlayer(OfflinePlayer player, boolean offlineValid) {
if (player instanceof Player) {
return getPlayer((Player) player);
}
return retrieveMcMMOPlayer(player.getName(), offlineValid);
}
public static McMMOPlayer getPlayer(String playerName, boolean offlineValid) {
return retrieveMcMMOPlayer(playerName, offlineValid);
public static McMMOPlayer getOfflinePlayer(String playerName) {
return retrieveMcMMOPlayer(playerName, true);
}
public static McMMOPlayer getPlayer(Player player) {
@@ -133,10 +109,6 @@ public final class UserManager {
}
public static boolean hasPlayerDataKey(Entity entity) {
if (entity == null) {
return false;
}
return entity.hasMetadata(mcMMO.playerDataKey);
return entity != null && entity.hasMetadata(mcMMO.playerDataKey);
}
}

View File

@@ -329,7 +329,7 @@ public class ScoreboardManager {
}
for (String playerName : dirtyPowerLevels) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
if (mcMMOPlayer == null) {
continue;

View File

@@ -197,7 +197,7 @@ public final class CombatUtils {
if (attacker instanceof Player && entityType == EntityType.PLAYER) {
Player player = (Player) attacker;
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -298,15 +298,6 @@ public final class CombatUtils {
}
}
}
else if (attacker instanceof Player) {
Player player = (Player) attacker;
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(target)) {
return;
}
MobHealthbarUtils.handleMobHealthbars(player, target, event.getDamage());
}
}
/**
@@ -506,7 +497,7 @@ public final class CombatUtils {
return false;
}
if (PartyManager.inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
if ((PartyManager.inSameParty(player, defender) || PartyManager.areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
return false;
}
@@ -558,7 +549,7 @@ public final class CombatUtils {
if (tamer instanceof Player) {
Player owner = (Player) tamer;
return (owner == attacker || PartyManager.inSameParty(attacker, owner));
return (owner == attacker || PartyManager.inSameParty(attacker, owner) || PartyManager.areAllies(attacker, owner));
}
}
@@ -614,4 +605,18 @@ public final class CombatUtils {
return tier;
}
public static void handleHealthbars(Entity attacker, LivingEntity target, double damage) {
if (!(attacker instanceof Player)) {
return;
}
Player player = (Player) attacker;
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(target)) {
return;
}
MobHealthbarUtils.handleMobHealthbars(player, target, damage);
}
}

View File

@@ -23,6 +23,8 @@ import java.util.zip.ZipFile;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.config.Config;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@@ -440,14 +442,14 @@ public class Updater {
return true;
}
// Check release vs. beta & dev
// Check release vs. beta & SNAPSHOT
if (newTokens.length == 1 && oldTokens.length == 3 && oldVersion == newVersion) {
return true;
}
// Check beta vs. dev
if (version.contains("dev") && title.contains("beta")) {
if (Integer.parseInt(oldTokens[1].substring(3)) <= Integer.parseInt(newTokens[1].substring(4))) {
// Check beta vs. SNAPSHOT
if (version.contains("SNAPSHOT") && title.contains("beta")) {
if (Integer.parseInt(oldTokens[1].substring(8)) <= Integer.parseInt(newTokens[1].substring(4))) {
return true;
}
@@ -465,7 +467,7 @@ public class Updater {
return false;
}
if (oldTokens.length == 3 && !version.contains("beta") && !version.contains("dev")) {
if (oldTokens.length == 3 && !version.contains("beta") && !version.contains("SNAPSHOT")) {
plugin.getLogger().warning("Could not get information about this mcMMO version; perhaps you are running a custom one?");
result = UpdateResult.FAIL_NOVERSION;
return false;
@@ -519,7 +521,11 @@ public class Updater {
this.plugin.getLogger().warning("If you have not recently modified your configuration and this is the first time you are seeing this message, the site may be experiencing temporary downtime.");
this.result = UpdateResult.FAIL_DBO;
}
e.printStackTrace();
if (Config.getInstance().getVerboseLoggingEnabled()) {
e.printStackTrace();
}
return false;
}
}

View File

@@ -471,7 +471,9 @@ Skills:
Bonus: 2.0
CallOfTheWild:
# MinHorseJumpStrength: The minimum jump strength a summoned horse must have
# MaxHorseJumpStrength: The maximum jump strength a summoned horse can have
MinHorseJumpStrength: 0.7
MaxHorseJumpStrength: 2.0
#
# Settings for Unarmed

View File

@@ -267,7 +267,8 @@ Skills:
Prevent_AFK_Leveling: true
Max_Tries_At_Same_Location: 3
Prevent_Dodge_Lightning: false
Prevent_XP_After_Teleport: true
# Prevent earning Acrobatics XP a few seconds after teleporting
XP_After_Teleport_Cooldown: 5
Level_Cap: 0
Alchemy:
# Allow Hoppers to transfer ingredients and brew Rank 1 Alchemy potions
@@ -316,16 +317,24 @@ Skills:
Enabled_For_PVE: true
Level_Cap: 0
Call_Of_The_Wild:
Bones_Required: 10
Fish_Required: 10
Apples_Required: 10
# Item_Material: Material of the item needed to summon the pet
# Item_Amount: Amount of items required to summon the pet
# Summon_Amount: Amount of pets to summon when using Call Of The Wild
Wolf:
Item_Material: BONE
Item_Amount: 10
Summon_Amount: 1
Ocelot:
Item_Material: RAW_FISH
Item_Amount: 10
Summon_Amount: 1
Horse:
Item_Material: APPLE
Item_Amount: 10
Summon_Amount: 1
# Range to check for nearby pets when using Call Of The Wild, 0 will disable the check
Range: 40.0
# Amount of pets to summon when using Call Of The Wild
Wolf_Amount: 1
Ocelot_Amount: 1
Horse_Amount: 1
Unarmed:
Enabled_For_PVP: true
Enabled_For_PVE: true
@@ -386,6 +395,10 @@ Commands:
# If true, when using partial names in commands mcMMO will try to look for a match from
# the offline players. Enabling this might slow the server down if there are a lot of offline players.
Match_OfflinePlayers: false
Database:
# Database command cooldown in milliseconds, cannot be changed below the default value. (1750)
# Prevents players from spamming /mctop or /mcrank
Player_Cooldown: 1750
mcmmo:
Donate_Message: true
inspect:

View File

@@ -129,7 +129,7 @@ Experience:
Mossy_Cobblestone: 30
Netherrack: 30
Obsidian: 150
Quartz_Ore: 250
Quartz_Ore: 100
Redstone_Ore: 150
Sandstone: 30
Stone: 30

View File

@@ -114,6 +114,9 @@ commands:
kraken:
aliases: [mckraken]
description: Unleash the kraken!
mcfools:
aliases: [macho, jumping, throwing, wrecking, crafting, walking, swimming, falling, climbing, flying, diving, piggy]
description: Deploy jokes
permissions:
mcmmo.*:
default: false
@@ -1937,6 +1940,9 @@ permissions:
children:
mcmmo.ability.woodcutting.all: true
mcmmo.commands.woodcutting: true
mcmmo.showversion:
default: true
description: Show mcMMO version number in /mcmmo and motd
mcmmo.tools.*:
default: false
description: Implies all mcmmo.tools permissions.

View File

@@ -363,7 +363,7 @@ Potions:
Children:
FERMENTED_SPIDER_EYE: 8236
REDSTONE: 8260
SULPHUR: 16452
SULPHUR: 16420
8260: # Potion of Poison Extended
Children:
FERMENTED_SPIDER_EYE: 8204
@@ -633,16 +633,16 @@ Potions:
16388: # Splash Potion of Poison
Children:
FERMENTED_SPIDER_EYE: 16396
GLOWSTONE_DUST: 16452
GLOWSTONE_DUST: 16420
REDSTONE: 16452
16452: # Splash Potion of Poison II
16420: # Splash Potion of Poison II
Children:
FERMENTED_SPIDER_EYE: 16428
REDSTONE: 16452
16452: # Splash Potion of Poison Extended
Children:
FERMENTED_SPIDER_EYE: 16396
GLOWSTONE_DUST: 16452
GLOWSTONE_DUST: 16420
21504: # Splash Potion of Decay
Effects: ["WITHER 0 338"]