Permalink
Browse files

Update PR to changes in master

- Special thanks, instead of in dev team
- Fix formatting issues
  * Remove trailing whitespaces
  * Rename method names of event listeners
  * Check for negative instead of positive
- Added Alchemy skill guide
  • Loading branch information...
1 parent 8f83e32 commit 614300351666747571f06dade3aa9f8472ace0ee @TfT-02 TfT-02 committed Dec 30, 2013
View
@@ -8,7 +8,7 @@ Key:
- Removal
Version 1.4.08-dev
- + Added new Skill - Alchemy!
+ + Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
+ Added the possibility to gain experience when using Fishing "Shake"
+ Added config options to disable various sound effects
View
@@ -31,12 +31,15 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)]
(https://github.com/riking)
+
+### Special thanks
[![EasyMFnE](https://www.gravatar.com/avatar/99c9a1fa3bbf957791ceac7b45daadb0.png)]
(https://github.com/EasyMFnE)
+Added the Alchemy skill
## Compiling
-mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
+mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
The typical command used to build mcMMO is: `mvn clean package install`
@@ -6,9 +6,11 @@
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
+import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.alchemy.Alchemy.Tier;
+import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@@ -27,11 +29,12 @@ public AlchemyCommand() {
super(SkillType.ALCHEMY);
}
- protected String[] calculateAbilityDisplayValues(Player player, float skillValue, boolean isLucky) {
+ protected String[] calculateAbilityDisplayValues(Player player, boolean isLucky) {
+ AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
String[] displayValues = new String[2];
- displayValues[0] = decimal.format(UserManager.getPlayer(player).getAlchemyManager().getBrewSpeed()) + "x";
- displayValues[1] = isLucky ? decimal.format(UserManager.getPlayer(player).getAlchemyManager().getBrewSpeedLucky()) + "x" : null;
+ displayValues[0] = decimal.format(alchemyManager.getBrewSpeed()) + "x";
+ displayValues[1] = isLucky ? decimal.format(alchemyManager.getBrewSpeedLucky()) + "x" : null;
return displayValues;
}
@@ -40,37 +43,38 @@ public AlchemyCommand() {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// CATALYSIS
if (canCatalysis) {
- String[] catalysisStrings = calculateAbilityDisplayValues(player, skillValue, isLucky);
+ String[] catalysisStrings = calculateAbilityDisplayValues(player, isLucky);
brewSpeed = catalysisStrings[0];
brewSpeedLucky = catalysisStrings[1];
}
// CONCOCTIONS
if (canConcoctions) {
- tier = UserManager.getPlayer(player).getAlchemyManager().getTier();
- ingredientCount = UserManager.getPlayer(player).getAlchemyManager().getIngredients().size();
- ingredientList = UserManager.getPlayer(player).getAlchemyManager().getIngredientList();
+ AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
+ tier = alchemyManager.getTier();
+ ingredientCount = alchemyManager.getIngredients().size();
+ ingredientList = alchemyManager.getIngredientList();
}
}
@Override
protected void permissionsCheck(Player player) {
- canCatalysis = Permissions.catalysis(player);
- canConcoctions = Permissions.concoctions(player);
+ canCatalysis = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CATALYSIS);
+ canConcoctions = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CONCOCTIONS);
}
@Override
protected List<String> effectsDisplay() {
List<String> messages = new ArrayList<String>();
-
+
if (canCatalysis) {
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Alchemy.Effect.0"), LocaleLoader.getString("Alchemy.Effect.1")));
}
if (canConcoctions) {
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Alchemy.Effect.2"), LocaleLoader.getString("Alchemy.Effect.3")));
}
-
+
return messages;
}
@@ -41,7 +41,7 @@ public static PotionConfig getInstance() {
return instance;
}
-
+
@Override
protected void loadKeys() {
loadConcoctions();
@@ -59,7 +59,7 @@ private void loadConcoctions() {
loadConcoctionsTier(concoctionsIngredientsTierSix, concoctionSection.getStringList("Tier_Six_Ingredients"));
loadConcoctionsTier(concoctionsIngredientsTierSeven, concoctionSection.getStringList("Tier_Seven_Ingredients"));
loadConcoctionsTier(concoctionsIngredientsTierEight, concoctionSection.getStringList("Tier_Eight_Ingredients"));
-
+
concoctionsIngredientsTierTwo.addAll(concoctionsIngredientsTierOne);
concoctionsIngredientsTierThree.addAll(concoctionsIngredientsTierTwo);
concoctionsIngredientsTierFour.addAll(concoctionsIngredientsTierThree);
@@ -73,7 +73,7 @@ private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> in
if (ingredientStrings != null && ingredientStrings.size() > 0) {
for (String ingredientString : ingredientStrings) {
ItemStack ingredient = loadIngredient(ingredientString);
-
+
if (ingredient != null) {
ingredientList.add(ingredient);
}
@@ -91,7 +91,7 @@ private void loadPotionMap() {
for (String dataValue : potionSection.getKeys(false)) {
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(dataValue));
-
+
if (potion != null) {
potionMap.put(potion.getDataValue(), potion);
pass++;
@@ -100,30 +100,31 @@ private void loadPotionMap() {
fail++;
}
}
-
- mcMMO.p.getLogger().info("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
+
+ mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
}
/**
* Parse a ConfigurationSection representing a AlchemyPotion.
* Returns null if input cannot be parsed.
- *
+ *
* @param potion_section ConfigurationSection to be parsed.
+ *
* @return Parsed AlchemyPotion.
*/
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
try {
short dataValue = Short.parseShort(potion_section.getName());
-
+
String name = potion_section.getString("Name");
-
+
List<String> lore = new ArrayList<String>();
if (potion_section.contains("Lore")) {
for (String line : potion_section.getStringList("Lore")) {
lore.add(line);
}
}
-
+
List<PotionEffect> effects = new ArrayList<PotionEffect>();
if (potion_section.contains("Effects")) {
for (String effect : potion_section.getStringList("Effects")) {
@@ -167,22 +168,25 @@ private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
* Parse a string representation of an ingredient.
* Format: '&lt;MATERIAL&gt;[:data]'
* Returns null if input cannot be parsed.
- *
+ *
* @param ingredient String representing an ingredient.
+ *
* @return Parsed ingredient.
*/
private ItemStack loadIngredient(String ingredient) {
if (ingredient == null || ingredient.isEmpty()) {
return null;
}
+
String[] parts = ingredient.split(":");
-
+
Material material = parts.length > 0 ? Material.getMaterial(parts[0]) : null;
short data = parts.length > 1 ? Short.parseShort(parts[1]) : 0;
-
+
if (material != null) {
return new ItemStack(material, 1, data);
}
+
return null;
}
}
@@ -6,6 +6,10 @@
GRACEFUL_ROLL,
ROLL,
+ /* ALCHEMY */
+ CATALYSIS,
+ CONCOCTIONS,
+
/* ARCHERY */
DAZE,
RETRIEVE,
@@ -36,7 +36,7 @@
public enum SkillType {
ACROBATICS(AcrobaticsManager.class, Color.WHITE, ImmutableList.of(SecondaryAbility.DODGE, SecondaryAbility.GRACEFUL_ROLL, SecondaryAbility.ROLL)),
- ALCHEMY(AlchemyManager.class, Color.FUCHSIA, null),
+ ALCHEMY(AlchemyManager.class, Color.FUCHSIA, ImmutableList.of(SecondaryAbility.CATALYSIS, SecondaryAbility.CONCOCTIONS)),
ARCHERY(ArcheryManager.class, Color.MAROON, ImmutableList.of(SecondaryAbility.DAZE, SecondaryAbility.RETRIEVE, SecondaryAbility.SKILL_SHOT)),
AXES(AxesManager.class, Color.AQUA, AbilityType.SKULL_SPLITTER, ToolType.AXE, ImmutableList.of(SecondaryAbility.ARMOR_IMPACT, SecondaryAbility.AXE_MASTERY, SecondaryAbility.CRITICAL_HIT, SecondaryAbility.GREATER_IMPACT)),
EXCAVATION(ExcavationManager.class, Color.fromRGB(139, 69, 19), AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL, ImmutableList.of(SecondaryAbility.EXCAVATION_TREASURE_HUNTER)),
@@ -10,7 +10,7 @@
public class McMMOPlayerBrewEvent extends McMMOPlayerSkillEvent implements Cancellable {
private Block brewingStand;
-
+
private boolean cancelled;
public McMMOPlayerBrewEvent(Player player, Block brewingStand) {
@@ -8,7 +8,7 @@
public class McMMOPlayerCatalysisEvent extends McMMOPlayerSkillEvent implements Cancellable {
private double speed;
-
+
private boolean cancelled;
public McMMOPlayerCatalysisEvent(Player player, double speed) {
@@ -598,20 +598,21 @@ public void onEntityTarget(EntityTargetEvent event) {
/**
* Handle PotionSplash events in order to fix broken Splash Potion of Saturation.
- *
+ *
* @param event The event to process
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) {
for (PotionEffect effect : ((PotionMeta) event.getEntity().getItem().getItemMeta()).getCustomEffects()) {
- // (effect.getType() == PotionEffectType.SATURATION) is seemingly broken, so we use deprecated method for now.
- if (effect.getType().getId() == 23) {
- for (LivingEntity entity : event.getAffectedEntities()) {
- int duration = (int) (effect.getDuration() * event.getIntensity(entity));
- entity.addPotionEffect(new PotionEffect(effect.getType(), duration, effect.getAmplifier(), effect.isAmbient()));
- }
+ // (effect.getType() != PotionEffectType.SATURATION) is seemingly broken, so we use deprecated method for now.
+ if (effect.getType().getId() != 23) {
+ return;
+ }
+
+ for (LivingEntity entity : event.getAffectedEntities()) {
+ int duration = (int) (effect.getDuration() * event.getIntensity(entity));
+ entity.addPotionEffect(new PotionEffect(effect.getType(), duration, effect.getAmplifier(), effect.isAmbient()));
}
- return;
}
}
}
@@ -136,8 +136,8 @@ public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
event.setExpToDrop(UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop()));
}
- @EventHandler(ignoreCancelled = true)
- public void onAlchemyClickEvent(InventoryClickEvent event) {
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onInventoryClickEventNormal(InventoryClickEvent event) {
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
return;
}
@@ -149,8 +149,8 @@ public void onAlchemyClickEvent(InventoryClickEvent event) {
AlchemyPotionBrewer.handleInventoryClick(event);
}
- @EventHandler(ignoreCancelled = true)
- public void onAlchemyDragEvent(InventoryDragEvent event) {
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onInventoryDragEvent(InventoryDragEvent event) {
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
return;
}
@@ -162,13 +162,13 @@ public void onAlchemyDragEvent(InventoryDragEvent event) {
AlchemyPotionBrewer.handleInventoryDrag(event);
}
- @EventHandler(ignoreCancelled = true)
- public void onAlchemyMoveItemEvent(InventoryMoveItemEvent event) {
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
if (event.getDestination().getType() != InventoryType.BREWING || !(event.getDestination().getHolder() instanceof BrewingStand)) {
return;
}
- if (Config.getInstance().getPreventHopperTransfer() && event.getItem() != null && event.getItem().getType() != Material.POTION) {
+ if (Config.getInstance().getPreventHopperTransfer() && event.getItem() != null && event.getItem().getType() != Material.POTION) {
event.setCancelled(true);
return;
}
@@ -6,6 +6,7 @@
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
+import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.alchemy.McMMOPlayerBrewEvent;
@@ -32,7 +33,7 @@ public AlchemyBrewTask(Block brewingStand, Player player) {
brewSpeed = DEFAULT_BREW_SPEED;
brewTimer = DEFAULT_BREW_TICKS;
- if (player != null && !Misc.isNPCEntity(player) && Permissions.catalysis(player)) {
+ if (player != null && !Misc.isNPCEntity(player) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CATALYSIS)) {
double catalysis = UserManager.getPlayer(player).getAlchemyManager().getBrewSpeed();
if (Permissions.lucky(player, SkillType.ALCHEMY)) {
@@ -2,13 +2,11 @@
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import org.bukkit.block.Block;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
-import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.runnables.skills.AlchemyBrewTask;
public final class Alchemy {
@@ -31,7 +29,7 @@ private Tier(int numerical) {
public int toNumerical() {
return numerical;
}
-
+
public static Tier fromNumerical(int numerical) {
for (Tier tier : Tier.values()) {
if (tier.toNumerical() == numerical) {
@@ -45,22 +43,21 @@ protected int getLevel() {
return AdvancedConfig.getInstance().getConcoctionsTierLevel(this);
}
}
-
+
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 double potionXp = ExperienceConfig.getInstance().getPotionXP();
-
public static Map<Block, AlchemyBrewTask> brewingStandMap = new HashMap<Block, AlchemyBrewTask>();
- private Alchemy() {};
-
+ 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) {
@@ -70,14 +67,14 @@ public static double calculateBrewSpeed(int skillLevel) {
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.getLogger().info("Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
- for (Entry<Block, AlchemyBrewTask> entry : brewingStandMap.entrySet()) {
- entry.getValue().finishImmediately();
+ mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
+ for (AlchemyBrewTask alchemyBrewTask : brewingStandMap.values()) {
+ alchemyBrewTask.finishImmediately();
}
}
}
Oops, something went wrong.

0 comments on commit 6143003

Please sign in to comment.