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

Compare commits

..

43 Commits
cs ... dev-tag

Author SHA1 Message Date
TfT_02
9e04e437e3 Compile with RELEASE 2014-02-28 19:50:20 +01:00
TfT_02
30e1d3fff3 No such thing as cancelled events 2014-02-28 19:49:53 +01:00
TfT_02
bada2f5d0d Remove reflection 2014-02-28 19:15:11 +01:00
GJ
1edc12af3b This is ugly & awful, but may keep us from needing to add Tag-API as a dependency. 2014-02-28 10:46:34 -05:00
TfT_02
f9a73c38d8 Step two 2014-02-27 22:25:54 +01:00
TfT_02
ccdab96650 First step in starting to fix this issue 2014-02-27 22:25:34 +01:00
GJ
8deac175d1 Repair damaged user files. Fixes #1869 2014-02-22 09:52:36 -05:00
GJ
d0b766a2d3 Fixed bug with updating (very) old user data. 2014-02-21 11:38:22 -05:00
GJ
65692f2a83 Fixed bug with checking maximum durability of mod items. Fixes #1634 2014-02-20 12:43:11 -05:00
GJ
d0b0786284 Fixed exploit involving Call of The Wild. Fixes #1877 2014-02-20 11:50:56 -05:00
Luuk Jacobs
87ac1002de Fix potion datavalues for Splash poison II potions 2014-02-18 08:45:44 +01:00
TfT_02
c51fde7f1f Added new permission node to control who can check version number
Negate this permission node to hide the version number from /mcmmo and
motd
2014-02-17 16:31:59 +01:00
TfT_02
0a6735110f Get mod config file resources properly
Fixes #1870 for real
2014-02-16 23:32:14 +01:00
TfT_02
8a284c50a2 Rename mod files to type.default.yml
Fixes #1870
2014-02-16 23:08:22 +01:00
roblikescake
09431ef27c Check durability before repairMaterial 2014-02-16 00:18:27 +01:00
TfT_02
9f9de86d21 The defender isn't necessarily a player here
Besides, the defender doesn’t need to have the player data key anyways
2014-02-16 00:11:15 +01:00
TfT_02
d9c04a09ba No need to clone here and it's not null checked
Fixes #1864
2014-02-15 23:35:14 +01:00
t00thpick1
04a02cfdc8 Store McMMOPlayer objects as metadata 2014-02-15 14:21:25 +01:00
TfT_02
b3a6c32ef6 Skip glass bottles as well
Fixes #1859
2014-02-15 11:18:11 +01:00
TfT_02
254f3b5ac9 Cleanup finishBrewing a bit 2014-02-15 11:17:31 +01:00
TfT_02
7f9ada14c8 Schedule check after putting a new bottle in the brewing stand 2014-02-15 01:37:41 +01:00
TfT_02
f79a4741cc Store Locations, not BlockStates
Fixes #1862
2014-02-15 01:31:13 +01:00
TfT_02
f3fd48d0c0 Don't set potion meta data - for Vanilla potions 2014-02-14 23:58:22 +01:00
GJ
fbee3318bd These go the other way around. 2014-02-12 08:29:14 -05:00
TfT_02
813f807876 Fix remaining potion data values
Fixes #1844
2014-02-12 13:48:24 +01:00
TfT_02
0060a86b20 Compile with 1.6.4-R2.0 2014-02-12 12:00:04 +01:00
TfT_02
15743c5f46 Don't set potion meta data
It causes incompatibilities with other plugins.

Fixes #1849
2014-02-12 11:54:21 +01:00
TfT_02
4b9d472f10 Fix ConcurrentModificationException with alchemyBrewTask.finishImmediately()
Fixes #1848
2014-02-12 11:16:05 +01:00
GJ
988006f913 Alchemy cleanup, part 1. 2014-02-11 16:22:57 -05:00
TfT_02
2f05c472ce Make party names case insensitive
Fixes #1846
2014-02-10 17:14:34 +01:00
TfT_02
5c836cdaaf Check party level before sending party chat
Fixes #1847
2014-02-10 16:07:43 +01:00
TfT_02
9e39c3495d Fix IllegalArgumentException: 1 > 0 2014-02-09 17:15:42 +01:00
TfT_02
b653aa57b7 You can't accept an alliance request when you already have an ally 2014-02-09 16:10:43 +01:00
Sean Porter
2ffdd340af The command is spelled xpshare, not expshare.
Fixes #1841
2014-02-09 12:31:30 +01:00
Sean Porter
d63c3fc6d0 Ensure the FlatFile directory exists.
Fixes #1842
2014-02-09 12:31:29 +01:00
TfT_02
4486261413 Schedule an Alchemy check after using a hotkey to add ingredients
Fixes #1834
2014-02-07 13:39:24 +01:00
TfT_02
a2e32179bb Fix /mcstats command
Fixes #1819
2014-02-05 19:24:14 +01:00
TfT_02
72b106e71f Fix ptp Accept_Required setting
I forgot to change this, oops!
2014-02-05 19:15:39 +01:00
TfT_02
679f1ed629 Use default Vanilla MC potion data values in potions.yml
Fixes #1821
2014-02-04 16:48:10 +01:00
GJ
734815c58d No reason to have our scoreboard stuff in a different listener. 2014-02-04 08:34:17 -05:00
GJ
abfedf381d Allow mod name to go in the middle or at the beginning. 2014-02-04 07:53:54 -05:00
GJ
8e040ae8d9 Refactor to match existing conventions 2014-02-03 14:57:45 -05:00
GJ
0c9836eb03 Made mod config files modular. Addresses #1802 2014-02-03 14:48:43 -05:00
71 changed files with 1419 additions and 1261 deletions

View File

@@ -20,6 +20,10 @@ Version 1.4.08-dev
+ 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
= 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

View File

@@ -47,5 +47,6 @@ Required Libraries:
* JUnit
* EMetrics
* Bukkit
* TagAPI
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.

12
pom.xml
View File

@@ -116,12 +116,16 @@
<id>Plugin MetricsExtension</id>
<url>http://repo.turt2live.com</url>
</repository>
<repository>
<id>TagAPI</id>
<url>http://repo.kitteh.org/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>RELEASE</version>
<version>1.6.4-R2.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
@@ -136,6 +140,12 @@
<artifactId>MetricsExtension</artifactId>
<version>0.0.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.kitteh</groupId>
<artifactId>tagapi</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>

View File

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

View File

@@ -4,8 +4,10 @@ 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;
@@ -28,6 +30,11 @@ 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 {

View File

@@ -217,7 +217,7 @@ public class PartyCommand implements TabExecutor {
}
private String[] extractArgs(String[] args) {
return Arrays.copyOfRange(args, 1, args.length - 1);
return Arrays.copyOfRange(args, 1, args.length);
}
private boolean isItemShareCategory(String category) {

View File

@@ -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 expshare"));
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare"));
return true;
default:

View File

@@ -23,6 +23,11 @@ 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;

View File

@@ -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.getBrewSpeed()) + "x";
displayValues[1] = isLucky ? decimal.format(alchemyManager.getBrewSpeedLucky()) + "x" : null;
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
return displayValues;
}

View File

@@ -376,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.Confirm_Required", true); }
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Accept_Required", true); }
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */

View File

@@ -0,0 +1,35 @@
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));
}
}
}

View File

@@ -0,0 +1,35 @@
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));
}
}
}

View File

@@ -16,42 +16,22 @@ 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;
private List<Repairable> repairables;
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<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>();
public List<Repairable> repairables = new ArrayList<Repairable>();
public CustomArmorConfig() {
super("mods", "armor.yml");
protected CustomArmorConfig(String fileName) {
super("mods", fileName);
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);
@@ -117,20 +97,4 @@ 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);
}
}

View File

@@ -13,40 +13,29 @@ 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;
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 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 HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
public HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
public CustomBlockConfig() {
super("mods", "blocks.yml");
protected CustomBlockConfig(String fileName) {
super("mods", fileName);
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", customWoodcuttingBlocks);
loadBlocks("Woodcutting", null);
loadBlocks("Ability_Blocks", customAbilityBlocks);
if (needsUpdate) {
@@ -85,7 +74,10 @@ public class CustomBlockConfig extends ConfigLoader {
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
blockList.add(blockMaterialData);
if (blockList != null) {
blockList.add(blockMaterialData);
}
if (skillType.equals("Ability_Blocks")) {
continue;
@@ -111,40 +103,4 @@ 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);
}
}

View File

@@ -3,7 +3,6 @@ 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;
@@ -12,24 +11,14 @@ import com.gmail.nossr50.datatypes.mods.CustomEntity;
import org.apache.commons.lang.ClassUtils;
public class CustomEntityConfig extends ConfigLoader {
private static CustomEntityConfig instance;
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
public CustomEntityConfig() {
super("mods", "entities.yml");
protected CustomEntityConfig(String fileName) {
super("mods", fileName);
loadKeys();
}
public static CustomEntityConfig getInstance() {
if (instance == null) {
instance = new CustomEntityConfig();
}
return instance;
}
@Override
protected void loadKeys() {
if (config.getConfigurationSection("Hostile") != null) {
@@ -71,47 +60,4 @@ 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);
}
}

View File

@@ -18,46 +18,26 @@ 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;
private List<Repairable> repairables;
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<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 HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
public List<Repairable> repairables = new ArrayList<Repairable>();
private CustomToolConfig() {
super("mods", "tools.yml");
protected CustomToolConfig(String fileName) {
super("mods", fileName);
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);
@@ -132,36 +112,4 @@ 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);
}
}

View File

@@ -0,0 +1,35 @@
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));
}
}
}

