mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
1 Commits
1.6-releas
...
cs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13e7788b14 |
@@ -7,7 +7,7 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.08
|
||||
Version 1.4.08-dev
|
||||
+ 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"
|
||||
@@ -20,14 +20,6 @@ Version 1.4.08
|
||||
+ Added new experience bonus perk 'mcmmo.perks.xp.10percentboost.<skillname>' multiplies incoming XP by 1.1
|
||||
+ 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
|
||||
@@ -41,12 +33,9 @@ Version 1.4.08
|
||||
= 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
|
||||
@@ -56,8 +45,6 @@ Version 1.4.08
|
||||
! 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
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.08</version>
|
||||
<version>1.4.08-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -121,7 +121,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.4-R2.0</version>
|
||||
<version>RELEASE</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -43,7 +43,9 @@ public final class ExperienceAPI {
|
||||
public static boolean isNonChildSkill(String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
return skill != null && !skill.isChildSkill();
|
||||
if (skill == null) return false;
|
||||
|
||||
return !skill.isChildSkill();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -57,7 +58,7 @@ public class KrakenCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -30,10 +30,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
if (Permissions.showversion(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
mcMMO.getHolidayManager().anniversaryCheck(sender);
|
||||
return true;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -61,7 +62,7 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -4,10 +4,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.chat.PartyChatManager;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -30,11 +28,6 @@ public class PartyChatCommand extends ChatCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
|
||||
return;
|
||||
}
|
||||
|
||||
message = buildChatMessage(args, 0);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -22,7 +23,7 @@ public class McremoveCommand implements TabExecutor {
|
||||
case 1:
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
|
||||
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
||||
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ public class McremoveCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -67,7 +68,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
int value = Integer.parseInt(args[2]);
|
||||
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// 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) {
|
||||
@@ -95,7 +96,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
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()));
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -65,7 +66,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// 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) {
|
||||
@@ -93,7 +94,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
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()));
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -16,7 +13,6 @@ 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;
|
||||
@@ -179,7 +175,7 @@ public class PartyCommand implements TabExecutor {
|
||||
case INVITE:
|
||||
case KICK:
|
||||
case OWNER:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
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()));
|
||||
@@ -194,10 +190,7 @@ 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) {
|
||||
Player player = (Player) sender;
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
|
||||
playerNames = party.getOnlinePlayerNames(player);
|
||||
playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
@@ -224,7 +217,7 @@ public class PartyCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private String[] extractArgs(String[] args) {
|
||||
return Arrays.copyOfRange(args, 1, args.length);
|
||||
return Arrays.copyOfRange(args, 1, args.length - 1);
|
||||
}
|
||||
|
||||
private boolean isItemShareCategory(String category) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class PartyHelpCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party expshare"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -18,7 +18,7 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
|
||||
@@ -11,7 +11,6 @@ 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 {
|
||||
@@ -20,15 +19,13 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||
|
||||
if (!playerParty.getMembers().contains(targetName)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||
if (!playerParty.getMembers().contains(target.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
|
||||
|
||||
if (target.isOnline()) {
|
||||
Player onlineTarget = target.getPlayer();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
@@ -23,11 +23,6 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getParty().getAlly() != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.acceptAllianceInvite(mcMMOPlayer);
|
||||
return true;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -110,7 +111,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) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 3:
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -10,10 +11,10 @@ import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -108,10 +109,7 @@ public class PtpCommand implements TabExecutor {
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
Player player = (Player) sender;
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
|
||||
List<String> playerNames = party.getOnlinePlayerNames(player);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -28,7 +29,7 @@ public class InspectCommand implements TabExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// 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) {
|
||||
@@ -103,7 +104,7 @@ public class InspectCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -14,6 +15,7 @@ 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;
|
||||
@@ -45,7 +47,7 @@ public class McrankCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
@@ -71,7 +73,7 @@ public class McrankCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
@@ -81,9 +83,8 @@ 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() + cooldownMillis > System.currentTimeMillis()) {
|
||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ 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;
|
||||
@@ -84,9 +85,8 @@ 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() + cooldownMillis > System.currentTimeMillis()) {
|
||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class AlchemyCommand extends SkillCommand {
|
||||
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
||||
String[] displayValues = new String[2];
|
||||
|
||||
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
|
||||
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
|
||||
displayValues[0] = decimal.format(alchemyManager.getBrewSpeed()) + "x";
|
||||
displayValues[1] = isLucky ? decimal.format(alchemyManager.getBrewSpeedLucky()) + "x" : null;
|
||||
|
||||
return displayValues;
|
||||
}
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ 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) {
|
||||
@@ -69,7 +70,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);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,7 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
|
||||
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
||||
Location location = fishingManager.getHookLocation();
|
||||
|
||||
if (location == null) {
|
||||
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -17,7 +18,6 @@ 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;
|
||||
|
||||
@@ -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().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)));
|
||||
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()));
|
||||
}
|
||||
|
||||
return messages;
|
||||
|
||||
@@ -777,7 +777,6 @@ 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 */
|
||||
|
||||
@@ -182,40 +182,20 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
reason.add("Cannot use the same item for Repair and Salvage anvils!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWMaterial(EntityType.WOLF) == null) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Material is invalid!!");
|
||||
if (getTamingCOTWWolfCost() < 1) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Bones_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 (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.Summon_Amount should be greater than 0!");
|
||||
if (getTamingCOTWOcelotCost() < 1) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Fish_Required should be at least 1!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Summon_Amount should be greater than 0!");
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot_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!");
|
||||
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf_Amount should be greater than 0!");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
@@ -238,6 +218,7 @@ 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); }
|
||||
@@ -248,7 +229,6 @@ 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); }
|
||||
|
||||
@@ -396,7 +376,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); }
|
||||
public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Accept_Required", true); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||
|
||||
/* Inspect command distance */
|
||||
@@ -443,7 +423,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
/* Acrobatics */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
public int getXPAfterTeleportCooldown() { return config.getInt("Skills.Acrobatics.XP_After_Teleport_Cooldown", 5); }
|
||||
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
|
||||
|
||||
/* Alchemy */
|
||||
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
|
||||
@@ -469,10 +449,11 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
/* Taming */
|
||||
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 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 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); }
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
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");
|
||||
Pattern startPattern = Pattern.compile("(?:.+)\\.armor\\.yml");
|
||||
File dataFolder = new File(mcMMO.getModDirectory());
|
||||
File vanilla = new File(dataFolder, "armor.default.yml");
|
||||
ModManager modManager = mcMMO.getModManager();
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "armor.default.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomArmor(new CustomArmorConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
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");
|
||||
Pattern startPattern = Pattern.compile("(?:.+)\\.blocks\\.yml");
|
||||
File dataFolder = new File(mcMMO.getModDirectory());
|
||||
File vanilla = new File(dataFolder, "blocks.default.yml");
|
||||
ModManager modManager = mcMMO.getModManager();
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "blocks.default.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomBlocks(new CustomBlockConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,22 +16,42 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customBoots = new ArrayList<Material>();
|
||||
public List<Material> customChestplates = new ArrayList<Material>();
|
||||
public List<Material> customHelmets = new ArrayList<Material>();
|
||||
public List<Material> customLeggings = new ArrayList<Material>();
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
private List<Material> customBoots = new ArrayList<Material>();
|
||||
private List<Material> customChestplates = new ArrayList<Material>();
|
||||
private List<Material> customHelmets = new ArrayList<Material>();
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
protected CustomArmorConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
public CustomArmorConfig() {
|
||||
super("mods", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomArmorConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
@@ -97,4 +117,20 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
materialList.add(armorMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCustomBoots(Material material) {
|
||||
return customBoots.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomChestplate(Material material) {
|
||||
return customChestplates.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomHelmet(Material material) {
|
||||
return customHelmets.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomLeggings(Material material) {
|
||||
return customLeggings.contains(material);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,29 +13,40 @@ import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private static CustomBlockConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customWoodcuttingBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
|
||||
public HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
|
||||
protected CustomBlockConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
public CustomBlockConfig() {
|
||||
super("mods", "blocks.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomBlockConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomBlockConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", null);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
|
||||
if (needsUpdate) {
|
||||
@@ -74,10 +85,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
|
||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||
|
||||
if (blockList != null) {
|
||||
blockList.add(blockMaterialData);
|
||||
}
|
||||
blockList.add(blockMaterialData);
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
continue;
|
||||
@@ -103,4 +111,40 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
}
|
||||
}
|
||||
|
||||
public CustomBlock getCustomBlock(MaterialData data) {
|
||||
return customBlockMap.get(data);
|
||||
}
|
||||
|
||||
public boolean isCustomOre(MaterialData data) {
|
||||
return customOres.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomLog(MaterialData data) {
|
||||
return customLogs.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomLeaf(MaterialData data) {
|
||||
return customLeaves.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomAbilityBlock(MaterialData data) {
|
||||
return customAbilityBlocks.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomExcavationBlock(MaterialData data) {
|
||||
return customExcavationBlocks.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomHerbalismBlock(MaterialData data) {
|
||||
return customHerbalismBlocks.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomMiningBlock(MaterialData data) {
|
||||
return customMiningBlocks.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomWoodcuttingBlock(MaterialData data) {
|
||||
return customWoodcuttingBlocks.contains(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.config.mods;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
@@ -11,14 +12,24 @@ import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
import org.apache.commons.lang.ClassUtils;
|
||||
|
||||
public class CustomEntityConfig extends ConfigLoader {
|
||||
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
private static CustomEntityConfig instance;
|
||||
|
||||
protected CustomEntityConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
|
||||
public CustomEntityConfig() {
|
||||
super("mods", "entities.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomEntityConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomEntityConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
if (config.getConfigurationSection("Hostile") != null) {
|
||||
@@ -60,4 +71,47 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCustomEntity(Entity entity) {
|
||||
if (customEntityTypeMap.containsKey(entity.getType().toString())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||
return customEntityClassMap.containsKey(entity.getClass().getName());
|
||||
}
|
||||
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public CustomEntity getCustomEntity(Entity entity) {
|
||||
CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
|
||||
|
||||
if (customEntity == null) {
|
||||
try {
|
||||
customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||
customEntity = customEntityClassMap.get(entity.getClass().getName());
|
||||
}
|
||||
else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return customEntity;
|
||||
}
|
||||
|
||||
public void addEntity(CustomEntity customEntity, String className, String entityName) {
|
||||
customEntityTypeMap.put(entityName, customEntity);
|
||||
customEntityClassMap.put(className, customEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,26 +18,46 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private static CustomToolConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<Material> customAxes = new ArrayList<Material>();
|
||||
public List<Material> customBows = new ArrayList<Material>();
|
||||
public List<Material> customHoes = new ArrayList<Material>();
|
||||
public List<Material> customPickaxes = new ArrayList<Material>();
|
||||
public List<Material> customShovels = new ArrayList<Material>();
|
||||
public List<Material> customSwords = new ArrayList<Material>();
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
private List<Material> customAxes = new ArrayList<Material>();
|
||||
private List<Material> customBows = new ArrayList<Material>();
|
||||
private List<Material> customHoes = new ArrayList<Material>();
|
||||
private List<Material> customPickaxes = new ArrayList<Material>();
|
||||
private List<Material> customShovels = new ArrayList<Material>();
|
||||
private List<Material> customSwords = new ArrayList<Material>();
|
||||
|
||||
public List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
|
||||
protected CustomToolConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
private CustomToolConfig() {
|
||||
super("mods", "tools.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomToolConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomToolConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
@@ -112,4 +132,36 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
customToolMap.put(toolMaterial, tool);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCustomAxe(Material material) {
|
||||
return customAxes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomBow(Material material) {
|
||||
return customBows.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomHoe(Material material) {
|
||||
return customHoes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomPickaxe(Material material) {
|
||||
return customPickaxes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomShovel(Material material) {
|
||||
return customShovels.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomSword(Material material) {
|
||||
return customSwords.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomTool(Material material) {
|
||||
return customToolMap.containsKey(material);
|
||||
}
|
||||
|
||||
public CustomTool getCustomTool(Material material) {
|
||||
return customToolMap.get(material);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
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");
|
||||
Pattern startPattern = Pattern.compile("(?:.+)\\.entities\\.yml");
|
||||
File dataFolder = new File(mcMMO.getModDirectory());
|
||||
File vanilla = new File(dataFolder, "entities.default.yml");
|
||||
ModManager modManager = mcMMO.getModManager();
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "entities.default.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomEntities(new CustomEntityConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
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");
|
||||
Pattern startPattern = Pattern.compile("(?:.+)\\.tools\\.yml");
|
||||
File dataFolder = new File(mcMMO.getModDirectory());
|
||||
File vanilla = new File(dataFolder, "tools.default.yml");
|
||||
ModManager modManager = mcMMO.getModManager();
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "tools.default.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
modManager.registerCustomTools(new CustomToolConfig(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config.skills.alchemy;
|
||||
package com.gmail.nossr50.config.potion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -13,21 +13,21 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.datatypes.AlchemyPotion;
|
||||
|
||||
public class PotionConfig extends ConfigLoader {
|
||||
private static PotionConfig instance;
|
||||
|
||||
private List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
||||
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
||||
|
||||
private Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
||||
public Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
||||
|
||||
private PotionConfig() {
|
||||
super("potions.yml");
|
||||
@@ -189,34 +189,4 @@ public class PotionConfig extends ConfigLoader {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ItemStack> getIngredients(int tier) {
|
||||
switch (tier) {
|
||||
case 8:
|
||||
return concoctionsIngredientsTierEight;
|
||||
case 7:
|
||||
return concoctionsIngredientsTierSeven;
|
||||
case 6:
|
||||
return concoctionsIngredientsTierSix;
|
||||
case 5:
|
||||
return concoctionsIngredientsTierFive;
|
||||
case 4:
|
||||
return concoctionsIngredientsTierFour;
|
||||
case 3:
|
||||
return concoctionsIngredientsTierThree;
|
||||
case 2:
|
||||
return concoctionsIngredientsTierTwo;
|
||||
case 1:
|
||||
default:
|
||||
return concoctionsIngredientsTierOne;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidPotion(ItemStack item) {
|
||||
return potionMap.containsKey(item.getDurability());
|
||||
}
|
||||
|
||||
public AlchemyPotion getPotion(short durability) {
|
||||
return potionMap.get(durability);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config.skills.repair;
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -96,10 +96,6 @@ 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!");
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config.skills.repair;
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -9,9 +9,11 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private final List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfigManager(mcMMO plugin) {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||
@@ -32,11 +34,19 @@ public class RepairConfigManager {
|
||||
}
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(fileName);
|
||||
repairables.addAll(rConfig.getLoadedRepairables());
|
||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
||||
|
||||
if (rConfigRepairables != null) {
|
||||
repairables.addAll(rConfigRepairables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public interface DatabaseManager {
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skill The skill to retrieve info on
|
||||
* @param skillName 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
|
||||
|
||||
@@ -26,9 +26,6 @@ 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>>();
|
||||
@@ -607,7 +604,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
// Length checks depend on last character being ':'
|
||||
if (line.charAt(line.length() - 1) != ':') {
|
||||
line = line.concat(":");
|
||||
line = line + ":";
|
||||
}
|
||||
String[] character = line.split(":");
|
||||
|
||||
@@ -624,33 +621,29 @@ 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], "");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.07";
|
||||
}
|
||||
oldVersion = "1.4.07";
|
||||
}
|
||||
|
||||
// If they're valid, rewrite them to the file.
|
||||
if (character.length == 41) {
|
||||
if (character.length > 40) {
|
||||
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
|
||||
@@ -689,7 +682,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
oldVersion = "1.4.06";
|
||||
}
|
||||
}
|
||||
if (character.length <= 39) {
|
||||
if (character.length <= 40) {
|
||||
// Addition of Alchemy
|
||||
// Version 1.4.08
|
||||
newLine.append("0").append(":");
|
||||
@@ -699,46 +692,6 @@ 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);
|
||||
}
|
||||
@@ -814,7 +767,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerProfile loadFromLine(String[] character) {
|
||||
private PlayerProfile loadFromLine(String[] character) throws Exception {
|
||||
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
|
||||
|
||||
@@ -799,6 +799,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
ResultSet resultSet;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -810,7 +811,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
// No reason to do anything here... we're just trying to catch exceptions
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -25,27 +25,25 @@ public class AlchemyPotion {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "AlchemyPotion{" + dataValue + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
|
||||
return "AlchemyPotion{" + dataValue + "," + name + ",Effects[" + effects.size() + "], Children[" + children.size() + "]}";
|
||||
}
|
||||
|
||||
public ItemStack toItemStack() {
|
||||
return toItemStack(1);
|
||||
}
|
||||
|
||||
public ItemStack toItemStack(int amount) {
|
||||
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
|
||||
PotionMeta meta = (PotionMeta) potion.getItemMeta();
|
||||
|
||||
if (this.getName() != null) {
|
||||
meta.setDisplayName(this.getName());
|
||||
}
|
||||
|
||||
meta.setDisplayName(this.getName());
|
||||
if (this.getLore() != null && !this.getLore().isEmpty()) {
|
||||
meta.setLore(this.getLore());
|
||||
}
|
||||
|
||||
if (!this.getEffects().isEmpty()) {
|
||||
for (PotionEffect effect : this.getEffects()) {
|
||||
meta.addCustomEffect(effect, true);
|
||||
}
|
||||
}
|
||||
|
||||
potion.setItemMeta(meta);
|
||||
return potion;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -84,19 +83,6 @@ 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;
|
||||
}
|
||||
@@ -351,4 +337,9 @@ public class Party {
|
||||
|
||||
return this.getName().equals(other.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
@@ -79,6 +80,7 @@ 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;
|
||||
@@ -121,6 +123,7 @@ public class McMMOPlayer {
|
||||
|
||||
for (ToolType toolType : ToolType.values()) {
|
||||
toolMode.put(toolType, false);
|
||||
toolATS.put(toolType, 0);
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
@@ -338,6 +341,28 @@ 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
|
||||
*/
|
||||
@@ -570,6 +595,10 @@ public class McMMOPlayer {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public PlayerProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
@@ -728,7 +757,7 @@ public class McMMOPlayer {
|
||||
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand());
|
||||
CustomTool tool = ModUtils.getToolFromItemStack(player.getItemInHand());
|
||||
|
||||
if (tool != null) {
|
||||
xp *= tool.getXpMultiplier();
|
||||
@@ -814,7 +843,7 @@ public class McMMOPlayer {
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
|
||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -849,6 +878,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ 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() {
|
||||
@@ -24,8 +23,7 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
|
||||
|
||||
/**
|
||||
* Sets the activation chance of the ability [0D-1.0D]
|
||||
*
|
||||
* @param chance The activation chance of the ability
|
||||
* @param The activation chance of the ability
|
||||
*/
|
||||
public void setChance(double chance) {
|
||||
this.chance = chance;
|
||||
@@ -33,8 +31,7 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
|
||||
|
||||
/**
|
||||
* Sets the activation chance of the ability to 100% or 0%
|
||||
*
|
||||
* @param success whether it should be successful or not
|
||||
* @param whether it should be successful or not
|
||||
*/
|
||||
public void setSuccessful(boolean success) {
|
||||
this.chance = success ? 1.0D : 0D;
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -67,7 +66,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) && futureEmptyBlock.getType() == Material.AIR) {
|
||||
if (b.equals(futureEmptyBlock)) {
|
||||
mcMMO.getPlaceStore().setFalse(b);
|
||||
}
|
||||
}
|
||||
@@ -90,14 +89,10 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (!event.isSticky()) {
|
||||
return;
|
||||
if (event.isSticky()) {
|
||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||
new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +104,7 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,20 +132,19 @@ 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(location)) {
|
||||
Alchemy.brewingStandMap.get(location).cancelBrew();
|
||||
if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(event.getBlock())) {
|
||||
Alchemy.brewingStandMap.get(event.getBlock()).cancelBrew();
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -182,7 +176,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
else if (BlockUtils.isLog(blockState) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||
|
||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||
@@ -220,7 +214,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -267,7 +261,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -333,7 +327,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ 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;
|
||||
@@ -31,10 +30,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;
|
||||
@@ -43,7 +42,6 @@ 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;
|
||||
@@ -53,7 +51,6 @@ 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;
|
||||
@@ -75,12 +72,14 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBow().containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
ItemStack bow = event.getBow();
|
||||
|
||||
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
|
||||
}
|
||||
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -92,7 +91,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,29 +101,21 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!BlockUtils.shouldBeWatched(block.getState())) {
|
||||
if (!(entity instanceof FallingBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
Block block = event.getBlock();
|
||||
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
||||
|
||||
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);
|
||||
}
|
||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
else {
|
||||
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
}
|
||||
else if (isTracked) {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,10 +174,6 @@ 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;
|
||||
@@ -199,7 +186,6 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
CombatUtils.processCombatAttack(event, attacker, target);
|
||||
CombatUtils.handleHealthbars(attacker, target, event.getDamage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,11 +226,6 @@ 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 */
|
||||
@@ -255,7 +236,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
switch (cause) {
|
||||
case FALL:
|
||||
if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
|
||||
if (Config.getInstance().getPreventXPAfterTeleport() && SkillUtils.calculateTimeLeft((long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -443,7 +424,7 @@ public class EntityListener implements Listener {
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -470,7 +451,7 @@ public class EntityListener implements Listener {
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -513,7 +494,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -576,14 +557,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();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -626,8 +603,9 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPotionSplash(PotionSplashEvent event) {
|
||||
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
|
||||
if (!effect.getType().equals(PotionEffectType.SATURATION)) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
||||
@@ -23,10 +22,8 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
@@ -35,9 +32,9 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -59,7 +56,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
HumanEntity player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,7 +73,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
HumanEntity player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,7 +92,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
Player player = getPlayerFromFurnace(furnaceBlock);
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
|
||||
if (Misc.isNPCEntity(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +110,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
Player player = getPlayerFromFurnace(furnaceBlock);
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !SkillType.SMELTING.getPermissions(player)) {
|
||||
if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,7 +129,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
Player player = getPlayerFromFurnace(furnaceBlock);
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
|
||||
if (Misc.isNPCEntity(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,167 +138,43 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryClickEventNormal(InventoryClickEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (!(inventory instanceof BrewerInventory)) {
|
||||
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
|
||||
if (!(holder instanceof BrewingStand)) {
|
||||
if (!(event.getWhoClicked() instanceof Player) || Misc.isNPCEntity(event.getWhoClicked()) || !Permissions.concoctions(event.getWhoClicked())) {
|
||||
return;
|
||||
}
|
||||
|
||||
HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) whoClicked;
|
||||
BrewingStand stand = (BrewingStand) holder;
|
||||
ItemStack clicked = event.getCurrentItem();
|
||||
ItemStack cursor = event.getCursor();
|
||||
|
||||
if ((clicked != null && clicked.getType() == Material.POTION) || (cursor != null && cursor.getType() == Material.POTION)) {
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
return;
|
||||
}
|
||||
|
||||
ClickType click = event.getClick();
|
||||
InventoryType.SlotType slot = event.getSlotType();
|
||||
|
||||
if (click.isShiftClick()) {
|
||||
switch (slot) {
|
||||
case FUEL:
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
return;
|
||||
case CONTAINER:
|
||||
case QUICKBAR:
|
||||
if (!AlchemyPotionBrewer.isValidIngredient(player, clicked)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), click)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (slot == InventoryType.SlotType.FUEL) {
|
||||
boolean emptyClicked = AlchemyPotionBrewer.isEmpty(clicked);
|
||||
|
||||
if (AlchemyPotionBrewer.isEmpty(cursor)) {
|
||||
if (emptyClicked && click == ClickType.NUMBER_KEY) {
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
return;
|
||||
}
|
||||
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
}
|
||||
else if (emptyClicked) {
|
||||
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
|
||||
int amount = cursor.getAmount();
|
||||
|
||||
if (click == ClickType.LEFT || (click == ClickType.RIGHT && amount == 1)) {
|
||||
event.setCancelled(true);
|
||||
event.setCurrentItem(cursor.clone());
|
||||
event.setCursor(null);
|
||||
|
||||
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
}
|
||||
else if (click == ClickType.RIGHT) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack one = cursor.clone();
|
||||
one.setAmount(1);
|
||||
|
||||
ItemStack rest = cursor.clone();
|
||||
rest.setAmount(amount - 1);
|
||||
|
||||
event.setCurrentItem(one);
|
||||
event.setCursor(rest);
|
||||
|
||||
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AlchemyPotionBrewer.handleInventoryClick(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryDragEvent(InventoryDragEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (!(inventory instanceof BrewerInventory)) {
|
||||
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
|
||||
if (!(holder instanceof BrewingStand)) {
|
||||
if (!(event.getWhoClicked() instanceof Player) || Misc.isNPCEntity(event.getWhoClicked()) || !Permissions.concoctions(event.getWhoClicked())) {
|
||||
return;
|
||||
}
|
||||
|
||||
HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack cursor = event.getCursor();
|
||||
ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();
|
||||
|
||||
if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
|
||||
Player player = (Player) whoClicked;
|
||||
|
||||
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
|
||||
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
|
||||
AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||
}
|
||||
AlchemyPotionBrewer.handleInventoryDrag(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
|
||||
Inventory inventory = event.getDestination();
|
||||
|
||||
if (!(inventory instanceof BrewerInventory)) {
|
||||
if (event.getDestination().getType() != InventoryType.BREWING || !(event.getDestination().getHolder() instanceof BrewingStand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
|
||||
if (!(holder instanceof BrewingStand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if (Config.getInstance().getPreventHopperTransfer() && item.getType() != Material.POTION) {
|
||||
if (Config.getInstance().getPreventHopperTransfer() && event.getItem() != null && event.getItem().getType() != Material.POTION) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
|
||||
AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
|
||||
if (Config.getInstance().getEnabledForHoppers()) {
|
||||
AlchemyPotionBrewer.handleInventoryMoveItem(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +187,7 @@ public class InventoryListener implements Listener {
|
||||
public void onCraftItem(CraftItemEvent event) {
|
||||
final HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
|
||||
if (Misc.isNPCEntity(whoClicked) || !(whoClicked instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ 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;
|
||||
@@ -59,7 +58,6 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||
import com.gmail.nossr50.util.Motd;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@@ -82,7 +80,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
|
||||
if (Misc.isNPCEntity(player) || !Config.getInstance().getPreventXPAfterTeleport() || event.getFrom().equals(event.getTo())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,7 +129,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player killedPlayer = event.getEntity();
|
||||
|
||||
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
if (Misc.isNPCEntity(killedPlayer) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,7 +164,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,7 +207,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerFishHighest(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,7 +252,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerFishMonitor(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -295,7 +293,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -305,7 +303,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).asString())) {
|
||||
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).value())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -345,7 +343,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,8 +352,7 @@ public class PlayerListener implements Listener {
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
BleedTimerTask.bleedOut(player);
|
||||
mcMMOPlayer.getProfile().save();
|
||||
UserManager.remove(player);
|
||||
ScoreboardManager.teardownPlayer(player);
|
||||
UserManager.remove(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,9 +372,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.addUser(player);
|
||||
mcMMOPlayer.actualizeRespawnATS();
|
||||
ScoreboardManager.setupPlayer(player);
|
||||
UserManager.addUser(player).actualizeRespawnATS();
|
||||
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
Motd.displayAll(player);
|
||||
@@ -406,7 +401,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -422,7 +417,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -513,7 +508,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -597,14 +592,21 @@ public class PlayerListener implements Listener {
|
||||
Material type = heldItem.getType();
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
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();
|
||||
switch (type) {
|
||||
case APPLE:
|
||||
tamingManager.summonHorse();
|
||||
break;
|
||||
|
||||
case BONE:
|
||||
tamingManager.summonWolf();
|
||||
break;
|
||||
|
||||
case RAW_FISH:
|
||||
tamingManager.summonOcelot();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -627,7 +629,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
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 ScoreboardsListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
ScoreboardManager.setupPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
ScoreboardManager.teardownPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
||||
ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
|
||||
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
|
||||
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,21 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
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)
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
SkillType skill = event.getSkill();
|
||||
|
||||
ScoreboardManager.handleLevelUp(player, skill);
|
||||
|
||||
if (!Config.getInstance().getLevelUpEffectsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) {
|
||||
skill.celebrateLevelUp(player);
|
||||
event.getSkill().celebrateLevelUp(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
|
||||
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
|
||||
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@@ -17,6 +18,7 @@ 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) {
|
||||
@@ -54,7 +56,9 @@ public class WorldListener implements Listener {
|
||||
|
||||
plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
||||
|
||||
new BlockStoreConversionMain(world).run();
|
||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
|
||||
converter.run();
|
||||
converters.add(converter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,12 +14,12 @@ 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.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.config.potion.PotionConfig;
|
||||
import com.gmail.nossr50.config.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
@@ -27,12 +27,12 @@ import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.ScoreboardsListener;
|
||||
import com.gmail.nossr50.listeners.SelfListener;
|
||||
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,7 +48,6 @@ 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;
|
||||
@@ -66,7 +65,6 @@ public class mcMMO extends JavaPlugin {
|
||||
/* Managers */
|
||||
private static ChunkManager placeStore;
|
||||
private static RepairableManager repairableManager;
|
||||
private static ModManager modManager;
|
||||
private static DatabaseManager databaseManager;
|
||||
private static FormulaManager formulaManager;
|
||||
private static HolidayManager holidayManager;
|
||||
@@ -88,6 +86,9 @@ 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;
|
||||
@@ -109,7 +110,6 @@ public class mcMMO extends JavaPlugin {
|
||||
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||
public final static String customDamageKey = "mcMMO: Custom Damage";
|
||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||
public final static String playerDataKey = "mcMMO: Player Data";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
|
||||
@@ -123,21 +123,21 @@ public class mcMMO extends JavaPlugin {
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
combatTagEnabled = pluginManager.getPlugin("CombatTag") != null;
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
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;
|
||||
|
||||
setupFilePaths();
|
||||
|
||||
modManager = new ModManager();
|
||||
|
||||
loadConfigFiles();
|
||||
|
||||
if (!noErrorsInConfigFiles) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getServer().getName().equals("MCPC+")) {
|
||||
if (mcpcEnabled) {
|
||||
checkModConfigs();
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class mcMMO extends JavaPlugin {
|
||||
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
||||
}
|
||||
|
||||
if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) {
|
||||
if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) {
|
||||
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
||||
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
||||
}
|
||||
@@ -294,10 +294,6 @@ public class mcMMO extends JavaPlugin {
|
||||
return databaseManager;
|
||||
}
|
||||
|
||||
public static ModManager getModManager() {
|
||||
return modManager;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
||||
mcMMO.databaseManager = databaseManager;
|
||||
@@ -311,6 +307,10 @@ public class mcMMO extends JavaPlugin {
|
||||
return healthBarPluginEnabled;
|
||||
}
|
||||
|
||||
public static boolean isMCPCEnabled() {
|
||||
return mcpcEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
@@ -329,47 +329,15 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
if (oldFlatfilePath.exists()) {
|
||||
if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) {
|
||||
getLogger().warning("Failed to rename FlatFileStuff to flatfile!");
|
||||
getLogger().warning("Failed to rename FlatFileStuff to flatfile !");
|
||||
}
|
||||
}
|
||||
|
||||
if (oldModPath.exists()) {
|
||||
if (!oldModPath.renameTo(new File(modDirectory))) {
|
||||
getLogger().warning("Failed to rename ModConfigs to mods!");
|
||||
getLogger().warning("Failed to rename ModConfigs to mods !");
|
||||
}
|
||||
}
|
||||
|
||||
File oldArmorFile = new File(modDirectory + "armor.yml");
|
||||
File oldBlocksFile = new File(modDirectory + "blocks.yml");
|
||||
File oldEntitiesFile = new File(modDirectory + "entities.yml");
|
||||
File oldToolsFile = new File(modDirectory + "tools.yml");
|
||||
|
||||
if (oldArmorFile.exists()) {
|
||||
if (!oldArmorFile.renameTo(new File(modDirectory + "armor.default.yml"))) {
|
||||
getLogger().warning("Failed to rename armor.yml to armor.default.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
if (oldBlocksFile.exists()) {
|
||||
if (!oldBlocksFile.renameTo(new File(modDirectory + "blocks.default.yml"))) {
|
||||
getLogger().warning("Failed to rename blocks.yml to blocks.default.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
if (oldEntitiesFile.exists()) {
|
||||
if (!oldEntitiesFile.renameTo(new File(modDirectory + "entities.default.yml"))) {
|
||||
getLogger().warning("Failed to rename entities.yml to entities.default.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
if (oldToolsFile.exists()) {
|
||||
if (!oldToolsFile.renameTo(new File(modDirectory + "tools.default.yml"))) {
|
||||
getLogger().warning("Failed to rename tools.yml to tools.default.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
File currentFlatfilePath = new File(flatFileDirectory);
|
||||
currentFlatfilePath.mkdirs();
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
@@ -405,24 +373,24 @@ public class mcMMO extends JavaPlugin {
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
new ToolConfigManager(this);
|
||||
repairables.addAll(CustomToolConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getArmorModsEnabled()) {
|
||||
new ArmorConfigManager(this);
|
||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getBlockModsEnabled()) {
|
||||
new BlockConfigManager(this);
|
||||
CustomBlockConfig.getInstance();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getEntityModsEnabled()) {
|
||||
new EntityConfigManager(this);
|
||||
CustomEntityConfig.getInstance();
|
||||
}
|
||||
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
|
||||
repairables.addAll(modManager.getLoadedRepairables());
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairableManager = new SimpleRepairableManager(repairables.size());
|
||||
repairableManager.registerRepairables(repairables);
|
||||
}
|
||||
@@ -436,6 +404,7 @@ public class mcMMO extends JavaPlugin {
|
||||
pluginManager.registerEvents(new EntityListener(this), this);
|
||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||
pluginManager.registerEvents(new SelfListener(), this);
|
||||
pluginManager.registerEvents(new ScoreboardsListener(), this);
|
||||
pluginManager.registerEvents(new WorldListener(this), this);
|
||||
}
|
||||
|
||||
@@ -478,10 +447,6 @@ 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() {
|
||||
|
||||
@@ -170,7 +170,7 @@ public final class PartyManager {
|
||||
*/
|
||||
public static Party getParty(String partyName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getName().equalsIgnoreCase(partyName)) {
|
||||
if (party.getName().equals(partyName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
@@ -260,11 +260,6 @@ 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);
|
||||
}
|
||||
|
||||
@@ -464,6 +459,16 @@ 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.
|
||||
*/
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -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, Block movedBlock) {
|
||||
public StickyPistonTrackerTask(BlockFace direction, Block block) {
|
||||
this.direction = direction;
|
||||
this.block = block;
|
||||
this.movedBlock = movedBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!BlockUtils.shouldBeWatched(movedBlock.getState()) || movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
||||
Block newBlock = block.getRelative(direction);
|
||||
Block originalBlock = newBlock.getRelative(direction);
|
||||
|
||||
if (originalBlock.getType() != Material.AIR || !mcMMO.getPlaceStore().isTrue(originalBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.getPlaceStore().setFalse(movedBlock);
|
||||
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
||||
mcMMO.getPlaceStore().setFalse(originalBlock);
|
||||
mcMMO.getPlaceStore().setTrue(newBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.getOfflinePlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
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.
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -12,6 +12,8 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
|
||||
public class AlchemyBrewCheckTask extends BukkitRunnable {
|
||||
private final static int INGREDIENT_SLOT = 3;
|
||||
|
||||
private Player player;
|
||||
private BrewingStand brewingStand;
|
||||
private ItemStack[] oldInventory;
|
||||
@@ -24,17 +26,18 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Location location = brewingStand.getLocation();
|
||||
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
|
||||
boolean validBrew = AlchemyPotionBrewer.isValidBrew(player, newInventory);
|
||||
Block block = brewingStand.getBlock();
|
||||
ItemStack[] newInventory = Arrays.copyOfRange(((BrewingStand) block.getState()).getInventory().getContents(), 0, 4);
|
||||
|
||||
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
|
||||
Alchemy.brewingStandMap.get(location).cancelBrew();
|
||||
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
|
||||
if (oldInventory[INGREDIENT_SLOT] == null || newInventory[INGREDIENT_SLOT] == null || !oldInventory[INGREDIENT_SLOT].isSimilar(newInventory[INGREDIENT_SLOT]) || !AlchemyPotionBrewer.isValidBrew(player, newInventory)) {
|
||||
Alchemy.brewingStandMap.get(brewingStand).cancelBrew();
|
||||
}
|
||||
}
|
||||
else if (validBrew) {
|
||||
Alchemy.brewingStandMap.put(location, new AlchemyBrewTask(brewingStand, player));
|
||||
|
||||
if (!Alchemy.brewingStandMap.containsKey(brewingStand) && AlchemyPotionBrewer.isValidBrew(player, newInventory)) {
|
||||
Alchemy.brewingStandMap.put(brewingStand, new AlchemyBrewTask(brewingStand, player));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
@@ -23,43 +22,44 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
||||
private static int DEFAULT_BREW_TICKS = 400;
|
||||
|
||||
private BlockState brewingStand;
|
||||
private Location location;
|
||||
private double brewSpeed;
|
||||
private double brewTimer;
|
||||
private Player player;
|
||||
|
||||
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
||||
this.brewingStand = brewingStand;
|
||||
this.location = brewingStand.getLocation();
|
||||
this.player = player;
|
||||
|
||||
brewSpeed = DEFAULT_BREW_SPEED;
|
||||
brewTimer = DEFAULT_BREW_TICKS;
|
||||
|
||||
if (player != null && !Misc.isNPCEntity(player) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CATALYSIS)) {
|
||||
double catalysis = UserManager.getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, SkillType.ALCHEMY));
|
||||
double catalysis = UserManager.getPlayer(player).getAlchemyManager().getBrewSpeed();
|
||||
|
||||
if (Permissions.lucky(player, SkillType.ALCHEMY)) {
|
||||
catalysis = UserManager.getPlayer(player).getAlchemyManager().getBrewSpeedLucky();
|
||||
}
|
||||
|
||||
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
brewSpeed = catalysis;
|
||||
}
|
||||
}
|
||||
|
||||
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||
Alchemy.brewingStandMap.get(location).cancel();
|
||||
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
|
||||
Alchemy.brewingStandMap.get(brewingStand).cancel();
|
||||
}
|
||||
|
||||
Alchemy.brewingStandMap.put(location, this);
|
||||
Alchemy.brewingStandMap.put(brewingStand, this);
|
||||
this.runTaskTimer(mcMMO.p, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) {
|
||||
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||
Alchemy.brewingStandMap.remove(location);
|
||||
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
|
||||
Alchemy.brewingStandMap.remove(brewingStand);
|
||||
}
|
||||
|
||||
this.cancel();
|
||||
@@ -87,20 +87,20 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
||||
AlchemyPotionBrewer.finishBrewing(brewingStand, player, false);
|
||||
}
|
||||
|
||||
Alchemy.brewingStandMap.remove(location);
|
||||
Alchemy.brewingStandMap.remove(brewingStand);
|
||||
}
|
||||
|
||||
public void finishImmediately() {
|
||||
this.cancel();
|
||||
|
||||
AlchemyPotionBrewer.finishBrewing(brewingStand, player, true);
|
||||
Alchemy.brewingStandMap.remove(location);
|
||||
Alchemy.brewingStandMap.remove(brewingStand);
|
||||
}
|
||||
|
||||
public void cancelBrew() {
|
||||
this.cancel();
|
||||
|
||||
((BrewingStand) brewingStand).setBrewingTime(-1);
|
||||
Alchemy.brewingStandMap.remove(location);
|
||||
Alchemy.brewingStandMap.remove(brewingStand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,10 @@ public abstract class SkillManager {
|
||||
this.skill = skill;
|
||||
}
|
||||
|
||||
public McMMOPlayer getMcMMOPlayer() {
|
||||
return mcMMOPlayer;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return mcMMOPlayer.getPlayer();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.gmail.nossr50.skills.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
@@ -46,30 +44,36 @@ public final class Alchemy {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int INGREDIENT_SLOT = 3;
|
||||
|
||||
public static int catalysisUnlockLevel = AdvancedConfig.getInstance().getCatalysisUnlockLevel();
|
||||
public static int catalysisMaxBonusLevel = AdvancedConfig.getInstance().getCatalysisMaxBonusLevel();
|
||||
public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
|
||||
public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();
|
||||
|
||||
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<Location, AlchemyBrewTask>();
|
||||
public static Map<BlockState, AlchemyBrewTask> brewingStandMap = new HashMap<BlockState, AlchemyBrewTask>();
|
||||
|
||||
private Alchemy() {}
|
||||
|
||||
/**
|
||||
* Calculate base brewing speed, given a skill level and ignoring all perks.
|
||||
*
|
||||
* @param skillLevel Skill level used for calculation.
|
||||
*
|
||||
* @return Base brewing speed for the level.
|
||||
*/
|
||||
public static double calculateBrewSpeed(int skillLevel) {
|
||||
if (skillLevel < catalysisUnlockLevel) {
|
||||
return catalysisMinSpeed;
|
||||
}
|
||||
|
||||
return Math.min(catalysisMaxSpeed, catalysisMinSpeed + (catalysisMaxSpeed - catalysisMinSpeed) * (skillLevel - catalysisUnlockLevel) / (catalysisMaxBonusLevel - catalysisUnlockLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish all active brews. Used upon Disable to prevent vanilla potions from being brewed upon next Enable.
|
||||
*/
|
||||
public static void finishAllBrews() {
|
||||
mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
|
||||
|
||||
List<AlchemyBrewTask> toFinish = new ArrayList<AlchemyBrewTask>();
|
||||
|
||||
for (AlchemyBrewTask alchemyBrewTask : brewingStandMap.values()) {
|
||||
toFinish.add(alchemyBrewTask);
|
||||
}
|
||||
|
||||
for (AlchemyBrewTask alchemyBrewTask : toFinish) {
|
||||
alchemyBrewTask.finishImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import java.util.List;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.config.potion.PotionConfig;
|
||||
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.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class AlchemyManager extends SkillManager {
|
||||
@@ -18,6 +20,23 @@ public class AlchemyManager extends SkillManager {
|
||||
super(mcMMOPlayer, SkillType.ALCHEMY);
|
||||
}
|
||||
|
||||
public boolean canCatalysis() {
|
||||
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.CATALYSIS);
|
||||
}
|
||||
|
||||
public boolean canConcoctions() {
|
||||
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.CONCOCTIONS);
|
||||
}
|
||||
|
||||
public boolean canUseIngredient(ItemStack item) {
|
||||
for (ItemStack ingredient : getIngredients()) {
|
||||
if (item.isSimilar(ingredient)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
for (Alchemy.Tier tier : Alchemy.Tier.values()) {
|
||||
if (getSkillLevel() >= tier.getLevel()) {
|
||||
@@ -29,17 +48,31 @@ public class AlchemyManager extends SkillManager {
|
||||
}
|
||||
|
||||
public List<ItemStack> getIngredients() {
|
||||
return PotionConfig.getInstance().getIngredients(getTier());
|
||||
switch (Alchemy.Tier.fromNumerical(getTier())) {
|
||||
case EIGHT:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierEight;
|
||||
case SEVEN:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierSeven;
|
||||
case SIX:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierSix;
|
||||
case FIVE:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierFive;
|
||||
case FOUR:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierFour;
|
||||
case THREE:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierThree;
|
||||
case TWO:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierTwo;
|
||||
default:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierOne;
|
||||
}
|
||||
}
|
||||
|
||||
public String getIngredientList() {
|
||||
StringBuilder list = new StringBuilder();
|
||||
|
||||
for (ItemStack ingredient : getIngredients()) {
|
||||
short durability = ingredient.getDurability();
|
||||
|
||||
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (durability != 0 ? ":" + durability : "");
|
||||
|
||||
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (ingredient.getDurability() != 0 ? ":" + ingredient.getDurability() : "");
|
||||
if (string.equals("Long Grass:2")) {
|
||||
string = "Fern";
|
||||
}
|
||||
@@ -47,20 +80,17 @@ public class AlchemyManager extends SkillManager {
|
||||
string = "Pufferfish";
|
||||
}
|
||||
|
||||
list.append(", ").append(string);
|
||||
list.append(", " + string);
|
||||
}
|
||||
|
||||
return list.substring(2);
|
||||
}
|
||||
|
||||
public double calculateBrewSpeed(boolean isLucky) {
|
||||
int skillLevel = getSkillLevel();
|
||||
public double getBrewSpeed() {
|
||||
return Alchemy.calculateBrewSpeed(getSkillLevel());
|
||||
}
|
||||
|
||||
if (skillLevel < Alchemy.catalysisUnlockLevel) {
|
||||
return Alchemy.catalysisMinSpeed;
|
||||
}
|
||||
|
||||
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
|
||||
public double getBrewSpeedLucky() {
|
||||
return LUCKY_MODIFIER * Alchemy.calculateBrewSpeed(getSkillLevel());
|
||||
}
|
||||
|
||||
public void handlePotionBrewSuccesses(int amount) {
|
||||
|
||||
@@ -8,69 +8,79 @@ import org.bukkit.block.BrewingStand;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.config.potion.PotionConfig;
|
||||
import com.gmail.nossr50.datatypes.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;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class AlchemyPotionBrewer {
|
||||
private final static int[] BOTTLE_SLOTS = new int[]{0, 1, 2};
|
||||
private final static int INGREDIENT_SLOT = 3;
|
||||
|
||||
public static boolean isValidBrew(Player player, ItemStack[] contents) {
|
||||
if (!isValidIngredient(player, contents[Alchemy.INGREDIENT_SLOT])) {
|
||||
if (!isValidIngredient(player, contents[INGREDIENT_SLOT])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (contents[i] == null || contents[i].getType() != Material.POTION) {
|
||||
continue;
|
||||
}
|
||||
for (int bottle : BOTTLE_SLOTS) {
|
||||
if (contents[bottle] != null && contents[bottle].getType() == Material.POTION) {
|
||||
AlchemyPotion potion = PotionConfig.getInstance().potionMap.get(contents[bottle].getDurability());
|
||||
|
||||
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i].getDurability()), contents[Alchemy.INGREDIENT_SLOT]) != null) {
|
||||
return true;
|
||||
if (getChildPotion(potion, contents[INGREDIENT_SLOT]) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private static AlchemyPotion getChildPotion(AlchemyPotion potion, ItemStack ingredient) {
|
||||
if (potion != null && potion.getChildDataValue(ingredient) != -1) {
|
||||
return PotionConfig.getInstance().getPotion(potion.getChildDataValue(ingredient));
|
||||
return PotionConfig.getInstance().potionMap.get(potion.getChildDataValue(ingredient));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isEmpty(ItemStack item) {
|
||||
private static boolean isEmpty(ItemStack item) {
|
||||
return item == null || item.getType() == Material.AIR || item.getAmount() == 0;
|
||||
}
|
||||
|
||||
private static boolean removeIngredient(BrewerInventory inventory, Player player) {
|
||||
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||
ItemStack ingredient = inventory.getIngredient();
|
||||
|
||||
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
|
||||
return false;
|
||||
}
|
||||
else if (ingredient.getAmount() <= 1) {
|
||||
inventory.setIngredient(null);
|
||||
inventory.setItem(INGREDIENT_SLOT, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
ingredient.setAmount(ingredient.getAmount() - 1);
|
||||
inventory.setIngredient(ingredient);
|
||||
inventory.setItem(INGREDIENT_SLOT, ingredient);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValidIngredient(Player player, ItemStack item) {
|
||||
private static boolean isValidIngredient(Player player, ItemStack item) {
|
||||
if (isEmpty(item)) {
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +95,28 @@ public final class AlchemyPotionBrewer {
|
||||
}
|
||||
|
||||
private static List<ItemStack> getValidIngredients(Player player) {
|
||||
return PotionConfig.getInstance().getIngredients((player == null || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
|
||||
if (player == null || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CONCOCTIONS)) {
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierOne;
|
||||
}
|
||||
|
||||
switch (UserManager.getPlayer(player).getAlchemyManager().getTier()) {
|
||||
case 8:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierEight;
|
||||
case 7:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierSeven;
|
||||
case 6:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierSix;
|
||||
case 5:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierFive;
|
||||
case 4:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierFour;
|
||||
case 3:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierThree;
|
||||
case 2:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierTwo;
|
||||
default:
|
||||
return PotionConfig.getInstance().concoctionsIngredientsTierOne;
|
||||
}
|
||||
}
|
||||
|
||||
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
|
||||
@@ -100,21 +131,17 @@ public final class AlchemyPotionBrewer {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
for (int bottle : BOTTLE_SLOTS) {
|
||||
if (!isEmpty(inventory.getItem(bottle)) && PotionConfig.getInstance().potionMap.containsKey(inventory.getItem(bottle).getDurability())) {
|
||||
AlchemyPotion input = PotionConfig.getInstance().potionMap.get(inventory.getItem(bottle).getDurability());
|
||||
AlchemyPotion output = PotionConfig.getInstance().potionMap.get(input.getChildDataValue(ingredient));
|
||||
|
||||
if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) {
|
||||
continue;
|
||||
}
|
||||
if (output != null) {
|
||||
inventory.setItem(bottle, output.toItemStack(inventory.getItem(bottle).getAmount()).clone());
|
||||
|
||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
|
||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
||||
|
||||
if (output != null) {
|
||||
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
|
||||
|
||||
if (player != null) {
|
||||
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
|
||||
if (player != null) {
|
||||
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,35 +151,18 @@ public final class AlchemyPotionBrewer {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean transferItems(InventoryView view, int fromSlot, ClickType click) {
|
||||
boolean success = false;
|
||||
|
||||
if (click.isLeftClick()) {
|
||||
success = transferItems(view, fromSlot);
|
||||
}
|
||||
else if (click.isRightClick()) {
|
||||
success = transferOneItem(view, fromSlot);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private static boolean transferOneItem(InventoryView view, int fromSlot) {
|
||||
private static boolean transferOneItem(InventoryView view, int fromSlot, int toSlot) {
|
||||
ItemStack from = view.getItem(fromSlot).clone();
|
||||
ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
|
||||
ItemStack to = view.getItem(toSlot).clone();
|
||||
|
||||
if (isEmpty(from)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean emptyTo = isEmpty(to);
|
||||
int fromAmount = from.getAmount();
|
||||
|
||||
if (!emptyTo && fromAmount >= from.getType().getMaxStackSize()) {
|
||||
else if (!isEmpty(to) && from.getAmount() >= from.getType().getMaxStackSize()) {
|
||||
return false;
|
||||
}
|
||||
else if (emptyTo || from.isSimilar(to)) {
|
||||
if (emptyTo) {
|
||||
else if (isEmpty(to) || from.isSimilar(to)) {
|
||||
if (isEmpty(to)) {
|
||||
to = from.clone();
|
||||
to.setAmount(1);
|
||||
}
|
||||
@@ -160,9 +170,9 @@ public final class AlchemyPotionBrewer {
|
||||
to.setAmount(to.getAmount() + 1);
|
||||
}
|
||||
|
||||
from.setAmount(fromAmount - 1);
|
||||
view.setItem(Alchemy.INGREDIENT_SLOT, to);
|
||||
view.setItem(fromSlot, from);
|
||||
from.setAmount(from.getAmount() - 1);
|
||||
view.setItem(toSlot, isEmpty(to) ? null : to);
|
||||
view.setItem(fromSlot, isEmpty(from) ? null : from);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -173,51 +183,167 @@ public final class AlchemyPotionBrewer {
|
||||
/**
|
||||
* Transfer items between two ItemStacks, returning the leftover status
|
||||
*/
|
||||
private static boolean transferItems(InventoryView view, int fromSlot) {
|
||||
ItemStack from = view.getItem(fromSlot).clone();
|
||||
ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
|
||||
|
||||
if (isEmpty(from)) {
|
||||
private static boolean transferItems(InventoryView view, int fromSlot, int toSlot) {
|
||||
if (isEmpty(view.getItem(fromSlot))) {
|
||||
return false;
|
||||
}
|
||||
else if (isEmpty(to)) {
|
||||
view.setItem(Alchemy.INGREDIENT_SLOT, from);
|
||||
else if (isEmpty(view.getItem(toSlot))) {
|
||||
view.setItem(toSlot, view.getItem(fromSlot).clone());
|
||||
view.setItem(fromSlot, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (from.isSimilar(to)) {
|
||||
int fromAmount = from.getAmount();
|
||||
int toAmount = to.getAmount();
|
||||
int maxSize = to.getType().getMaxStackSize();
|
||||
else if (view.getItem(fromSlot).isSimilar(view.getItem(toSlot))) {
|
||||
if (view.getItem(fromSlot).getAmount() + view.getItem(toSlot).getAmount() > view.getItem(toSlot).getType().getMaxStackSize()) {
|
||||
int left = view.getItem(fromSlot).getAmount() + view.getItem(toSlot).getAmount() - view.getItem(toSlot).getType().getMaxStackSize();
|
||||
|
||||
if (fromAmount + toAmount > maxSize) {
|
||||
int left = fromAmount + toAmount - maxSize;
|
||||
|
||||
to.setAmount(maxSize);
|
||||
view.setItem(Alchemy.INGREDIENT_SLOT, to);
|
||||
ItemStack to = new ItemStack(view.getItem(toSlot));
|
||||
to.setAmount(to.getType().getMaxStackSize());
|
||||
view.setItem(toSlot, to);
|
||||
|
||||
ItemStack from = new ItemStack(view.getItem(fromSlot));
|
||||
from.setAmount(left);
|
||||
view.setItem(fromSlot, from);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
to.setAmount(fromAmount + toAmount);
|
||||
ItemStack to = new ItemStack(view.getItem(toSlot));
|
||||
to.setAmount(view.getItem(fromSlot).getAmount() + view.getItem(toSlot).getAmount());
|
||||
view.setItem(fromSlot, null);
|
||||
view.setItem(Alchemy.INGREDIENT_SLOT, to);
|
||||
view.setItem(toSlot, to);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void scheduleCheck(Player player, BrewingStand brewingStand) {
|
||||
public static void handleInventoryClick(InventoryClickEvent event) {
|
||||
Player player = event.getWhoClicked() instanceof Player ? (Player) event.getWhoClicked() : null;
|
||||
BrewingStand brewingStand = (BrewingStand) event.getInventory().getHolder();
|
||||
|
||||
ItemStack cursor = event.getCursor();
|
||||
ItemStack clicked = event.getCurrentItem();
|
||||
|
||||
if (clicked != null && clicked.getType() == Material.POTION) {
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
if (event.isShiftClick()) {
|
||||
if (event.getSlotType() == SlotType.FUEL) {
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (event.getSlotType() == SlotType.CONTAINER || event.getSlotType() == SlotType.QUICKBAR) {
|
||||
if (isValidIngredient(player, clicked)) {
|
||||
if (event.isLeftClick()) {
|
||||
transferItems(event.getView(), event.getRawSlot(), INGREDIENT_SLOT);
|
||||
}
|
||||
else if (event.isRightClick()) {
|
||||
transferOneItem(event.getView(), event.getRawSlot(), INGREDIENT_SLOT);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
scheduleUpdate(brewingStand.getInventory());
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getRawSlot() == INGREDIENT_SLOT) {
|
||||
if (isEmpty(cursor) && isEmpty(clicked)) {
|
||||
return;
|
||||
}
|
||||
else if (isEmpty(cursor)) {
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (isEmpty(clicked)) {
|
||||
if (isValidIngredient(player, event.getCursor())) {
|
||||
if (event.getClick() == ClickType.LEFT || (event.getClick() == ClickType.RIGHT && event.getCursor().getAmount() == 1)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
event.setCurrentItem(event.getCursor().clone());
|
||||
event.setCursor(null);
|
||||
|
||||
scheduleUpdate(brewingStand.getInventory());
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (event.getClick() == ClickType.RIGHT) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack one = event.getCursor().clone();
|
||||
one.setAmount(1);
|
||||
|
||||
ItemStack rest = event.getCursor().clone();
|
||||
rest.setAmount(event.getCursor().getAmount() - 1);
|
||||
|
||||
event.setCurrentItem(one);
|
||||
event.setCursor(rest);
|
||||
|
||||
scheduleUpdate(brewingStand.getInventory());
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleInventoryDrag(InventoryDragEvent event) {
|
||||
Player player = event.getWhoClicked() instanceof Player ? (Player) event.getWhoClicked() : null;
|
||||
BrewingStand brewingStand = (BrewingStand) event.getInventory().getHolder();
|
||||
|
||||
ItemStack cursor = event.getCursor();
|
||||
ItemStack ingredient = brewingStand.getInventory().getIngredient();
|
||||
|
||||
if (!event.getInventorySlots().contains(INGREDIENT_SLOT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
|
||||
if (isValidIngredient(player, cursor)) {
|
||||
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
event.setCancelled(true);
|
||||
|
||||
scheduleUpdate(brewingStand.getInventory());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void handleInventoryMoveItem(InventoryMoveItemEvent event) {
|
||||
Player player = null;
|
||||
BrewingStand brewingStand = (BrewingStand) event.getDestination().getHolder();
|
||||
|
||||
if (isValidIngredient(player, event.getItem())) {
|
||||
scheduleCheck(player, brewingStand);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void scheduleCheck(Player player, BrewingStand brewingStand) {
|
||||
new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
|
||||
}
|
||||
|
||||
public static void scheduleUpdate(Inventory inventory) {
|
||||
private static void scheduleUpdate(Inventory inventory) {
|
||||
for (HumanEntity humanEntity : inventory.getViewers()) {
|
||||
if (humanEntity instanceof Player) {
|
||||
new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p);
|
||||
|
||||
@@ -4,10 +4,12 @@ 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;
|
||||
|
||||
@@ -61,4 +63,14 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
|
||||
Location firedLocation = Archery.stringToLocation(damager.getMetadata(mcMMO.arrowDistanceKey).get(0).asString());
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
if (firedLocation.getWorld() != targetLocation.getWorld()) {
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
|
||||
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;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
|
||||
public class Excavation {
|
||||
/**
|
||||
@@ -52,8 +52,8 @@ public class Excavation {
|
||||
protected static int getBlockXP(BlockState blockState) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
if (xp == 0 && ModUtils.isCustomExcavationBlock(blockState)) {
|
||||
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
return xp;
|
||||
|
||||
@@ -54,6 +54,8 @@ 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() {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -135,8 +136,8 @@ public class HerbalismManager extends SkillManager {
|
||||
int xp;
|
||||
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||
|
||||
if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) {
|
||||
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
|
||||
if (ModUtils.isCustomHerbalismBlock(blockState)) {
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
|
||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) {
|
||||
|
||||
@@ -4,11 +4,11 @@ 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;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
|
||||
public class Mining {
|
||||
|
||||
@@ -21,8 +21,8 @@ public class Mining {
|
||||
Material blockType = blockState.getType();
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) {
|
||||
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
return xp;
|
||||
@@ -65,7 +65,7 @@ public class Mining {
|
||||
return;
|
||||
|
||||
default:
|
||||
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||
}
|
||||
return;
|
||||
@@ -104,7 +104,7 @@ public class Mining {
|
||||
return;
|
||||
|
||||
default:
|
||||
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
@@ -69,7 +70,7 @@ public class MiningManager extends SkillManager {
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
}
|
||||
|
||||
if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||
if ((ModUtils.isCustomMiningBlock(blockState) && !ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,8 +116,8 @@ public class MiningManager extends SkillManager {
|
||||
/**
|
||||
* Handler for explosion drops and XP gain.
|
||||
*
|
||||
* @param yield The % of blocks to drop
|
||||
* @param blockList The list of blocks to drop
|
||||
* @param yield
|
||||
* @param blockList
|
||||
*/
|
||||
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
|
||||
List<BlockState> ores = new ArrayList<BlockState>();
|
||||
|
||||
@@ -90,15 +90,7 @@ 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));
|
||||
@@ -111,6 +103,14 @@ 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 && (100 - getDowngradeEnchantChance()) <= Misc.getRandom().nextInt(activationChance)) {
|
||||
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
||||
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
||||
downgraded = true;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class SimpleRepairableManager implements RepairableManager {
|
||||
private HashMap<Material, Repairable> repairables;
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ 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;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
|
||||
public class Smelting {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
@@ -50,6 +50,6 @@ public class Smelting {
|
||||
MaterialData data = smelting.getData();
|
||||
Material resourceType = smelting.getType();
|
||||
|
||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
|
||||
return ModUtils.isCustomOre(data) ? ModUtils.getCustomBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ 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;
|
||||
@@ -146,7 +145,7 @@ public class TamingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWCost(EntityType.OCELOT));
|
||||
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWOcelotCost());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +156,7 @@ public class TamingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWCost(EntityType.WOLF));
|
||||
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWWolfCost());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +167,7 @@ public class TamingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
callOfTheWild(EntityType.HORSE, Config.getInstance().getTamingCOTWCost(EntityType.HORSE));
|
||||
callOfTheWild(EntityType.HORSE, Config.getInstance().getTamingCOTWHorseCost());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,16 +226,8 @@ 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:
|
||||
@@ -255,7 +246,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.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
|
||||
horse.setJumpStrength(Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength()));
|
||||
//TODO: setSpeed, once available
|
||||
break;
|
||||
|
||||
@@ -269,7 +260,7 @@ public class TamingManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
||||
player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public final class Woodcutting {
|
||||
@@ -51,8 +52,8 @@ public final class Woodcutting {
|
||||
break;
|
||||
}
|
||||
|
||||
if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
if (ModUtils.isCustomLogBlock(blockState)) {
|
||||
return ModUtils.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
switch (((Tree) blockState.getData()).getSpecies()) {
|
||||
@@ -85,7 +86,7 @@ public final class Woodcutting {
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
protected static void checkForDoubleDrop(BlockState blockState) {
|
||||
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
|
||||
if (ModUtils.isCustomLogBlock(blockState) && ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) {
|
||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -11,7 +11,6 @@ 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;
|
||||
@@ -23,6 +22,7 @@ import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -126,18 +126,18 @@ public class WoodcuttingManager extends SkillManager {
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||
}
|
||||
else if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||
else if (ModUtils.isCustomLogBlock(blockState)) {
|
||||
if (canGetDoubleDrops()) {
|
||||
Woodcutting.checkForDoubleDrop(blockState);
|
||||
}
|
||||
|
||||
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
|
||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
|
||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||
}
|
||||
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
|
||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||
else if (ModUtils.isCustomLeafBlock(blockState)) {
|
||||
Misc.randomDropItems(blockState.getLocation(), block.getDrops(), 10.0);
|
||||
}
|
||||
else {
|
||||
Tree tree = (Tree) blockState.getData();
|
||||
|
||||
@@ -12,7 +12,6 @@ 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 {
|
||||
@@ -65,7 +64,7 @@ public final class BlockUtils {
|
||||
return false;
|
||||
|
||||
default:
|
||||
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
|
||||
return !isMcMMOAnvil(blockState) && !ModUtils.isCustomAbilityBlock(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +135,7 @@ public final class BlockUtils {
|
||||
return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
||||
return ModUtils.isCustomHerbalismBlock(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +157,7 @@ public final class BlockUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
|
||||
return isOre(blockState) || ModUtils.isCustomMiningBlock(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ public final class BlockUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
||||
return ModUtils.isCustomExcavationBlock(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +199,7 @@ public final class BlockUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomLog(blockState);
|
||||
return ModUtils.isCustomLogBlock(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +215,7 @@ public final class BlockUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomLeaf(blockState);
|
||||
return ModUtils.isCustomLeafBlock(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,56 +19,25 @@ 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 static final int START_YEAR = 2011;
|
||||
private final int startYear = 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>();
|
||||
@@ -196,7 +165,7 @@ public final class HolidayManager {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.BLUE + "Happy " + (currentYear - START_YEAR) + " Year Anniversary! In honor of all of");
|
||||
sender.sendMessage(ChatColor.BLUE + "Happy " + (currentYear - startYear) + " 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;
|
||||
@@ -252,11 +221,11 @@ public final class HolidayManager {
|
||||
hasCelebrated.add(sender.getName());
|
||||
}
|
||||
|
||||
public boolean getDateRange(Date date, Date start, Date end) {
|
||||
private boolean getDateRange(Date date, Date start, Date end) {
|
||||
return !(date.before(start) || date.after(end));
|
||||
}
|
||||
|
||||
public void spawnFireworks(Player player) {
|
||||
private 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;
|
||||
@@ -285,31 +254,4 @@ 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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
@@ -30,7 +33,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomBow(type);
|
||||
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomBow(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +55,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomSword(type);
|
||||
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomSword(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +77,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomHoe(type);
|
||||
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomHoe(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomShovel(type);
|
||||
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomShovel(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +121,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomAxe(type);
|
||||
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomAxe(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +143,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomPickaxe(type);
|
||||
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomPickaxe(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +165,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomHelmet(type);
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomHelmet(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +187,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomChestplate(type);
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomChestplate(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +209,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomLeggings(type);
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomLeggings(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +231,7 @@ public final class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomBoots(type);
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomBoots(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +501,11 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isSmeltable(ItemStack item) {
|
||||
return item != null && MaterialUtils.isOre(item.getData());
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MaterialUtils.isOre(item.getData());
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack item) {
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public final class MaterialUtils {
|
||||
private MaterialUtils() {}
|
||||
|
||||
@@ -21,7 +19,7 @@ public final class MaterialUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomOre(data);
|
||||
return ModUtils.isCustomOre(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ 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;
|
||||
|
||||
@@ -63,7 +64,11 @@ 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) {
|
||||
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
|
||||
if (first.getWorld() != second.getWorld()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
|
||||
}
|
||||
|
||||
public static void dropItems(Location location, Collection<ItemStack> drops) {
|
||||
@@ -85,6 +90,41 @@ 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.
|
||||
*
|
||||
@@ -109,10 +149,11 @@ public final class Misc {
|
||||
}
|
||||
|
||||
public static void profileCleanup(String playerName) {
|
||||
UserManager.remove(playerName);
|
||||
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player != null) {
|
||||
UserManager.remove(player);
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class MobHealthbarUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
return ModUtils.isCustomBossEntity(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,284 +0,0 @@
|
||||
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;
|
||||
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
||||
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.skills.repair.repairables.Repairable;
|
||||
|
||||
public class ModManager {
|
||||
private List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
// Armor Mods
|
||||
private List<Material> customBoots = new ArrayList<Material>();
|
||||
private List<Material> customChestplates = new ArrayList<Material>();
|
||||
private List<Material> customHelmets = new ArrayList<Material>();
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
// Block Mods
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
|
||||
// Entity Mods
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
|
||||
// Tool Mods
|
||||
private List<Material> customAxes = new ArrayList<Material>();
|
||||
private List<Material> customBows = new ArrayList<Material>();
|
||||
private List<Material> customHoes = new ArrayList<Material>();
|
||||
private List<Material> customPickaxes = new ArrayList<Material>();
|
||||
private List<Material> customShovels = new ArrayList<Material>();
|
||||
private List<Material> customSwords = new ArrayList<Material>();
|
||||
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
|
||||
public void registerCustomArmor(CustomArmorConfig config) {
|
||||
customBoots.addAll(config.customBoots);
|
||||
customChestplates.addAll(config.customChestplates);
|
||||
customHelmets.addAll(config.customHelmets);
|
||||
customLeggings.addAll(config.customLeggings);
|
||||
repairables.addAll(config.repairables);
|
||||
}
|
||||
|
||||
public void registerCustomBlocks(CustomBlockConfig config) {
|
||||
customExcavationBlocks.addAll(config.customExcavationBlocks);
|
||||
customHerbalismBlocks.addAll(config.customHerbalismBlocks);
|
||||
customMiningBlocks.addAll(config.customMiningBlocks);
|
||||
customOres.addAll(config.customOres);
|
||||
customLogs.addAll(config.customLogs);
|
||||
customLeaves.addAll(config.customLeaves);
|
||||
customAbilityBlocks.addAll(config.customAbilityBlocks);
|
||||
customBlockMap.putAll(config.customBlockMap);
|
||||
}
|
||||
|
||||
public void registerCustomEntities(CustomEntityConfig config) {
|
||||
customEntityClassMap.putAll(config.customEntityClassMap);
|
||||
customEntityTypeMap.putAll(config.customEntityTypeMap);
|
||||
}
|
||||
|
||||
public void registerCustomTools(CustomToolConfig config) {
|
||||
customAxes.addAll(config.customAxes);
|
||||
customBows.addAll(config.customBows);
|
||||
customHoes.addAll(config.customHoes);
|
||||
customPickaxes.addAll(config.customPickaxes);
|
||||
customShovels.addAll(config.customShovels);
|
||||
customSwords.addAll(config.customSwords);
|
||||
customToolMap.putAll(config.customToolMap);
|
||||
repairables.addAll(config.repairables);
|
||||
}
|
||||
|
||||
public boolean isCustomBoots(Material material) {
|
||||
return Config.getInstance().getArmorModsEnabled() && customBoots.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomChestplate(Material material) {
|
||||
return Config.getInstance().getArmorModsEnabled() && customChestplates.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomHelmet(Material material) {
|
||||
return Config.getInstance().getArmorModsEnabled() && customHelmets.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomLeggings(Material material) {
|
||||
return Config.getInstance().getArmorModsEnabled() && customLeggings.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomAxe(Material material) {
|
||||
return Config.getInstance().getToolModsEnabled() && customAxes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomBow(Material material) {
|
||||
return Config.getInstance().getToolModsEnabled() && customBows.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomHoe(Material material) {
|
||||
return Config.getInstance().getToolModsEnabled() && customHoes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomPickaxe(Material material) {
|
||||
return Config.getInstance().getToolModsEnabled() && customPickaxes.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomShovel(Material material) {
|
||||
return Config.getInstance().getToolModsEnabled() && customShovels.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomSword(Material material) {
|
||||
return Config.getInstance().getToolModsEnabled() && customSwords.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomOre(MaterialData data) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customOres.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomLog(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customLogs.contains(state.getData());
|
||||
}
|
||||
|
||||
public boolean isCustomLeaf(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customLeaves.contains(state.getData());
|
||||
}
|
||||
|
||||
public boolean isCustomAbilityBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getData());
|
||||
}
|
||||
|
||||
public boolean isCustomExcavationBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getData());
|
||||
}
|
||||
|
||||
public boolean isCustomHerbalismBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getData());
|
||||
}
|
||||
|
||||
public boolean isCustomMiningBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getData());
|
||||
}
|
||||
|
||||
public CustomBlock getBlock(BlockState state) {
|
||||
return customBlockMap.get(state.getData());
|
||||
}
|
||||
|
||||
public CustomBlock getBlock(MaterialData data) {
|
||||
return customBlockMap.get(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public boolean isCustomTool(ItemStack item) {
|
||||
return Config.getInstance().getToolModsEnabled() && item != null && customToolMap.containsKey(item.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public CustomTool getTool(ItemStack item) {
|
||||
return item == null ? null : customToolMap.get(item.getType());
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
return repairables;
|
||||
}
|
||||
|
||||
public boolean isCustomEntity(Entity entity) {
|
||||
if (!Config.getInstance().getEntityModsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (customEntityTypeMap.containsKey(entity.getType().toString())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||
return customEntityClassMap.containsKey(entity.getClass().getName());
|
||||
}
|
||||
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public CustomEntity getEntity(Entity entity) {
|
||||
CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
|
||||
|
||||
if (customEntity == null) {
|
||||
try {
|
||||
customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||
customEntity = customEntityClassMap.get(entity.getClass().getName());
|
||||
}
|
||||
else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return customEntity;
|
||||
}
|
||||
|
||||
public void addCustomEntity(Entity entity) {
|
||||
if (!Config.getInstance().getEntityModsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
File entityFile = new File(mcMMO.p.getDataFolder(), "mods" + File.separator + "entities.default.yml");
|
||||
YamlConfiguration entitiesFile = YamlConfiguration.loadConfiguration(entityFile);
|
||||
|
||||
String entityName = entity.getType().toString();
|
||||
String sanitizedEntityName = entityName.replace(".", "_");
|
||||
|
||||
if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
entitiesFile.set(sanitizedEntityName + ".XP_Multiplier", 1.0D);
|
||||
entitiesFile.set(sanitizedEntityName + ".Tameable", false);
|
||||
entitiesFile.set(sanitizedEntityName + ".Taming_XP", 0);
|
||||
entitiesFile.set(sanitizedEntityName + ".CanBeSummoned", false);
|
||||
entitiesFile.set(sanitizedEntityName + ".COTW_Material", "");
|
||||
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Data", 0);
|
||||
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Amount", 0);
|
||||
|
||||
String className = "";
|
||||
|
||||
try {
|
||||
className = ((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName();
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||
className = entity.getClass().getName();
|
||||
}
|
||||
else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
CustomEntity customEntity = new CustomEntity(1.0D, false, 0, false, null, 0);
|
||||
customEntityTypeMap.put(entityName, customEntity);
|
||||
customEntityClassMap.put(className, customEntity);
|
||||
|
||||
try {
|
||||
entitiesFile.save(entityFile);
|
||||
mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
213
src/main/java/com/gmail/nossr50/util/ModUtils.java
Normal file
213
src/main/java/com/gmail/nossr50/util/ModUtils.java
Normal file
@@ -0,0 +1,213 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
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.CustomBlockConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
||||
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;
|
||||
|
||||
public final class ModUtils {
|
||||
private static boolean customToolsEnabled = Config.getInstance().getToolModsEnabled();
|
||||
private static boolean customBlocksEnabled = Config.getInstance().getBlockModsEnabled();
|
||||
private static boolean customEntitiesEnabled = Config.getInstance().getEntityModsEnabled();
|
||||
|
||||
private ModUtils() {}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
return CustomToolConfig.getInstance().getCustomTool(item.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom entity associated with an entity.
|
||||
*
|
||||
* @param entity The entity to check
|
||||
* @return the entity is if exists, null otherwise
|
||||
*/
|
||||
public static CustomEntity getCustomEntity(Entity entity) {
|
||||
return CustomEntityConfig.getInstance().getCustomEntity(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom block associated with an block.
|
||||
*
|
||||
* @param blockState The BlockState of the bloc to check
|
||||
* @return the block if it exists, null otherwise
|
||||
*/
|
||||
public static CustomBlock getCustomBlock(BlockState blockState) {
|
||||
return CustomBlockConfig.getInstance().getCustomBlock(blockState.getData());
|
||||
}
|
||||
|
||||
public static CustomBlock getCustomBlock(MaterialData data) {
|
||||
return CustomBlockConfig.getInstance().getCustomBlock(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a woodcutting block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents a custom woodcutting block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomWoodcuttingBlock(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block should not activate abilites.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents an ability block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomAbilityBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomAbilityBlock(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a mining block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents a custom mining block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomMiningBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomMiningBlock(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an excavation block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents a custom excavation block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomExcavationBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomExcavationBlock(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an herbalism block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents a custom herbalism block, false otherwise
|
||||
*/
|
||||
public static boolean isCustomHerbalismBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomHerbalismBlock(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a leaf block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents leaves, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLeafBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomLeaf(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a log block.
|
||||
*
|
||||
* @param blockState The BlockState of the block to check
|
||||
* @return true if the block represents a log, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLogBlock(BlockState blockState) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomLog(blockState.getData());
|
||||
}
|
||||
|
||||
public static boolean isCustomOre(MaterialData data) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomOre(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomTool(ItemStack item) {
|
||||
return customToolsEnabled && CustomToolConfig.getInstance().isCustomTool(item.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an entity is a custom entity.
|
||||
*
|
||||
* @param entity Entity to check
|
||||
* @return true if the entity is a custom entity, false otherwise
|
||||
*/
|
||||
public static boolean isCustomEntity(Entity entity) {
|
||||
return customEntitiesEnabled && CustomEntityConfig.getInstance().isCustomEntity(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom entity is a boss.
|
||||
*
|
||||
* @param entity The entity to check
|
||||
* @return true if the entity represents a boss, false otherwise
|
||||
*/
|
||||
public static boolean isCustomBossEntity(Entity entity) {
|
||||
//TODO: Finish this method
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addCustomEntity(Entity entity) {
|
||||
if (!customEntitiesEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
File entityFile = CustomEntityConfig.getInstance().getFile();
|
||||
YamlConfiguration entitiesFile = YamlConfiguration.loadConfiguration(entityFile);
|
||||
|
||||
String entityName = entity.getType().toString();
|
||||
String sanitizedEntityName = entityName.replace(".", "_");
|
||||
|
||||
if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
entitiesFile.set(sanitizedEntityName + ".XP_Multiplier", 1.0D);
|
||||
entitiesFile.set(sanitizedEntityName + ".Tameable", false);
|
||||
entitiesFile.set(sanitizedEntityName + ".Taming_XP", 0);
|
||||
entitiesFile.set(sanitizedEntityName + ".CanBeSummoned", false);
|
||||
entitiesFile.set(sanitizedEntityName + ".COTW_Material", "");
|
||||
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Data", 0);
|
||||
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Amount", 0);
|
||||
|
||||
String className = "";
|
||||
|
||||
try {
|
||||
className = ((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName();
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
||||
className = entity.getClass().getName();
|
||||
}
|
||||
else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
CustomEntityConfig.getInstance().addEntity(new CustomEntity(1.0D, false, 0, false, null, 0), className, entityName);
|
||||
|
||||
try {
|
||||
entitiesFile.save(entityFile);
|
||||
mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,7 @@ public final class Motd {
|
||||
* @param version Plugin version
|
||||
*/
|
||||
public static void displayVersion(Player player, String version) {
|
||||
if (Permissions.showversion(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Version", version));
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Version", version));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,6 @@ 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"); }
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
|
||||
|
||||
public class HashChunkManager implements ChunkManager {
|
||||
private static final int FILE_VERSION = 1;
|
||||
private HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>>();
|
||||
public HashMap<String, ChunkStore> store = new HashMap<String, ChunkStore>();
|
||||
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<BlockStoreConversionZDirectory>();
|
||||
@@ -120,7 +121,21 @@ public class HashChunkManager implements ChunkManager {
|
||||
McMMOSimpleRegionFile regionFile = worldRegions.get(key2);
|
||||
|
||||
if (regionFile == null) {
|
||||
File file = new File(directory, "mcmmo_" + rx + "_" + rz + "_.mcm");
|
||||
// Pre-Versioned files in negative chunks were being saved/tracked with incorrect chunk numbers
|
||||
int xLegacy = (x < -1) ? (x + 1) >> 5 : rx;
|
||||
int zLegacy = (z < -1) ? (z + 1) >> 5 : rz;
|
||||
File legacy = new File(directory, "mcmmo_" + xLegacy + "_" + zLegacy + "_.mcm");
|
||||
File file = new File(directory, "mcmmo_" + rx + "_" + rz + "_.v" + FILE_VERSION + ".mcm");
|
||||
// If the legacy file exists, rename it and the loading will convert it properly
|
||||
if (legacy.isFile()) {
|
||||
// The center 4 chunks are unusable so we don't preserve them
|
||||
if (!((rx == 0 || rx == -1) && (rz == 0 || rz == -1))) {
|
||||
if (!legacy.renameTo(file)) {
|
||||
mcMMO.p.debug(String.format("Lost Legacy ChunkStore for %d %d", rx, rz));
|
||||
}
|
||||
}
|
||||
legacy.delete();
|
||||
}
|
||||
regionFile = new McMMOSimpleRegionFile(file, rx, rz);
|
||||
worldRegions.put(key2, regionFile);
|
||||
}
|
||||
@@ -293,8 +308,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
int cx = (x < 0 ? x - 16 : x) >> 4 << 4;
|
||||
int cz = (z < 0 ? z - 16 : z) >> 4 << 4;
|
||||
String key = world.getName() + "," + cx + "," + cz;
|
||||
|
||||
if (!store.containsKey(key)) {
|
||||
@@ -336,8 +351,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
int cx = (x < 0 ? x - 16 : x) >> 4 << 4;
|
||||
int cz = (z < 0 ? z - 16 : z) >> 4 << 4;
|
||||
|
||||
int ix = Math.abs(x) % 16;
|
||||
int iz = Math.abs(z) % 16;
|
||||
@@ -382,8 +397,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
int cx = (x < 0 ? x - 16 : x) >> 4 << 4;
|
||||
int cz = (z < 0 ? z - 16 : z) >> 4 << 4;
|
||||
|
||||
int ix = Math.abs(x) % 16;
|
||||
int iz = Math.abs(z) % 16;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
transient private boolean dirty = false;
|
||||
/** X, Z, Y */
|
||||
public boolean[][][] store;
|
||||
private static final int CURRENT_VERSION = 7;
|
||||
private static final int CURRENT_VERSION = 8;
|
||||
private static final int MAGIC_NUMBER = 0xEA5EDEBB;
|
||||
private int cx;
|
||||
private int cz;
|
||||
@@ -132,6 +132,16 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
fixArray();
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if (fileVersionNumber == 7 && cx < 0) {
|
||||
cx--;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if (fileVersionNumber == 7 && cz < 0) {
|
||||
cz--;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void fixArray() {
|
||||
|
||||
@@ -90,10 +90,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -195,10 +191,10 @@ public final class CommandUtils {
|
||||
|
||||
public static String displaySkill(PlayerProfile profile, SkillType skill) {
|
||||
if (skill.isChildSkill()) {
|
||||
return LocaleLoader.getString("Skills.ChildStats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill));
|
||||
return LocaleLoader.getString("Skills.ChildStats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener"), " ", profile.getSkillLevel(skill));
|
||||
}
|
||||
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill));
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener"), " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill));
|
||||
}
|
||||
|
||||
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<SkillType> skillGroup) {
|
||||
@@ -220,19 +216,6 @@ 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.
|
||||
*
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.gmail.nossr50.util.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
|
||||
public final class UserManager {
|
||||
private final static Map<String, McMMOPlayer> players = new HashMap<String, McMMOPlayer>();
|
||||
|
||||
private UserManager() {}
|
||||
|
||||
@@ -22,8 +23,16 @@ public final class UserManager {
|
||||
* @return the player's {@link McMMOPlayer} object
|
||||
*/
|
||||
public static McMMOPlayer addUser(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player);
|
||||
player.setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
||||
String playerName = player.getName();
|
||||
McMMOPlayer mcMMOPlayer = players.get(playerName);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
mcMMOPlayer.setPlayer(player); // The player object is different on each reconnection and must be updated
|
||||
}
|
||||
else {
|
||||
mcMMOPlayer = new McMMOPlayer(player);
|
||||
players.put(playerName, mcMMOPlayer);
|
||||
}
|
||||
|
||||
return mcMMOPlayer;
|
||||
}
|
||||
@@ -31,41 +40,35 @@ public final class UserManager {
|
||||
/**
|
||||
* Remove a user.
|
||||
*
|
||||
* @param player The Player object
|
||||
* @param playerName The name of the player to remove
|
||||
*/
|
||||
public static void remove(Player player) {
|
||||
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p);
|
||||
public static void remove(String playerName) {
|
||||
players.remove(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all users.
|
||||
*/
|
||||
public static void clearAll() {
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
remove(player);
|
||||
}
|
||||
players.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all users.
|
||||
*/
|
||||
public static void saveAll() {
|
||||
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
|
||||
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.length + ")");
|
||||
|
||||
for (Player player : onlinePlayers) {
|
||||
getPlayer(player).getProfile().save();
|
||||
mcMMO.p.debug("Saving mcMMOPlayers... (" + players.size() + ")");
|
||||
for (McMMOPlayer mcMMOPlayer : players.values()) {
|
||||
mcMMOPlayer.getProfile().save();
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getPlayerNames() {
|
||||
return players.keySet();
|
||||
}
|
||||
|
||||
public static Collection<McMMOPlayer> getPlayers() {
|
||||
Collection<McMMOPlayer> playerCollection = new ArrayList<McMMOPlayer>();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
playerCollection.add(getPlayer(player));
|
||||
}
|
||||
|
||||
return playerCollection;
|
||||
return players.values();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,37 +81,42 @@ public final class UserManager {
|
||||
return retrieveMcMMOPlayer(playerName, false);
|
||||
}
|
||||
|
||||
public static McMMOPlayer getOfflinePlayer(OfflinePlayer player) {
|
||||
if (player instanceof Player) {
|
||||
return getPlayer((Player) player);
|
||||
}
|
||||
|
||||
return retrieveMcMMOPlayer(player.getName(), true);
|
||||
/**
|
||||
* 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) {
|
||||
return retrieveMcMMOPlayer(player.getName(), false);
|
||||
}
|
||||
|
||||
public static McMMOPlayer getOfflinePlayer(String playerName) {
|
||||
return retrieveMcMMOPlayer(playerName, true);
|
||||
public static McMMOPlayer getPlayer(OfflinePlayer player, boolean offlineValid) {
|
||||
return retrieveMcMMOPlayer(player.getName(), offlineValid);
|
||||
}
|
||||
|
||||
public static McMMOPlayer getPlayer(Player player) {
|
||||
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||
public static McMMOPlayer getPlayer(String playerName, boolean offlineValid) {
|
||||
return retrieveMcMMOPlayer(playerName, offlineValid);
|
||||
}
|
||||
|
||||
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
McMMOPlayer mcMMOPlayer = players.get(playerName);
|
||||
|
||||
if (player == null) {
|
||||
if (!offlineValid) {
|
||||
mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + ".");
|
||||
if (mcMMOPlayer == null) {
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
if (!offlineValid) {
|
||||
mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + ".");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
mcMMOPlayer = new McMMOPlayer(player);
|
||||
players.put(playerName, mcMMOPlayer);
|
||||
}
|
||||
|
||||
return getPlayer(player);
|
||||
}
|
||||
|
||||
public static boolean hasPlayerDataKey(Entity entity) {
|
||||
return entity != null && entity.hasMetadata(mcMMO.playerDataKey);
|
||||
return mcMMOPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ public class ScoreboardManager {
|
||||
}
|
||||
|
||||
for (String playerName : dirtyPowerLevels) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
continue;
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -197,7 +198,7 @@ public final class CombatUtils {
|
||||
if (attacker instanceof Player && entityType == EntityType.PLAYER) {
|
||||
Player player = (Player) attacker;
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
if (Misc.isNPCEntity(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -298,6 +299,15 @@ 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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,8 +421,8 @@ public final class CombatUtils {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mcMMO.getModManager().isCustomEntity(target)) {
|
||||
baseXP = mcMMO.getModManager().getEntity(target).getXpMultiplier();
|
||||
if (ModUtils.isCustomEntity(target)) {
|
||||
baseXP = ModUtils.getCustomEntity(target).getXpMultiplier();
|
||||
}
|
||||
else if (target instanceof Animals) {
|
||||
baseXP = ExperienceConfig.getInstance().getAnimalsXP();
|
||||
@@ -463,7 +473,7 @@ public final class CombatUtils {
|
||||
|
||||
default:
|
||||
baseXP = 1.0;
|
||||
mcMMO.getModManager().addCustomEntity(target);
|
||||
ModUtils.addCustomEntity(target);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -497,7 +507,7 @@ public final class CombatUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((PartyManager.inSameParty(player, defender) || PartyManager.areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
||||
if (PartyManager.inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -549,7 +559,7 @@ public final class CombatUtils {
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
|
||||
return (owner == attacker || PartyManager.inSameParty(attacker, owner) || PartyManager.areAllies(attacker, owner));
|
||||
return (owner == attacker || PartyManager.inSameParty(attacker, owner));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,24 +609,10 @@ public final class CombatUtils {
|
||||
else if (ItemUtils.isDiamondTool(inHand)) {
|
||||
tier = 4;
|
||||
}
|
||||
else if (mcMMO.getModManager().isCustomTool(inHand)) {
|
||||
tier = mcMMO.getModManager().getTool(inHand).getTier();
|
||||
else if (ModUtils.isCustomTool(inHand)) {
|
||||
tier = ModUtils.getToolFromItemStack(inHand).getTier();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ 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;
|
||||
@@ -442,14 +440,14 @@ public class Updater {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check release vs. beta & SNAPSHOT
|
||||
// Check release vs. beta & dev
|
||||
if (newTokens.length == 1 && oldTokens.length == 3 && oldVersion == newVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check beta vs. SNAPSHOT
|
||||
if (version.contains("SNAPSHOT") && title.contains("beta")) {
|
||||
if (Integer.parseInt(oldTokens[1].substring(8)) <= Integer.parseInt(newTokens[1].substring(4))) {
|
||||
// Check beta vs. dev
|
||||
if (version.contains("dev") && title.contains("beta")) {
|
||||
if (Integer.parseInt(oldTokens[1].substring(3)) <= Integer.parseInt(newTokens[1].substring(4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -467,7 +465,7 @@ public class Updater {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldTokens.length == 3 && !version.contains("beta") && !version.contains("SNAPSHOT")) {
|
||||
if (oldTokens.length == 3 && !version.contains("beta") && !version.contains("dev")) {
|
||||
plugin.getLogger().warning("Could not get information about this mcMMO version; perhaps you are running a custom one?");
|
||||
result = UpdateResult.FAIL_NOVERSION;
|
||||
return false;
|
||||
@@ -521,11 +519,7 @@ 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;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVerboseLoggingEnabled()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,9 +471,7 @@ 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
|
||||
|
||||
@@ -267,8 +267,7 @@ Skills:
|
||||
Prevent_AFK_Leveling: true
|
||||
Max_Tries_At_Same_Location: 3
|
||||
Prevent_Dodge_Lightning: false
|
||||
# Prevent earning Acrobatics XP a few seconds after teleporting
|
||||
XP_After_Teleport_Cooldown: 5
|
||||
Prevent_XP_After_Teleport: true
|
||||
Level_Cap: 0
|
||||
Alchemy:
|
||||
# Allow Hoppers to transfer ingredients and brew Rank 1 Alchemy potions
|
||||
@@ -317,24 +316,16 @@ Skills:
|
||||
Enabled_For_PVE: true
|
||||
Level_Cap: 0
|
||||
Call_Of_The_Wild:
|
||||
# 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
|
||||
Bones_Required: 10
|
||||
Fish_Required: 10
|
||||
Apples_Required: 10
|
||||
|
||||
# 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
|
||||
@@ -395,10 +386,6 @@ 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:
|
||||
|
||||
@@ -129,7 +129,7 @@ Experience:
|
||||
Mossy_Cobblestone: 30
|
||||
Netherrack: 30
|
||||
Obsidian: 150
|
||||
Quartz_Ore: 100
|
||||
Quartz_Ore: 250
|
||||
Redstone_Ore: 150
|
||||
Sandstone: 30
|
||||
Stone: 30
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user