View File

@@ -0,0 +1,35 @@
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));
}
}
}

View File

@@ -1,10 +1,11 @@
package com.gmail.nossr50.config.potion;
package com.gmail.nossr50.config.skills.alchemy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@@ -13,21 +14,21 @@ import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.AlchemyPotion;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
public class PotionConfig extends ConfigLoader {
private static PotionConfig instance;
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 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 Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
private Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
private PotionConfig() {
super("potions.yml");
@@ -189,4 +190,34 @@ 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);
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.config.repair;
package com.gmail.nossr50.config.skills.repair;
import java.util.ArrayList;
import java.util.List;
@@ -96,6 +96,10 @@ public class RepairConfig extends ConfigLoader {
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
if (maximumDurability <= 0) {
maximumDurability = (short) config.getInt("Repairables." + key + ".MaximumDurability");
}
if (maximumDurability <= 0) {
reason.add("Maximum durability of " + key + " must be greater than 0!");
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.config.repair;
package com.gmail.nossr50.config.skills.repair;
import java.io.File;
import java.util.ArrayList;
@@ -9,11 +9,9 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
public class RepairConfigManager {
private List<Repairable> repairables;
private final List<Repairable> repairables = new ArrayList<Repairable>();
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");
@@ -34,19 +32,11 @@ public class RepairConfigManager {
}
RepairConfig rConfig = new RepairConfig(fileName);
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
if (rConfigRepairables != null) {
repairables.addAll(rConfigRepairables);
}
repairables.addAll(rConfig.getLoadedRepairables());
}
}
public List<Repairable> getLoadedRepairables() {
if (repairables == null) {
return new ArrayList<Repairable>();
}
return repairables;
}
}

View File

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

View File

@@ -47,7 +47,6 @@ 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;
@@ -92,6 +91,8 @@ public class McMMOPlayer {
private boolean isUsingUnarmed;
private final FixedMetadataValue playerMetadata;
private String nameTag;
public McMMOPlayer(Player player) {
String playerName = player.getName();
@@ -757,7 +758,7 @@ public class McMMOPlayer {
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
if (Config.getInstance().getToolModsEnabled()) {
CustomTool tool = ModUtils.getToolFromItemStack(player.getItemInHand());
CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand());
if (tool != null) {
xp *= tool.getXpMultiplier();
@@ -843,7 +844,7 @@ public class McMMOPlayer {
ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
return;
}
@@ -950,4 +951,12 @@ public class McMMOPlayer {
public FixedMetadataValue getPlayerMetadata() {
return playerMetadata;
}
public String getNameTag() {
return nameTag;
}
public void setNameTag(String nameTag) {
this.nameTag = nameTag;
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.datatypes;
package com.gmail.nossr50.datatypes.skills.alchemy;
import java.util.List;
import java.util.Map;
@@ -25,25 +25,27 @@ public class AlchemyPotion {
}
public String toString() {
return "AlchemyPotion{" + dataValue + "," + name + ",Effects[" + effects.size() + "], Children[" + children.size() + "]}";
}
public ItemStack toItemStack() {
return toItemStack(1);
return "AlchemyPotion{" + dataValue + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
}
public ItemStack toItemStack(int amount) {
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
PotionMeta meta = (PotionMeta) potion.getItemMeta();
meta.setDisplayName(this.getName());
if (this.getName() != null) {
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;
}

View File

@@ -104,7 +104,7 @@ public class BlockListener implements Listener {
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -144,7 +144,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
@@ -214,7 +214,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
@@ -261,7 +261,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -327,7 +327,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}

View File

@@ -424,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 (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -451,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 (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -494,7 +494,7 @@ public class EntityListener implements Listener {
Player player = (Player) entity;
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -560,7 +560,7 @@ public class EntityListener implements Listener {
Player player = (Player) event.getOwner();
LivingEntity entity = event.getEntity();
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
return;
}

View File

@@ -12,6 +12,7 @@ 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;
@@ -22,8 +23,10 @@ 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;
@@ -32,9 +35,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;
@@ -56,7 +59,7 @@ public class InventoryListener implements Listener {
HumanEntity player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -73,7 +76,7 @@ public class InventoryListener implements Listener {
HumanEntity player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -92,7 +95,7 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock);
if (Misc.isNPCEntity(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
if (!UserManager.hasPlayerDataKey(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
return;
}
@@ -110,7 +113,7 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock);
if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
if (!UserManager.hasPlayerDataKey(player) || !SkillType.SMELTING.getPermissions(player)) {
return;
}
@@ -129,7 +132,7 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock);
if (Misc.isNPCEntity(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
return;
}
@@ -138,43 +141,164 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryClickEventNormal(InventoryClickEvent event) {
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) {
return;
}
if (!(event.getWhoClicked() instanceof Player) || Misc.isNPCEntity(event.getWhoClicked()) || !Permissions.concoctions(event.getWhoClicked())) {
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
AlchemyPotionBrewer.handleInventoryClick(event);
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;
}
AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), Alchemy.INGREDIENT_SLOT, click);
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);
}
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) {
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) {
return;
}
if (!(event.getWhoClicked() instanceof Player) || Misc.isNPCEntity(event.getWhoClicked()) || !Permissions.concoctions(event.getWhoClicked())) {
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
AlchemyPotionBrewer.handleInventoryDrag(event);
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);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
if (event.getDestination().getType() != InventoryType.BREWING || !(event.getDestination().getHolder() instanceof BrewingStand)) {
Inventory inventory = event.getDestination();
if (!(inventory instanceof BrewerInventory)) {
return;
}
if (Config.getInstance().getPreventHopperTransfer() && event.getItem() != null && event.getItem().getType() != Material.POTION) {
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
ItemStack item = event.getItem();
if (Config.getInstance().getPreventHopperTransfer() && item.getType() != Material.POTION) {
event.setCancelled(true);
return;
}
if (Config.getInstance().getEnabledForHoppers()) {
AlchemyPotionBrewer.handleInventoryMoveItem(event);
if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
}
}
@@ -187,7 +311,7 @@ public class InventoryListener implements Listener {
public void onCraftItem(CraftItemEvent event) {
final HumanEntity whoClicked = event.getWhoClicked();
if (Misc.isNPCEntity(whoClicked) || !(whoClicked instanceof Player)) {
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
return;
}

View File

@@ -58,6 +58,7 @@ 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 {
@@ -80,7 +81,7 @@ public class PlayerListener implements Listener {
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Config.getInstance().getPreventXPAfterTeleport() || event.getFrom().equals(event.getTo())) {
if (!UserManager.hasPlayerDataKey(player) || !Config.getInstance().getPreventXPAfterTeleport() || event.getFrom().equals(event.getTo())) {
return;
}
@@ -129,7 +130,7 @@ public class PlayerListener implements Listener {
Player killedPlayer = event.getEntity();
if (Misc.isNPCEntity(killedPlayer) || Permissions.hardcoreBypass(killedPlayer)) {
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
return;
}
@@ -164,7 +165,7 @@ public class PlayerListener implements Listener {
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -207,7 +208,7 @@ public class PlayerListener implements Listener {
public void onPlayerFishHighest(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
return;
}
@@ -252,7 +253,7 @@ public class PlayerListener implements Listener {
public void onPlayerFishMonitor(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
return;
}
@@ -293,7 +294,7 @@ public class PlayerListener implements Listener {
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -343,7 +344,7 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -352,7 +353,8 @@ public class PlayerListener implements Listener {
mcMMOPlayer.resetAbilityMode();
BleedTimerTask.bleedOut(player);
mcMMOPlayer.getProfile().save();
UserManager.remove(player.getName());
UserManager.remove(player);
ScoreboardManager.teardownPlayer(player);
}
/**
@@ -372,7 +374,9 @@ public class PlayerListener implements Listener {
return;
}
UserManager.addUser(player).actualizeRespawnATS();
McMMOPlayer mcMMOPlayer = UserManager.addUser(player);
mcMMOPlayer.actualizeRespawnATS();
ScoreboardManager.setupPlayer(player);
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
@@ -401,7 +405,7 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -417,7 +421,7 @@ public class PlayerListener implements Listener {
public void onPlayerInteractLowest(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
@@ -508,7 +512,7 @@ public class PlayerListener implements Listener {
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}

View File

@@ -1,39 +0,0 @@
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());
}
}

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -10,12 +15,27 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
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) {
event.getSkill().celebrateLevelUp(event.getPlayer());
skill.celebrateLevelUp(player);
}
}
@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());
}
}

View File

@@ -0,0 +1,59 @@
package com.gmail.nossr50.listeners;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.kitteh.tag.AsyncPlayerReceiveNameTagEvent;
public class TagListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onAsyncPlayerReceiveNameTag(AsyncPlayerReceiveNameTagEvent event) {
Player player = event.getNamedPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true);
if (mcMMOPlayer == null) {
return;
}
String tag = event.getTag();
String colorlessTag = ChatColor.stripColor(tag);
if (colorlessTag.equals(tag)) {
mcMMOPlayer.setNameTag(null);
return;
}
if (colorlessTag.equals(player.getName()) && (mcMMOPlayer.getNameTag() == null || !mcMMOPlayer.getNameTag().equals(tag))) {
mcMMOPlayer.setNameTag(tag);
ScoreboardManager.tagUpdate(player);
}
/*
mbax:
With TagAPI, you can set the name tag over anybody's head to any value.
You can have five people with the name 'Notch' (And one named 'notch' for
good measure). That makes it difficult to properly utilize the scoreboard
feature to match a changed name to a score for below name objective display.
Additionally, every single player can be seeing a different username over
the head of the same player. So even if you're just trying to detect colored usernames
you could be encountering 16 different colors before a username (15, generally, who does white?)
and maybe some format codes as well. The Scoreboard API doesn't support per-player setting of names,
so you'd have to add an entry for each.
At best, what you could do is listen to TagAPI's event on MONITOR priority and track all the names.
Check if a set name is the same as their actual name, sans colors. If yes, store that and each time
you update a player's below-name objective, update an OfflinePlayer with that colored version as well.
This is not a good idea if the objective will ever change DisplaySlot, particularly if it goes to the
sidebar, since you'll then need to clear the color ones.
*/
}
}

View File

@@ -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.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.mods.ArmorConfigManager;
import com.gmail.nossr50.config.mods.BlockConfigManager;
import com.gmail.nossr50.config.mods.EntityConfigManager;
import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
@@ -27,8 +27,8 @@ 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.TagListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.metrics.MetricsManager;
@@ -48,6 +48,7 @@ import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.LogFilter;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
@@ -65,6 +66,7 @@ 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 +90,7 @@ public class mcMMO extends JavaPlugin {
private static boolean healthBarPluginEnabled;
private static boolean noCheatPlusPluginEnabled;
private static boolean compatNoCheatPlusPluginEnabled;
private static boolean tagapiPluginEnabled;
private static boolean mcpcEnabled;
// Config Validation Check
@@ -110,6 +113,7 @@ 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;
@@ -128,9 +132,12 @@ public class mcMMO extends JavaPlugin {
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
tagapiPluginEnabled = getServer().getPluginManager().getPlugin("TagAPI") != null && checkTagVersion();
setupFilePaths();
modManager = new ModManager();
loadConfigFiles();
if (!noErrorsInConfigFiles) {
@@ -294,6 +301,10 @@ public class mcMMO extends JavaPlugin {
return databaseManager;
}
public static ModManager getModManager() {
return modManager;
}
@Deprecated
public static void setDatabaseManager(DatabaseManager databaseManager) {
mcMMO.databaseManager = databaseManager;
@@ -329,15 +340,47 @@ 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() {
@@ -373,24 +416,24 @@ public class mcMMO extends JavaPlugin {
List<Repairable> repairables = new ArrayList<Repairable>();
if (Config.getInstance().getToolModsEnabled()) {
repairables.addAll(CustomToolConfig.getInstance().getLoadedRepairables());
new ToolConfigManager(this);
}
if (Config.getInstance().getArmorModsEnabled()) {
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
new ArmorConfigManager(this);
}
if (Config.getInstance().getBlockModsEnabled()) {
CustomBlockConfig.getInstance();
new BlockConfigManager(this);
}
if (Config.getInstance().getEntityModsEnabled()) {
CustomEntityConfig.getInstance();
new EntityConfigManager(this);
}
// Load repair configs, make manager, and register them at this time
RepairConfigManager rManager = new RepairConfigManager(this);
repairables.addAll(rManager.getLoadedRepairables());
repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
repairables.addAll(modManager.getLoadedRepairables());
repairableManager = new SimpleRepairableManager(repairables.size());
repairableManager.registerRepairables(repairables);
}
@@ -404,8 +447,11 @@ 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);
if (tagapiPluginEnabled) {
pluginManager.registerEvents(new TagListener(), this);
}
}
private void registerCustomRecipes() {
@@ -470,4 +516,17 @@ public class mcMMO extends JavaPlugin {
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
}
private boolean checkTagVersion() {
try {
Class.forName("org.kitteh.tag.AsyncPlayerReceiveNameTagEvent");
}
catch (final ClassNotFoundException e) {
getLogger().info("This TagAPI version does not have AsyncPlayerReceiveNameTagEvent");
getLogger().info("Please update TagAPI to ensure full compatibility with mcMMO");
return false;
}
return true;
}
}

View File

@@ -170,7 +170,7 @@ public final class PartyManager {
*/
public static Party getParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
if (party.getName().equalsIgnoreCase(partyName)) {
return party;
}
}

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.runnables.skills;
import java.util.Arrays;
import org.bukkit.block.Block;
import org.bukkit.Location;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -12,8 +12,6 @@ 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;
@@ -26,18 +24,17 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
@Override
public void run() {
Block block = brewingStand.getBlock();
ItemStack[] newInventory = Arrays.copyOfRange(((BrewingStand) block.getState()).getInventory().getContents(), 0, 4);
Location location = brewingStand.getLocation();
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
boolean validBrew = AlchemyPotionBrewer.isValidBrew(player, newInventory);
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();
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) && AlchemyPotionBrewer.isValidBrew(player, newInventory)) {
Alchemy.brewingStandMap.put(brewingStand, new AlchemyBrewTask(brewingStand, player));
else if (validBrew) {
Alchemy.brewingStandMap.put(location, new AlchemyBrewTask(brewingStand, player));
}
}
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.runnables.skills;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
@@ -22,44 +23,43 @@ 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().getBrewSpeed();
if (Permissions.lucky(player, SkillType.ALCHEMY)) {
catalysis = UserManager.getPlayer(player).getAlchemyManager().getBrewSpeedLucky();
}
double catalysis = UserManager.getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, SkillType.ALCHEMY));
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
brewSpeed = catalysis;
}
}
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
Alchemy.brewingStandMap.get(brewingStand).cancel();
if (Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.get(location).cancel();
}
Alchemy.brewingStandMap.put(brewingStand, this);
Alchemy.brewingStandMap.put(location, 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(brewingStand)) {
Alchemy.brewingStandMap.remove(brewingStand);
if (Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.remove(location);
}
this.cancel();
@@ -87,20 +87,20 @@ public class AlchemyBrewTask extends BukkitRunnable {
AlchemyPotionBrewer.finishBrewing(brewingStand, player, false);
}
Alchemy.brewingStandMap.remove(brewingStand);
Alchemy.brewingStandMap.remove(location);
}
public void finishImmediately() {
this.cancel();
AlchemyPotionBrewer.finishBrewing(brewingStand, player, true);
Alchemy.brewingStandMap.remove(brewingStand);
Alchemy.brewingStandMap.remove(location);
}
public void cancelBrew() {
this.cancel();
((BrewingStand) brewingStand).setBrewingTime(-1);
Alchemy.brewingStandMap.remove(brewingStand);
Alchemy.brewingStandMap.remove(location);
}
}

View File

@@ -1,9 +1,11 @@
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.block.BlockState;
import org.bukkit.Location;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
@@ -44,36 +46,30 @@ 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<BlockState, AlchemyBrewTask> brewingStandMap = new HashMap<BlockState, AlchemyBrewTask>();
public static Map<Location, AlchemyBrewTask> brewingStandMap = new HashMap<Location, 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();
}
}

View File

@@ -2,15 +2,14 @@ package com.gmail.nossr50.skills.alchemy;
import java.util.List;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.potion.PotionConfig;
import com.gmail.nossr50.config.skills.alchemy.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 {
@@ -20,23 +19,6 @@ 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()) {
@@ -48,31 +30,17 @@ public class AlchemyManager extends SkillManager {
}
public List<ItemStack> getIngredients() {
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;
}
return PotionConfig.getInstance().getIngredients(getTier());
}
public String getIngredientList() {
StringBuilder list = new StringBuilder();
for (ItemStack ingredient : getIngredients()) {
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (ingredient.getDurability() != 0 ? ":" + ingredient.getDurability() : "");
short durability = ingredient.getDurability();
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (durability != 0 ? ":" + durability : "");
if (string.equals("Long Grass:2")) {
string = "Fern";
}
@@ -80,17 +48,20 @@ public class AlchemyManager extends SkillManager {
string = "Pufferfish";
}
list.append(", " + string);
list.append(", ").append(string);
}
return list.substring(2);
}
public double getBrewSpeed() {
return Alchemy.calculateBrewSpeed(getSkillLevel());
}
public double calculateBrewSpeed(boolean isLucky) {
int skillLevel = getSkillLevel();
public double getBrewSpeedLucky() {
return LUCKY_MODIFIER * 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 void handlePotionBrewSuccesses(int amount) {

View File

@@ -8,18 +8,14 @@ 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.potion.PotionConfig;
import com.gmail.nossr50.datatypes.AlchemyPotion;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.runnables.PlayerUpdateInventoryTask;
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
@@ -27,60 +23,54 @@ 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[INGREDIENT_SLOT])) {
if (!isValidIngredient(player, contents[Alchemy.INGREDIENT_SLOT])) {
return false;
}
for (int bottle : BOTTLE_SLOTS) {
if (contents[bottle] != null && contents[bottle].getType() == Material.POTION) {
AlchemyPotion potion = PotionConfig.getInstance().potionMap.get(contents[bottle].getDurability());
for (int i = 0; i < 3; i++) {
if (contents[i] == null || contents[i].getType() != Material.POTION) {
continue;
}
if (getChildPotion(potion, contents[INGREDIENT_SLOT]) != null) {
return true;
}
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i].getDurability()), contents[Alchemy.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().potionMap.get(potion.getChildDataValue(ingredient));
return PotionConfig.getInstance().getPotion(potion.getChildDataValue(ingredient));
}
return null;
}
private static boolean isEmpty(ItemStack item) {
public 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();
ItemStack ingredient = inventory.getIngredient().clone();
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
return false;
}
else if (ingredient.getAmount() <= 1) {
inventory.setItem(INGREDIENT_SLOT, null);
inventory.setIngredient(null);
return true;
}
else {
ingredient.setAmount(ingredient.getAmount() - 1);
inventory.setItem(INGREDIENT_SLOT, ingredient);
inventory.setIngredient(ingredient);
return true;
}
}
private static boolean isValidIngredient(Player player, ItemStack item) {
public static boolean isValidIngredient(Player player, ItemStack item) {
if (isEmpty(item)) {
return false;
}
@@ -95,28 +85,7 @@ public final class AlchemyPotionBrewer {
}
private static List<ItemStack> getValidIngredients(Player player) {
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;
}
return PotionConfig.getInstance().getIngredients((player == null || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
}
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
@@ -131,17 +100,21 @@ public final class AlchemyPotionBrewer {
return;
}
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));
for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i);
if (output != null) {
inventory.setItem(bottle, output.toItemStack(inventory.getItem(bottle).getAmount()).clone());
if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) {
continue;
}
if (player != null) {
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
}
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);
}
}
}
@@ -151,18 +124,36 @@ public final class AlchemyPotionBrewer {
}
}
public static boolean transferItems(InventoryView view, int fromSlot, int toSlot, ClickType click) {
boolean success = false;
if (click.isLeftClick()) {
success = transferItems(view, fromSlot, toSlot);
}
else if (click.isRightClick()) {
success = transferOneItem(view, fromSlot, toSlot);
}
return success;
}
private static boolean transferOneItem(InventoryView view, int fromSlot, int toSlot) {
ItemStack from = view.getItem(fromSlot).clone();
ItemStack to = view.getItem(toSlot).clone();
boolean emptyFrom = isEmpty(from);
if (isEmpty(from)) {
if (emptyFrom) {
return false;
}
else if (!isEmpty(to) && from.getAmount() >= from.getType().getMaxStackSize()) {
boolean emptyTo = isEmpty(to);
int fromAmount = from.getAmount();
if (!emptyTo && fromAmount >= from.getType().getMaxStackSize()) {
return false;
}
else if (isEmpty(to) || from.isSimilar(to)) {
if (isEmpty(to)) {
else if (emptyTo || from.isSimilar(to)) {
if (emptyTo) {
to = from.clone();
to.setAmount(1);
}
@@ -170,9 +161,9 @@ public final class AlchemyPotionBrewer {
to.setAmount(to.getAmount() + 1);
}
from.setAmount(from.getAmount() - 1);
view.setItem(toSlot, isEmpty(to) ? null : to);
view.setItem(fromSlot, isEmpty(from) ? null : from);
from.setAmount(fromAmount - 1);
view.setItem(toSlot, emptyTo ? null : to);
view.setItem(fromSlot, emptyFrom ? null : from);
return true;
}
@@ -184,166 +175,50 @@ public final class AlchemyPotionBrewer {
* Transfer items between two ItemStacks, returning the leftover status
*/
private static boolean transferItems(InventoryView view, int fromSlot, int toSlot) {
if (isEmpty(view.getItem(fromSlot))) {
ItemStack from = view.getItem(fromSlot).clone();
ItemStack to = view.getItem(toSlot).clone();
if (isEmpty(from)) {
return false;
}
else if (isEmpty(view.getItem(toSlot))) {
view.setItem(toSlot, view.getItem(fromSlot).clone());
else if (isEmpty(to)) {
view.setItem(toSlot, from);
view.setItem(fromSlot, null);
return true;
}
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();
else if (from.isSimilar(to)) {
int fromAmount = from.getAmount();
int toAmount = to.getAmount();
int maxSize = to.getType().getMaxStackSize();
ItemStack to = new ItemStack(view.getItem(toSlot));
to.setAmount(to.getType().getMaxStackSize());
if (fromAmount + toAmount > maxSize) {
int left = fromAmount + toAmount - maxSize;
to.setAmount(maxSize);
view.setItem(toSlot, to);
ItemStack from = new ItemStack(view.getItem(fromSlot));
from.setAmount(left);
view.setItem(fromSlot, from);
return true;
}
ItemStack to = new ItemStack(view.getItem(toSlot));
to.setAmount(view.getItem(fromSlot).getAmount() + view.getItem(toSlot).getAmount());
to.setAmount(fromAmount + toAmount);
view.setItem(fromSlot, null);
view.setItem(toSlot, to);
return true;
}
return false;
}
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) {
public static void scheduleCheck(Player player, BrewingStand brewingStand) {
new AlchemyBrewCheckTask(player, brewingStand).runTask(mcMMO.p);
}
private static void scheduleUpdate(Inventory inventory) {
public static void scheduleUpdate(Inventory inventory) {
for (HumanEntity humanEntity : inventory.getViewers()) {
if (humanEntity instanceof Player) {
new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p);

View File

@@ -3,13 +3,13 @@ package com.gmail.nossr50.skills.excavation;
import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.mcMMO;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.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 && ModUtils.isCustomExcavationBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
}
return xp;

View File

@@ -32,7 +32,6 @@ 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;
@@ -136,8 +135,8 @@ public class HerbalismManager extends SkillManager {
int xp;
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
if (ModUtils.isCustomHerbalismBlock(blockState)) {
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) {
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
xp = customBlock.getXpGain();
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) {

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
@@ -8,7 +9,6 @@ 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 && ModUtils.isCustomMiningBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
}
return xp;
@@ -65,7 +65,7 @@ public class Mining {
return;
default:
if (ModUtils.isCustomMiningBlock(blockState)) {
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
}
return;
@@ -104,7 +104,7 @@ public class Mining {
return;
default:
if (ModUtils.isCustomMiningBlock(blockState)) {
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
return;

View File

@@ -23,7 +23,6 @@ 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;
@@ -70,7 +69,7 @@ public class MiningManager extends SkillManager {
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
}
if ((ModUtils.isCustomMiningBlock(blockState) && !ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
return;
}

View File

@@ -90,7 +90,15 @@ public class RepairManager extends SkillManager {
Material repairMaterial = repairable.getRepairMaterial();
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
short startDurability = item.getDurability();
// Do not repair if at full durability
if (startDurability <= 0) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
return;
}
// Check if they have the proper material to repair with
if (!inventory.contains(repairMaterial)) {
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial));
@@ -103,14 +111,6 @@ public class RepairManager extends SkillManager {
return;
}
short startDurability = item.getDurability();
// Do not repair if at full durability
if (startDurability <= 0) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
return;
}
// Do not repair stacked items
if (item.getAmount() != 1) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));

View File

@@ -6,7 +6,6 @@ import java.util.List;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class SimpleRepairableManager implements RepairableManager {
private HashMap<Material, Repairable> repairables;

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.smelting;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
@@ -7,7 +8,6 @@ import org.bukkit.material.MaterialData;
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 ModUtils.isCustomOre(data) ? ModUtils.getCustomBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
}
}

View File

@@ -260,7 +260,7 @@ public class TamingManager extends SkillManager {
}
}
player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}

View File

@@ -16,7 +16,6 @@ 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 {
@@ -52,8 +51,8 @@ public final class Woodcutting {
break;
}
if (ModUtils.isCustomLogBlock(blockState)) {
return ModUtils.getCustomBlock(blockState).getXpGain();
if (mcMMO.getModManager().isCustomLog(blockState)) {
return mcMMO.getModManager().getBlock(blockState).getXpGain();
}
switch (((Tree) blockState.getData()).getSpecies()) {
@@ -86,7 +85,7 @@ public final class Woodcutting {
* @param blockState Block being broken
*/
protected static void checkForDoubleDrop(BlockState blockState) {
if (ModUtils.isCustomLogBlock(blockState) && ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) {
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
else {

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.woodcutting;
import java.util.HashSet;
import java.util.Set;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -22,7 +23,6 @@ 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 (ModUtils.isCustomLogBlock(blockState)) {
else if (mcMMO.getModManager().isCustomLog(blockState)) {
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
xp = customBlock.getXpGain();
Misc.dropItems(blockState.getLocation(), block.getDrops());
}
else if (ModUtils.isCustomLeafBlock(blockState)) {
Misc.randomDropItems(blockState.getLocation(), block.getDrops(), 10.0);
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
Misc.dropItems(blockState.getLocation(), block.getDrops());
}
else {
Tree tree = (Tree) blockState.getData();

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.util;
import java.util.HashSet;
import com.gmail.nossr50.mcMMO;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.NetherWartsState;
@@ -64,7 +65,7 @@ public final class BlockUtils {
return false;
default:
return !isMcMMOAnvil(blockState) && !ModUtils.isCustomAbilityBlock(blockState);
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
}
}
@@ -135,7 +136,7 @@ public final class BlockUtils {
return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE;
default:
return ModUtils.isCustomHerbalismBlock(blockState);
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
}
}
@@ -157,7 +158,7 @@ public final class BlockUtils {
return true;
default:
return isOre(blockState) || ModUtils.isCustomMiningBlock(blockState);
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
}
}
@@ -181,7 +182,7 @@ public final class BlockUtils {
return true;
default:
return ModUtils.isCustomExcavationBlock(blockState);
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
}
}
@@ -199,7 +200,7 @@ public final class BlockUtils {
return true;
default:
return ModUtils.isCustomLogBlock(blockState);
return mcMMO.getModManager().isCustomLog(blockState);
}
}
@@ -215,7 +216,7 @@ public final class BlockUtils {
return true;
default:
return ModUtils.isCustomLeafBlock(blockState);
return mcMMO.getModManager().isCustomLeaf(blockState);
}
}

View File

@@ -10,9 +10,6 @@ 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;
@@ -33,7 +30,7 @@ public final class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomBow(type));
return mcMMO.getModManager().isCustomBow(type);
}
}
@@ -55,7 +52,7 @@ public final class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomSword(type));
return mcMMO.getModManager().isCustomSword(type);
}
}
@@ -77,7 +74,7 @@ public final class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomHoe(type));
return mcMMO.getModManager().isCustomHoe(type);
}
}
@@ -99,7 +96,7 @@ public final class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomShovel(type));
return mcMMO.getModManager().isCustomShovel(type);
}
}
@@ -121,7 +118,7 @@ public final class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomAxe(type));
return mcMMO.getModManager().isCustomAxe(type);
}
}
@@ -143,7 +140,7 @@ public final class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomPickaxe(type));
return mcMMO.getModManager().isCustomPickaxe(type);
}
}
@@ -165,7 +162,7 @@ public final class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomHelmet(type);
return mcMMO.getModManager().isCustomHelmet(type);
}
}
@@ -187,7 +184,7 @@ public final class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomChestplate(type);
return mcMMO.getModManager().isCustomChestplate(type);
}
}
@@ -209,7 +206,7 @@ public final class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomLeggings(type);
return mcMMO.getModManager().isCustomLeggings(type);
}
}
@@ -231,7 +228,7 @@ public final class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomBoots(type);
return mcMMO.getModManager().isCustomBoots(type);
}
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.mcMMO;
import org.bukkit.material.MaterialData;
public final class MaterialUtils {
@@ -19,7 +20,7 @@ public final class MaterialUtils {
return true;
default:
return ModUtils.isCustomOre(data);
return mcMMO.getModManager().isCustomOre(data);
}
}
}

View File

@@ -149,11 +149,10 @@ 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);
}
}

View File

@@ -167,7 +167,7 @@ public final class MobHealthbarUtils {
return true;
default:
return ModUtils.isCustomBossEntity(livingEntity);
return false;
}
}
}

View File

@@ -0,0 +1,283 @@
package com.gmail.nossr50.util;
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.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ModManager {
private List<Repairable> repairables = new ArrayList<Repairable>();
// 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();
}
}
}

View File

@@ -1,213 +0,0 @@
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();
}
}
}

View File

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

View File

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

View File

@@ -20,7 +20,6 @@ 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>();
@@ -121,21 +120,7 @@ public class HashChunkManager implements ChunkManager {
McMMOSimpleRegionFile regionFile = worldRegions.get(key2);
if (regionFile == null) {
// 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();
}
File file = new File(directory, "mcmmo_" + rx + "_" + rz + "_.mcm");
regionFile = new McMMOSimpleRegionFile(file, rx, rz);
worldRegions.put(key2, regionFile);
}
@@ -308,8 +293,8 @@ public class HashChunkManager implements ChunkManager {
return false;
}
int cx = (x < 0 ? x - 16 : x) >> 4 << 4;
int cz = (z < 0 ? z - 16 : z) >> 4 << 4;
int cx = x / 16;
int cz = z / 16;
String key = world.getName() + "," + cx + "," + cz;
if (!store.containsKey(key)) {
@@ -351,8 +336,8 @@ public class HashChunkManager implements ChunkManager {
return;
}
int cx = (x < 0 ? x - 16 : x) >> 4 << 4;
int cz = (z < 0 ? z - 16 : z) >> 4 << 4;
int cx = x / 16;
int cz = z / 16;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
@@ -397,8 +382,8 @@ public class HashChunkManager implements ChunkManager {
return;
}
int cx = (x < 0 ? x - 16 : x) >> 4 << 4;
int cz = (z < 0 ? z - 16 : z) >> 4 << 4;
int cx = x / 16;
int cz = z / 16;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;

View File

@@ -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 = 8;
private static final int CURRENT_VERSION = 7;
private static final int MAGIC_NUMBER = 0xEA5EDEBB;
private int cx;
private int cz;
@@ -132,16 +132,6 @@ 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() {

View File

@@ -191,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) {

View File

@@ -1,18 +1,19 @@
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.HashSet;
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() {}
@@ -23,16 +24,8 @@ public final class UserManager {
* @return the player's {@link McMMOPlayer} object
*/
public static McMMOPlayer addUser(Player player) {
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);
}
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player);
player.setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
return mcMMOPlayer;
}
@@ -40,35 +33,51 @@ public final class UserManager {
/**
* Remove a user.
*
* @param playerName The name of the player to remove
* @param player The Player object
*/
public static void remove(String playerName) {
players.remove(playerName);
public static void remove(Player player) {
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p);
}
/**
* Clear all users.
*/
public static void clearAll() {
players.clear();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
remove(player);
}
}
/**
* Save all users.
*/
public static void saveAll() {
mcMMO.p.debug("Saving mcMMOPlayers... (" + players.size() + ")");
for (McMMOPlayer mcMMOPlayer : players.values()) {
mcMMOPlayer.getProfile().save();
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.length + ")");
for (Player player : onlinePlayers) {
getPlayer(player).getProfile().save();
}
}
public static Set<String> getPlayerNames() {
return players.keySet();
Set<String> playerNames = new HashSet<String>();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
playerNames.add(player.getName());
}
return playerNames;
}
public static Collection<McMMOPlayer> getPlayers() {
return players.values();
Collection<McMMOPlayer> playerCollection = new ArrayList<McMMOPlayer>();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
playerCollection.add(getPlayer(player));
}
return playerCollection;
}
/**
@@ -88,10 +97,16 @@ public final class UserManager {
* @return the player's McMMOPlayer object
*/
public static McMMOPlayer getPlayer(OfflinePlayer player) {
if (player instanceof Player) {
return getPlayer((Player) player);
}
return retrieveMcMMOPlayer(player.getName(), false);
}
public static McMMOPlayer getPlayer(OfflinePlayer player, boolean offlineValid) {
if (player instanceof Player) {
return getPlayer((Player) player);
}
return retrieveMcMMOPlayer(player.getName(), offlineValid);
}
@@ -99,24 +114,29 @@ public final class UserManager {
return retrieveMcMMOPlayer(playerName, offlineValid);
}
public static McMMOPlayer getPlayer(Player player) {
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
}
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
McMMOPlayer mcMMOPlayer = players.get(playerName);
Player player = mcMMO.p.getServer().getPlayerExact(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;
if (player == null) {
if (!offlineValid) {
mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + ".");
}
mcMMOPlayer = new McMMOPlayer(player);
players.put(playerName, mcMMOPlayer);
return null;
}
return mcMMOPlayer;
return getPlayer(player);
}
public static boolean hasPlayerDataKey(Entity entity) {
if (entity == null) {
return false;
}
return entity.hasMetadata(mcMMO.playerDataKey);
}
}

View File

@@ -224,6 +224,15 @@ public class ScoreboardManager {
}
}
// Called by internal TagAPI event listener
public static void tagUpdate(Player player) {
String playerName = player.getName();
if (Config.getInstance().getPowerLevelTagsEnabled() && !dirtyPowerLevels.contains(playerName)) {
dirtyPowerLevels.add(playerName);
}
}
// **** Setup methods **** //
public static void enablePlayerSkillScoreboard(Player player, SkillType skill) {
@@ -342,6 +351,10 @@ public class ScoreboardManager {
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
wrapper.updatePowerLevel(player, power);
if (mcMMOPlayer.getNameTag() != null) {
wrapper.updatePowerLevel(mcMMO.p.getServer().getOfflinePlayer(mcMMOPlayer.getNameTag()), power);
}
}
}

View File

@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@@ -558,4 +559,8 @@ public class ScoreboardWrapper {
public void updatePowerLevel(Player player, int newPowerLevel) {
powerObjective.getScore(player).setScore(newPowerLevel);
}
public void updatePowerLevel(OfflinePlayer offlinePlayer, int newPowerLevel) {
powerObjective.getScore(offlinePlayer).setScore(newPowerLevel);
}
}

View File

@@ -39,7 +39,6 @@ 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;
@@ -198,7 +197,7 @@ public final class CombatUtils {
if (attacker instanceof Player && entityType == EntityType.PLAYER) {
Player player = (Player) attacker;
if (Misc.isNPCEntity(player)) {
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@@ -421,8 +420,8 @@ public final class CombatUtils {
}
}
else {
if (ModUtils.isCustomEntity(target)) {
baseXP = ModUtils.getCustomEntity(target).getXpMultiplier();
if (mcMMO.getModManager().isCustomEntity(target)) {
baseXP = mcMMO.getModManager().getEntity(target).getXpMultiplier();
}
else if (target instanceof Animals) {
baseXP = ExperienceConfig.getInstance().getAnimalsXP();
@@ -473,7 +472,7 @@ public final class CombatUtils {
default:
baseXP = 1.0;
ModUtils.addCustomEntity(target);
mcMMO.getModManager().addCustomEntity(target);
break;
}
}
@@ -609,8 +608,8 @@ public final class CombatUtils {
else if (ItemUtils.isDiamondTool(inHand)) {
tier = 4;
}
else if (ModUtils.isCustomTool(inHand)) {
tier = ModUtils.getToolFromItemStack(inHand).getTier();
else if (mcMMO.getModManager().isCustomTool(inHand)) {
tier = mcMMO.getModManager().getTool(inHand).getTier();
}
return tier;

View File

@@ -523,7 +523,7 @@ Commands.Party.Alliance.Invite.0=[[RED]]ALERT: [[GREEN]]You have received a part
Commands.Party.Alliance.Invite.1=[[YELLOW]]Type [[GREEN]]/party alliance accept[[YELLOW]] to accept the invite
Commands.Party.Alliance.Invite.Accepted=[[GREEN]]Alliance invite Accepted.
Commands.Party.Alliance.None=[[RED]]Your does not have an ally.
Commands.Party.Alliance.AlreadyAllies=[[RED]]Your party already has an ally.
Commands.Party.Alliance.AlreadyAllies=[[RED]]Your party already has an ally. Disband with [[DARK_AQUA]]/party alliance disband
Commands.Party.Alliance.Help.0=[[RED]]This party hasn't formed an alliance. Invite a party leader
Commands.Party.Alliance.Help.1=[[RED]] to an alliance with [[DARK_AQUA]]/party alliance invite <player>[[RED]].
Commands.ptp.Enabled=Party teleporting [[GREEN]]enabled

View File

@@ -1937,6 +1937,9 @@ permissions:
children:
mcmmo.ability.woodcutting.all: true
mcmmo.commands.woodcutting: true
mcmmo.showversion:
default: true
description: Show mcMMO version number in /mcmmo and motd
mcmmo.tools.*:
default: false
description: Implies all mcmmo.tools permissions.

View File

@@ -66,7 +66,7 @@ Potions:
0: # Water Bottle
Children:
BLAZE_POWDER: 8192 # Mundane Potion
FERMENTED_SPIDER_EYE: 4616 # Potion of Weakness
FERMENTED_SPIDER_EYE: 8200 # Potion of Weakness
GHAST_TEAR: 8192 # Mundane Potion
GLOWSTONE_DUST: 32 # Thick Potion
MAGMA_CREAM: 8192 # Mundane Potion
@@ -79,76 +79,70 @@ Potions:
16: # Awkward Potion
Children:
APPLE: 5376 # Potion of Health Boost
BLAZE_POWDER: 1289 # Potion of Strength
BLAZE_POWDER: 8201 # Potion of Strength
BROWN_MUSHROOM: 2304 # Potion of Nausea
CARROT_ITEM: 768 # Potion of Haste
FERMENTED_SPIDER_EYE: 4616 # Potion of Weakness
GHAST_TEAR: 2561 # Potion of Regeneration
FERMENTED_SPIDER_EYE: 8200 # Potion of Weakness
GHAST_TEAR: 8193 # Potion of Regeneration
'GOLDEN_APPLE:0': 2816 # Potion of Resistance
GOLDEN_CARROT: 4102 # Potion of Night Vision
GOLDEN_CARROT: 8198 # Potion of Night Vision
'INK_SACK:0': 3840 # Potion of Blindness
'LONG_GRASS:2': 5888 # Potion of Saturation
MAGMA_CREAM: 3075 # Potion of Fire Resistance
MAGMA_CREAM: 8195 # Potion of Fire Resistance
POISONOUS_POTATO: 5120 # Potion of Decay
QUARTZ: 5632 # Potion of Absorption
RED_MUSHROOM: 2048 # Potion of Leaping
ROTTEN_FLESH: 4352 # Potion of Hunger
SLIME_BALL: 1024 # Potion of Dullness
SPECKLED_MELON: 1541 # Potion of Healing
SPIDER_EYE: 4868 # Potion of Poison
SUGAR: 258 # Potion of Swiftness
WATER_LILY: 3341 # Potion of Water Breathing (Minecraft 1.6)
'RAW_FISH:3': 3341 # Potion of Water Breathing (Minecraft 1.7)
SPECKLED_MELON: 8197 # Potion of Healing
SPIDER_EYE: 8196 # Potion of Poison
SUGAR: 8194 # Potion of Swiftness
WATER_LILY: 8205 # Potion of Water Breathing (Minecraft 1.6)
'RAW_FISH:3': 8205 # Potion of Water Breathing (Minecraft 1.7)
32: # Thick Potion
Children:
FERMENTED_SPIDER_EYE: 4616
FERMENTED_SPIDER_EYE: 8200
64: # Mundane Potion Extended
Children:
FERMENTED_SPIDER_EYE: 4680
FERMENTED_SPIDER_EYE: 8264
8192: # Mundane Potion
Children:
FERMENTED_SPIDER_EYE: 4616
FERMENTED_SPIDER_EYE: 8200
SULPHUR: 16384
### DRINKABLE POTIONS ######################################################
258: # Potion of Swiftness
Effects: ["SPEED 0 3600"]
8194: # Potion of Swiftness
Children:
FERMENTED_SPIDER_EYE: 522
GLOWSTONE_DUST: 290
REDSTONE: 322
SULPHUR: 16642
290: # Potion of Swiftness II
Effects: ["SPEED 1 1800"]
FERMENTED_SPIDER_EYE: 8202
GLOWSTONE_DUST: 8226
REDSTONE: 8258
SULPHUR: 16386
8226: # Potion of Swiftness II
Children:
FERMENTED_SPIDER_EYE: 586
REDSTONE: 322
SULPHUR: 16642
322: # Potion of Swiftness Extended
Effects: ["SPEED 0 9600"]
FERMENTED_SPIDER_EYE: 8266
REDSTONE: 8258
SULPHUR: 16418
8258: # Potion of Swiftness Extended
Children:
FERMENTED_SPIDER_EYE: 522
GLOWSTONE_DUST: 290
SULPHUR: 16706
FERMENTED_SPIDER_EYE: 8202
GLOWSTONE_DUST: 8226
SULPHUR: 16450
522: # Potion of Slowness
Effects: ["SLOW 0 1800"]
8202: # Potion of Slowness
Children:
REDSTONE: 586
SULPHUR: 16906
586: # Potion of Slowness Extended
Effects: ["SLOW 0 4800"]
REDSTONE: 8266
SULPHUR: 16394
8266: # Potion of Slowness Extended
Children:
GLOWSTONE_DUST: 522
SULPHUR: 16970
GLOWSTONE_DUST: 8202
SULPHUR: 16458
768: # Potion of Haste
Effects: ["FAST_DIGGING 0 3600"]
Effects: ["FAST_DIGGING 0 3600"]
Children:
GLOWSTONE_DUST: 800
REDSTONE: 832
@@ -161,7 +155,7 @@ Potions:
SULPHUR: 17184
832: # Potion of Haste Extended
Effects: ["FAST_DIGGING 0 9600"]
Effects: ["FAST_DIGGING 0 9600"]
Children:
GLOWSTONE_DUST: 800
SULPHUR: 17216
@@ -183,49 +177,42 @@ Potions:
GLOWSTONE_DUST: 1056
SULPHUR: 17472
1289: # Potion of Strength
Effects: ["INCREASE_DAMAGE 0 3600"]
8201: # Potion of Strength
Children:
FERMENTED_SPIDER_EYE: 4616
GLOWSTONE_DUST: 1321
REDSTONE: 1353
SULPHUR: 17673
1321: # Potion of Strength II
Effects: ["INCREASE_DAMAGE 1 1800"]
FERMENTED_SPIDER_EYE: 8200
GLOWSTONE_DUST: 8233
REDSTONE: 8265
SULPHUR: 16393
8233: # Potion of Strength II
Children:
FERMENTED_SPIDER_EYE: 4616
REDSTONE: 1353
SULPHUR: 17705
1353: # Potion of Strength Extended
Effects: ["INCREASE_DAMAGE 0 9600"]
FERMENTED_SPIDER_EYE: 8200
REDSTONE: 8265
SULPHUR: 16425
8265: # Potion of Strength Extended
Children:
FERMENTED_SPIDER_EYE: 4680
GLOWSTONE_DUST: 1321
SULPHUR: 17737
FERMENTED_SPIDER_EYE: 8264
GLOWSTONE_DUST: 8233
SULPHUR: 16457
1541: # Potion of Healing
Effects: ["HEAL 0"]
8197: # Potion of Healing
Children:
FERMENTED_SPIDER_EYE: 1804
GLOWSTONE_DUST: 1573
SULPHUR: 17925
1573: # Potion of Healing II
Effects: ["HEAL 1"]
FERMENTED_SPIDER_EYE: 8204
GLOWSTONE_DUST: 8229
SULPHUR: 16389
8229: # Potion of Healing II
Children:
FERMENTED_SPIDER_EYE: 1836
REDSTONE: 1541
SULPHUR: 17957
FERMENTED_SPIDER_EYE: 8236
REDSTONE: 8197
SULPHUR: 16421
1804: # Potion of Harming
Effects: ["HARM 0"]
8204: # Potion of Harming
Children:
GLOWSTONE_DUST: 1836
SULPHUR: 18188
1836: # Potion of Harming II
Effects: ["HARM 1"]
GLOWSTONE_DUST: 8236
SULPHUR: 16396
8236: # Potion of Harming II
Children:
REDSTONE: 1804
SULPHUR: 18220
REDSTONE: 8204
SULPHUR: 16428
2048: # Potion of Leaping
Effects: ["JUMP 0 3600"]
@@ -255,25 +242,22 @@ Potions:
GLOWSTONE_DUST: 2304
SULPHUR: 18752
2561: # Potion of Regeneration
Effects: ["REGENERATION 0 900"]
8193: # Potion of Regeneration
Children:
FERMENTED_SPIDER_EYE: 4616
GLOWSTONE_DUST: 2593
REDSTONE: 2625
SULPHUR: 18945
2593: # Potion of Regeneration II
Effects: ["REGENERATION 1 450"]
FERMENTED_SPIDER_EYE: 8200
GLOWSTONE_DUST: 8225
REDSTONE: 8257
SULPHUR: 16385
8225: # Potion of Regeneration II
Children:
FERMENTED_SPIDER_EYE: 4616
REDSTONE: 2625
SULPHUR: 18977
2625: # Potion of Regeneration Extended
Effects: ["REGENERATION 0 2400"]
FERMENTED_SPIDER_EYE: 8200
REDSTONE: 8257
SULPHUR: 16417
8257: # Potion of Regeneration Extended
Children:
FERMENTED_SPIDER_EYE: 4680
GLOWSTONE_DUST: 2593
SULPHUR: 19009
FERMENTED_SPIDER_EYE: 8264
GLOWSTONE_DUST: 8225
SULPHUR: 16449
2816: # Potion of Resistance
Effects: ["DAMAGE_RESISTANCE 0 450"]
@@ -292,40 +276,34 @@ Potions:
GLOWSTONE_DUST: 2848
SULPHUR: 19264
3075: # Potion of Fire Resistance
Effects: ["FIRE_RESISTANCE 0 3600"]
8195: # Potion of Fire Resistance
Children:
FERMENTED_SPIDER_EYE: 522
REDSTONE: 3139
SULPHUR: 19459
3139: # Potion of Fire Resistance Extended
Effects: ["FIRE_RESISTANCE 0 9600"]
FERMENTED_SPIDER_EYE: 8202
REDSTONE: 8259
SULPHUR: 16387
8259: # Potion of Fire Resistance Extended
Children:
FERMENTED_SPIDER_EYE: 586
GLOWSTONE_DUST: 3075
SULPHUR: 19523
FERMENTED_SPIDER_EYE: 8266
GLOWSTONE_DUST: 8195
SULPHUR: 16451
3341: # Potion of Water Breathing
Effects: ["WATER_BREATHING 0 3600"]
8205: # Potion of Water Breathing
Children:
REDSTONE: 3405
SULPHUR: 19725
3405: # Potion of Water Breathing Extended
Effects: ["WATER_BREATHING 0 9600"]
REDSTONE: 8269
SULPHUR: 16397
8269: # Potion of Water Breathing Extended
Children:
GLOWSTONE_DUST: 3341
SULPHUR: 19789
GLOWSTONE_DUST: 8205
SULPHUR: 16461
3598: # Potion of Invisibility
Effects: ["INVISIBILITY 0 3600"]
8206: # Potion of Invisibility
Children:
REDSTONE: 3662
SULPHUR: 19982
3662: # Potion of Invisibility Extended
Effects: ["INVISIBILITY 0 9600"]
REDSTONE: 8270
SULPHUR: 16398
8270: # Potion of Invisibility Extended
Children:
GLOWSTONE_DUST: 3598
SULPHUR: 20046
GLOWSTONE_DUST: 8206
SULPHUR: 16462
3840: # Potion of Blindness
Effects: ["BLINDNESS 0 225"]
@@ -338,18 +316,16 @@ Potions:
GLOWSTONE_DUST: 3840
SULPHUR: 20288
4102: # Potion of Night Vision
Effects: ["NIGHT_VISION 0 3600"]
8198: # Potion of Night Vision
Children:
FERMENTED_SPIDER_EYE: 3598
REDSTONE: 4166
SULPHUR: 20486
4166: # Potion of Night Vision Extended
Effects: ["NIGHT_VISION 0 9600"]
FERMENTED_SPIDER_EYE: 8206
REDSTONE: 8262
SULPHUR: 16390
8262: # Potion of Night Vision Extended
Children:
FERMENTED_SPIDER_EYE: 3662
GLOWSTONE_DUST: 4102
SULPHUR: 20550
FERMENTED_SPIDER_EYE: 8270
GLOWSTONE_DUST: 8198
SULPHUR: 16454
4352: # Potion of Hunger
Effects: ["HUNGER 0 900"]
@@ -368,36 +344,31 @@ Potions:
GLOWSTONE_DUST: 4384
SULPHUR: 20800
4616: # Potion of Weakness
Effects: ["WEAKNESS 0 1800"]
8200: # Potion of Weakness
Children:
REDSTONE: 4680
SULPHUR: 21000
4680: # Potion of Weakness Extended
Effects: ["WEAKNESS 0 4800"]
REDSTONE: 8264
SULPHUR: 16392
8264: # Potion of Weakness Extended
Children:
GLOWSTONE_DUST: 4616
SULPHUR: 21064
GLOWSTONE_DUST: 8200
SULPHUR: 16456
4868: # Potion of Poison
Effects: ["POISON 0 900"]
8196: # Potion of Poison
Children:
FERMENTED_SPIDER_EYE: 1804
GLOWSTONE_DUST: 4900
REDSTONE: 4932
SULPHUR: 21252
4900: # Potion of Poison II
Effects: ["POISON 1 450"]
FERMENTED_SPIDER_EYE: 8204
GLOWSTONE_DUST: 8228
REDSTONE: 8260
SULPHUR: 16388
8228: # Potion of Poison II
Children:
FERMENTED_SPIDER_EYE: 1836
REDSTONE: 4932
SULPHUR: 21284
4932: # Potion of Poison Extended
Effects: ["POISON 0 2400"]
FERMENTED_SPIDER_EYE: 8236
REDSTONE: 8260
SULPHUR: 16420
8260: # Potion of Poison Extended
Children:
FERMENTED_SPIDER_EYE: 1804
GLOWSTONE_DUST: 4900
SULPHUR: 21284
FERMENTED_SPIDER_EYE: 8204
GLOWSTONE_DUST: 8228
SULPHUR: 16452
5120: # Potion of Decay
Effects: ["WITHER 0 450"]
@@ -465,33 +436,28 @@ Potions:
16384: # Splash Mundane Potion
Children:
FERMENTED_SPIDER_EYE: 21000
FERMENTED_SPIDER_EYE: 16392
16642: # Splash Potion of Swiftness
Effects: ["SPEED 0 2700"]
16386: # Splash Potion of Swiftness
Children:
FERMENTED_SPIDER_EYE: 16906
GLOWSTONE_DUST: 16674
REDSTONE: 16706
16674: # Splash Potion of Swiftness II
Effects: ["SPEED 1 1350"]
FERMENTED_SPIDER_EYE: 16394
GLOWSTONE_DUST: 16418
REDSTONE: 16450
16418: # Splash Potion of Swiftness II
Children:
FERMENTED_SPIDER_EYE: 16906
REDSTONE: 16706
16706: # Splash Potion of Swiftness Extended
Effects: ["SPEED 0 7200"]
FERMENTED_SPIDER_EYE: 16394
REDSTONE: 16450
16450: # Splash Potion of Swiftness Extended
Children:
FERMENTED_SPIDER_EYE: 16906
GLOWSTONE_DUST: 16674
FERMENTED_SPIDER_EYE: 16394
GLOWSTONE_DUST: 16418
16906: # Splash Potion of Slowness
Effects: ["SLOW 0 1350"]
16394: # Splash Potion of Slowness
Children:
REDSTONE: 16970
16970: # Splash Potion of Slowness Extended
Effects: ["SLOW 0 3600"]
REDSTONE: 16458
16458: # Splash Potion of Slowness Extended
Children:
GLOWSTONE_DUST: 16906
GLOWSTONE_DUST: 16394
17152: # Splash Potion of Haste
Effects: ["FAST_DIGGING 0 2700"]
@@ -521,42 +487,35 @@ Potions:
Children:
GLOWSTONE_DUST: 17440
17673: # Splash Potion of Strength
Effects: ["INCREASE_DAMAGE 0 2700"]
16393: # Splash Potion of Strength
Children:
FERMENTED_SPIDER_EYE: 21000
GLOWSTONE_DUST: 17705
REDSTONE: 17737
17705: # Splash Potion of Strength II
Effects: ["INCREASE_DAMAGE 1 1350"]
FERMENTED_SPIDER_EYE: 16392
GLOWSTONE_DUST: 16425
REDSTONE: 16457
16425: # Splash Potion of Strength II
Children:
FERMENTED_SPIDER_EYE: 21000
REDSTONE: 17737
17737: # Splash Potion of Strength Extended
Effects: ["INCREASE_DAMAGE 0 7200"]
FERMENTED_SPIDER_EYE: 16392
REDSTONE: 16457
16457: # Splash Potion of Strength Extended
Children:
FERMENTED_SPIDER_EYE: 21064
GLOWSTONE_DUST: 17705
FERMENTED_SPIDER_EYE: 16456
GLOWSTONE_DUST: 16425
17925: # Splash Potion of Healing
Effects: ["HEAL 0"]
16389: # Splash Potion of Healing
Children:
FERMENTED_SPIDER_EYE: 18188
GLOWSTONE_DUST: 17957
17957: # Splash Potion of Healing II
Effects: ["HEAL 1"]
FERMENTED_SPIDER_EYE: 16396
GLOWSTONE_DUST: 16421
16421: # Splash Potion of Healing II
Children:
FERMENTED_SPIDER_EYE: 18220
REDSTONE: 17925
FERMENTED_SPIDER_EYE: 16428
REDSTONE: 16389
18188: # Splash Potion of Harming
Effects: ["HARM 0"]
16396: # Splash Potion of Harming
Children:
GLOWSTONE_DUST: 18220
18220: # Splash Potion of Harming II
Effects: ["HARM 1"]
GLOWSTONE_DUST: 16428
16428: # Splash Potion of Harming II
Children:
REDSTONE: 18188
REDSTONE: 16396
18432: # Splash Potion of Leaping
Effects: ["JUMP 0 2700"]
@@ -581,22 +540,19 @@ Potions:
Children:
GLOWSTONE_DUST: 18688
18945: # Splash Potion of Regeneration
Effects: ["REGENERATION 0 675"]
16385: # Splash Potion of Regeneration
Children:
FERMENTED_SPIDER_EYE: 21000
GLOWSTONE_DUST: 18977
REDSTONE: 19009
18977: # Splash Potion of Regeneration II
Effects: ["REGENERATION 1 338"]
FERMENTED_SPIDER_EYE: 16392
GLOWSTONE_DUST: 16417
REDSTONE: 16449
16417: # Splash Potion of Regeneration II
Children:
FERMENTED_SPIDER_EYE: 21000
REDSTONE: 19009
19009: # Splash Potion of Regeneration Extended
Effects: ["REGENERATION 0 1800"]
FERMENTED_SPIDER_EYE: 16392
REDSTONE: 16449
16449: # Splash Potion of Regeneration Extended
Children:
FERMENTED_SPIDER_EYE: 21064
GLOWSTONE_DUST: 18977
FERMENTED_SPIDER_EYE: 16456
GLOWSTONE_DUST: 16417
19200: # Splash Potion of Resistance
Effects: ["DAMAGE_RESISTANCE 0 338"]
@@ -612,34 +568,28 @@ Potions:
Children:
GLOWSTONE_DUST: 19232
19459: # Splash Potion of Fire Resistance
Effects: ["FIRE_RESISTANCE 0 2700"]
16387: # Splash Potion of Fire Resistance
Children:
FERMENTED_SPIDER_EYE: 16906
REDSTONE: 19523
19523: # Splash Potion of Fire Resistance Extended
Effects: ["FIRE_RESISTANCE 0 7200"]
FERMENTED_SPIDER_EYE: 16394
REDSTONE: 16451
16451: # Splash Potion of Fire Resistance Extended
Children:
FERMENTED_SPIDER_EYE: 16970
GLOWSTONE_DUST: 19459
FERMENTED_SPIDER_EYE: 16458
GLOWSTONE_DUST: 16387
19725: # Splash Potion of Water Breathing
Effects: ["WATER_BREATHING 0 2700"]
16397: # Splash Potion of Water Breathing
Children:
REDSTONE: 19789
19789: # Splash Potion of Water Breathing Extended
Effects: ["WATER_BREATHING 0 7200"]
REDSTONE: 16461
16461: # Splash Potion of Water Breathing Extended
Children:
GLOWSTONE_DUST: 19725
GLOWSTONE_DUST: 16397
19982: # Splash Potion of Invisibility
Effects: ["INVISIBILITY 0 2700"]
16398: # Splash Potion of Invisibility
Children:
REDSTONE: 20046
20046: # Splash Potion of Invisibility Extended
Effects: ["INVISIBILITY 0 7200"]
REDSTONE: 16462
16462: # Splash Potion of Invisibility Extended
Children:
GLOWSTONE_DUST: 19982
GLOWSTONE_DUST: 16398
20224: # Splash Potion of Blindness
Effects: ["BLINDNESS 0 169"]
@@ -650,16 +600,14 @@ Potions:
Children:
GLOWSTONE_DUST: 20224
20486: # Splash Potion of Night Vision
Effects: ["NIGHT_VISION 0 2700"]
16390: # Splash Potion of Night Vision
Children:
FERMENTED_SPIDER_EYE: 19982
REDSTONE: 20550
20550: # Splash Potion of Night Vision Extended
Effects: ["NIGHT_VISION 0 7200"]
FERMENTED_SPIDER_EYE: 16398
REDSTONE: 16454
16454: # Splash Potion of Night Vision Extended
Children:
FERMENTED_SPIDER_EYE: 20046
GLOWSTONE_DUST: 20486
FERMENTED_SPIDER_EYE: 16462
GLOWSTONE_DUST: 16390
20736: # Splash Potion of Hunger
Effects: ["HUNGER 0 675"]
@@ -675,31 +623,26 @@ Potions:
Children:
GLOWSTONE_DUST: 20768
21000: # Splash Potion of Weakness
Effects: ["WEAKNESS 0 1350"]
16392: # Splash Potion of Weakness
Children:
REDSTONE: 21064
21064: # Splash Potion of Weakness Extended
Effects: ["WEAKNESS 0 3600"]
REDSTONE: 16456
16456: # Splash Potion of Weakness Extended
Children:
GLOWSTONE_DUST: 21000
GLOWSTONE_DUST: 16392
21252: # Splash Potion of Poison
Effects: ["POISON 0 675"]
16388: # Splash Potion of Poison
Children:
FERMENTED_SPIDER_EYE: 18188
GLOWSTONE_DUST: 21284
REDSTONE: 21316
21284: # Splash Potion of Poison II
Effects: ["POISON 1 338"]
FERMENTED_SPIDER_EYE: 16396
GLOWSTONE_DUST: 16420
REDSTONE: 16452
16420: # Splash Potion of Poison II
Children:
FERMENTED_SPIDER_EYE: 18220
REDSTONE: 21316
21316: # Splash Potion of Poison Extended
Effects: ["POISON 0 1800"]
FERMENTED_SPIDER_EYE: 16428
REDSTONE: 16452
16452: # Splash Potion of Poison Extended
Children:
FERMENTED_SPIDER_EYE: 18188
GLOWSTONE_DUST: 21284
FERMENTED_SPIDER_EYE: 16396
GLOWSTONE_DUST: 16420
21504: # Splash Potion of Decay
Effects: ["WITHER 0 338"]