Smelting!

This commit is contained in:
GJ 2013-01-23 16:34:01 -05:00
parent 56d27c3d78
commit 6f0e2437e0
25 changed files with 734 additions and 21 deletions

View File

@ -8,6 +8,7 @@ Key:
- Removal
Version 1.4.00-dev
+ Added new Child Skill - Smelting!
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
+ Added config options for Hylian Luck skill
+ Added display values to Unarmed command for Iron Grip

28
pom.xml
View File

@ -54,12 +54,12 @@
</includes>
</resource>
<resource>
<targetPath>com/gmail/nossr50/locale</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/locale/</directory>
<includes>
<include>locale*.properties</include>
</includes>
<targetPath>com/gmail/nossr50/locale</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/locale/</directory>
<includes>
<include>locale*.properties</include>
</includes>
</resource>
</resources>
<plugins>
@ -116,8 +116,8 @@
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<id>spout-repo</id>
<url>http://nexus.spout.org/content/groups/public/</url>
<id>spout-repo</id>
<url>http://nexus.spout.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
@ -135,12 +135,12 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>

View File

@ -247,6 +247,15 @@ public class Config extends ConfigLoader {
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
/* Smelting */
public int getSmeltingXPCoal() { return config.getInt("Experience.Smelting.Coal", 10); }
public int getSmeltingXPRedstone() { return config.getInt("Experience.Smelting.Redstone", 15); }
public int getSmeltingXPIron() { return config.getInt("Experience.Smelting.Iron", 25); }
public int getSmeltingXPGold() { return config.getInt("Experience.Smelting.Gold", 35); }
public int getSmeltingXPDiamond() { return config.getInt("Experience.Smelting.Diamond", 75); }
public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); }
public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
@ -308,6 +317,10 @@ public class Config extends ConfigLoader {
return getLevelCap("Skills.Repair.Level_Cap");
}
public int getLevelCapSmelting() {
return getLevelCap("Skills.Smelting.Level_Cap");
}
public int getLevelCapSwords() {
return getLevelCap("Skills.Swords.Level_Cap");
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -34,6 +35,7 @@ import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Salvage;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
@ -213,16 +215,30 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreakHigher(BlockBreakEvent event) {
if (event instanceof FakeBlockBreakEvent) {
return;
}
Player player = event.getPlayer();
Block block = event.getBlock();
ItemStack inHand = player.getItemInHand();
if (Misc.isNPC(player)) {
return;
}
if (Permissions.hylianLuck(player) && ItemChecks.isSword(player.getItemInHand()) && !mcMMO.placeStore.isTrue(block)) {
if (mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
return;
}
if (Permissions.hylianLuck(player) && ItemChecks.isSword(inHand)) {
Herbalism.hylianLuck(block, player, event);
}
else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(inHand) && !inHand.containsEnchantment(Enchantment.SILK_TOUCH)) {
SmeltingManager smeltingManager = new SmeltingManager(player);
smeltingManager.fluxMining(event);
}
}
/**

View File

@ -0,0 +1,89 @@
package com.gmail.nossr50.listeners;
import org.bukkit.block.Block;
import org.bukkit.block.Furnace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceExtractEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.FurnaceInventory;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.util.ItemChecks;
public class InventoryListener implements Listener{
private final mcMMO plugin;
public InventoryListener(final mcMMO plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryOpen(InventoryOpenEvent event) {
InventoryType inventoryType = event.getInventory().getType();
if (inventoryType == InventoryType.FURNACE) {
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
Furnace furnace = inventory.getHolder();
Block furnaceBlock = furnace.getBlock();
if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) {
plugin.addToOpenFurnaceTracker(furnaceBlock, event.getPlayer().getName());
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClose(InventoryCloseEvent event) {
InventoryType inventoryType = event.getInventory().getType();
if (inventoryType == InventoryType.FURNACE) {
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
Furnace furnace = inventory.getHolder();
Block furnaceBlock = furnace.getBlock();
if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) {
plugin.removeFromFurnaceTracker(furnaceBlock);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
Block furnaceBlock = event.getBlock();
FurnaceInventory inventory = ((Furnace)furnaceBlock).getInventory();
if (plugin.furnaceIsTracked(furnaceBlock) && ItemChecks.isSmeltable(inventory.getSmelting())) {
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
smeltingManager.fuelEfficiency(event);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
Block furnaceBlock = event.getBlock();
FurnaceInventory inventory = ((Furnace)furnaceBlock).getInventory();
if (plugin.furnaceIsTracked(furnaceBlock) && ItemChecks.isSmeltable(inventory.getSmelting())) {
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
smeltingManager.smeltProcessing(event);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
Block furnaceBlock = event.getBlock();
FurnaceInventory inventory = ((Furnace)furnaceBlock).getInventory();
if (plugin.furnaceIsTracked(furnaceBlock) && ItemChecks.isSmeltable(inventory.getSmelting())) {
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
smeltingManager.vanillaXPBoost(event);
}
}
}

View File

@ -235,7 +235,7 @@ public class PlayerListener implements Listener {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 4 }) }));
}
if (Permissions.luckyAcrobatics(player) || Permissions.luckyArchery(player) || Permissions.luckyAxes(player) || Permissions.luckyFishing(player) || Permissions.luckyHerbalism(player) || Permissions.luckyMining(player) || Permissions.luckyRepair(player) || Permissions.luckySwords(player) || Permissions.luckyTaming(player) || Permissions.luckyUnarmed(player) || Permissions.luckyWoodcutting(player)) {
if (Permissions.luckyAcrobatics(player) || Permissions.luckyArchery(player) || Permissions.luckyAxes(player) || Permissions.luckyFishing(player) || Permissions.luckyHerbalism(player) || Permissions.luckyMining(player) || Permissions.luckyRepair(player) || Permissions.luckySwords(player) || Permissions.luckyTaming(player) || Permissions.luckyUnarmed(player) || Permissions.luckyWoodcutting(player) || Permissions.luckySmelting(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") }));
}

View File

@ -9,6 +9,7 @@ import java.util.List;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
@ -43,6 +44,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.HardcoreListener;
import com.gmail.nossr50.listeners.InventoryListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
@ -70,6 +72,7 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
import com.gmail.nossr50.skills.smelting.SmeltingCommand;
import com.gmail.nossr50.skills.swords.SwordsCommand;
import com.gmail.nossr50.skills.taming.TamingCommand;
import com.gmail.nossr50.skills.unarmed.UnarmedCommand;
@ -86,16 +89,17 @@ import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
public class mcMMO extends JavaPlugin {
private final PlayerListener playerListener = new PlayerListener(this);
private final BlockListener blockListener = new BlockListener(this);
private final EntityListener entityListener = new EntityListener(this);
private final WorldListener worldListener = new WorldListener();
private final HardcoreListener hardcoreListener = new HardcoreListener();
private final InventoryListener inventoryListener = new InventoryListener(this);
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
private static Database database;
public static mcMMO p;
@ -165,6 +169,7 @@ public class mcMMO extends JavaPlugin {
pluginManager.registerEvents(blockListener, this);
pluginManager.registerEvents(entityListener, this);
pluginManager.registerEvents(worldListener, this);
pluginManager.registerEvents(inventoryListener, this);
if (configInstance.getHardcoreEnabled()) {
pluginManager.registerEvents(hardcoreListener, this);
@ -336,6 +341,7 @@ public class mcMMO extends JavaPlugin {
aliasMap.put(LocaleLoader.getString("Herbalism.SkillName").toLowerCase(), "herbalism");
aliasMap.put(LocaleLoader.getString("Mining.SkillName").toLowerCase(), "mining");
aliasMap.put(LocaleLoader.getString("Repair.SkillName").toLowerCase(), "repair");
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "smelting");
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
@ -351,6 +357,7 @@ public class mcMMO extends JavaPlugin {
getCommand("herbalism").setExecutor(new HerbalismCommand());
getCommand("mining").setExecutor(new MiningCommand());
getCommand("repair").setExecutor(new RepairCommand());
getCommand("smelting").setExecutor(new SmeltingCommand());
getCommand("swords").setExecutor(new SwordsCommand());
getCommand("taming").setExecutor(new TamingCommand());
getCommand("unarmed").setExecutor(new UnarmedCommand());
@ -517,6 +524,22 @@ public class mcMMO extends JavaPlugin {
tntTracker.remove(tntID);
}
public void addToOpenFurnaceTracker(Block furnace, String playerName) {
furnaceTracker.put(furnace, playerName);
}
public boolean furnaceIsTracked(Block furnace) {
return furnaceTracker.containsKey(furnace);
}
public void removeFromFurnaceTracker(Block furnace) {
furnaceTracker.remove(furnace);
}
public Player getFurnacePlayer(Block furnace) {
return getServer().getPlayer(furnaceTracker.get(furnace));
}
public static String getMainDirectory() {
return mainDirectory;
}

View File

@ -60,8 +60,11 @@ public abstract class SkillCommand implements CommandExecutor {
permissionsCheck();
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
}
if (effectsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));

View File

@ -20,6 +20,13 @@ public abstract class SkillManager {
this.activationChance = Misc.calculateActivationChance(Permissions.lucky(player, skill));
}
public SkillManager(Player player, SkillType child, SkillType parent1, SkillType parent2) {
this.player = player;
this.profile = Users.getProfile(player);
this.skillLevel = (profile.getSkillLevel(parent1) / 4) + (profile.getSkillLevel(parent2) / 4); //TODO: Make this cleaner somehow
this.activationChance = Misc.calculateActivationChance(Permissions.lucky(player, child));
}
public Player getPlayer() {
return player;
}

View File

@ -16,6 +16,7 @@ public enum SkillType {
HERBALISM(AbilityType.GREEN_TERRA, Config.getInstance().getLevelCapHerbalism(), ToolType.HOE, Config.getInstance().getFormulaMultiplierHerbalism()),
MINING(AbilityType.SUPER_BREAKER, Config.getInstance().getLevelCapMining(), ToolType.PICKAXE, Config.getInstance().getFormulaMultiplierMining()),
REPAIR(Config.getInstance().getLevelCapRepair(), Config.getInstance().getFormulaMultiplierRepair()),
SMELTING(Config.getInstance().getLevelCapSmelting(), 0),
SWORDS(AbilityType.SERRATED_STRIKES, Config.getInstance().getLevelCapSwords(), ToolType.SWORD, Config.getInstance().getFormulaMultiplierSwords()),
TAMING(Config.getInstance().getLevelCapTaming(), Config.getInstance().getFormulaMultiplierTaming()),
UNARMED(AbilityType.BERSERK, Config.getInstance().getLevelCapUnarmed(), ToolType.FISTS, Config.getInstance().getFormulaMultiplierUnarmed()),
@ -142,4 +143,14 @@ public enum SkillType {
public int getSkillLevel(Player player) {
return Users.getProfile(player).getSkillLevel(this);
}
public boolean isChildSkill() {
switch (this) {
case SMELTING:
return true;
default:
return false;
}
}
}

View File

@ -580,6 +580,8 @@ public class Herbalism {
else {
item = new ItemStack(Material.APPLE);
}
mcMMO.placeStore.setFalse(block);
break;
case FLOWER_POT:

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillType;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.util.Misc;
public class FluxMiningEventHandler {
private SmeltingManager manager;
private BlockBreakEvent event;
private Block block;
protected FluxMiningEventHandler(SmeltingManager manager, BlockBreakEvent event) {
this.manager = manager;
this.event = event;
this.block = event.getBlock();
}
protected void processDrops() {
ItemStack item = null;
switch (block.getType()) {
case IRON_ORE:
item = new ItemStack(Material.IRON_INGOT);
break;
case GOLD_ORE:
item = new ItemStack(Material.GOLD_INGOT);
break;
default:
break;
}
if (item == null) {
return;
}
Location location = block.getLocation();
int chance = (int) ((Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * (Misc.skillCheck(manager.getProfile().getSkillLevel(SkillType.MINING), Mining.doubleDropsMaxLevel)));
Misc.dropItem(location, item);
Misc.randomDropItem(location, item, chance);
}
protected void eventCancellationAndProcessing() {
event.setCancelled(true);
block.setType(Material.AIR);
}
protected void sendAbilityMessage() {
manager.getPlayer().sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
}
}

View File

@ -0,0 +1,23 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.event.inventory.FurnaceBurnEvent;
public class FuelEfficiencyEventHandler {
private SmeltingManager manager;
private FurnaceBurnEvent event;
private double burnModifier;
protected FuelEfficiencyEventHandler(SmeltingManager manager, FurnaceBurnEvent event) {
this.manager = manager;
this.event = event;
}
protected void calculateBurnModifier() {
this.burnModifier = 1 + ((manager.getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier);
}
protected void modifyBurnTime() {
int burnTime = event.getBurnTime();
event.setBurnTime((int)(burnTime * burnModifier));
}
}

View File

@ -0,0 +1,79 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.skills.SkillType;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
public class SmeltResourceEventHandler {
private SmeltingManager manager;
private FurnaceSmeltEvent event;
protected int skillModifier;
protected SmeltResourceEventHandler(SmeltingManager manager, FurnaceSmeltEvent event) {
this.manager = manager;
this.event = event;
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Smelting.secondSmeltMaxLevel);
}
protected void handleXPGain() {
Player player = manager.getPlayer();
PlayerProfile profile = manager.getProfile();
Material sourceType = event.getSource().getType();
int xp = 0;
switch (sourceType) {
case COAL_ORE:
xp = Config.getInstance().getSmeltingXPCoal();
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
xp = Config.getInstance().getSmeltingXPRedstone();
break;
case IRON_ORE:
xp = Config.getInstance().getSmeltingXPIron();
break;
case GOLD_ORE:
xp = Config.getInstance().getSmeltingXPGold();
break;
case DIAMOND_ORE:
xp = Config.getInstance().getSmeltingXPDiamond();
break;
case LAPIS_ORE:
xp = Config.getInstance().getSmeltingXPLapis();
break;
case EMERALD_ORE:
xp = Config.getInstance().getSmeltingXPEmerald();
break;
default:
break;
}
Skills.xpProcessing(player, profile, SkillType.MINING, xp / 2);
Skills.xpProcessing(player, profile, SkillType.REPAIR, xp / 2);
}
protected void handleBonusSmelts() {
ItemStack result = event.getResult();
result.setAmount(result.getAmount() + 1);
event.setResult(result);
}
}

View File

@ -0,0 +1,18 @@
package com.gmail.nossr50.skills.smelting;
public class Smelting {
public static int burnModifierMaxLevel = 1000;
public static double burnTimeMultiplier = 3.0;
public static double secondSmeltMaxChance = 100;
public static int secondSmeltMaxLevel = 1000;
public static int fluxMiningUnlockLevel = 200;
public static double fluxMiningChance = 33.0;
public static int vanillaXPBoostRank1Level = 100;
public static int vanillaXPBoostRank2Level = 300;
public static int vanillaXPBoostRank3Level = 500;
public static int vanillaXPBoostRank4Level = 700;
public static int vanillaXPBoostRank5Level = 900;
}

View File

@ -0,0 +1,134 @@
package com.gmail.nossr50.skills.smelting;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.SkillType;
import com.gmail.nossr50.util.Permissions;
public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier;
private String secondSmeltChance;
private String secondSmeltChanceLucky;
private String fluxMiningChance;
private String fluxMiningChanceLucky;
private String vanillaXPModifier;
private boolean canFuelEfficiency;
private boolean canSecondSmelt;
private boolean canFluxMine;
private boolean canVanillaXPBoost;
public SmeltingCommand() {
super(SkillType.SMELTING);
this.skillValue = (profile.getSkillLevel(SkillType.MINING) / 4) + (profile.getSkillLevel(SkillType.REPAIR) / 4); //TODO: Make this cleaner somehow
}
@Override
protected void dataCalculations() {
//FUEL EFFICIENCY
burnTimeModifier = String.valueOf(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
//SECOND SMELT
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
secondSmeltChance = secondSmeltStrings[0];
secondSmeltChanceLucky = secondSmeltStrings[1];
//FLUX MINING
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
fluxMiningChance = fluxMiningStrings[0];
fluxMiningChanceLucky = fluxMiningStrings[1];
//VANILLA XP BOOST
if (skillValue >= Smelting.vanillaXPBoostRank5Level) {
vanillaXPModifier = "6";
}
else if (skillValue >= Smelting.vanillaXPBoostRank4Level) {
vanillaXPModifier = "5";
}
else if (skillValue >= Smelting.vanillaXPBoostRank3Level) {
vanillaXPModifier = "4";
}
else if (skillValue >= Smelting.vanillaXPBoostRank2Level) {
vanillaXPModifier = "3";
}
else {
vanillaXPModifier = "2";
}
}
@Override
protected void permissionsCheck() {
canFuelEfficiency = Permissions.fuelEfficiency(player);
canSecondSmelt = Permissions.secondSmelt(player);
canFluxMine = Permissions.fluxMining(player);
canVanillaXPBoost = Permissions.smeltingVanillaXPBoost(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1") }));
}
if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3") }));
}
if (canVanillaXPBoost) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5") }));
}
if (canFluxMine) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
}
@Override
protected void statsDisplay() {
if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", new Object[] { burnTimeModifier }));
}
if (canSecondSmelt) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", new Object[] { secondSmeltChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { secondSmeltChanceLucky }));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", new Object[] { secondSmeltChance }));
}
}
if (canVanillaXPBoost) {
if (skillValue < Smelting.vanillaXPBoostRank1Level) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Smelting.Ability.Locked.0", new Object[] { Smelting.vanillaXPBoostRank1Level } ) }));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", new Object[] { vanillaXPModifier }));
}
}
if (canFluxMine) {
if (skillValue < Smelting.fluxMiningUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Smelting.Ability.Locked.1", new Object[] { Smelting.fluxMiningUnlockLevel } ) }));
}
else if (isLucky) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", new Object[] { fluxMiningChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { fluxMiningChanceLucky }));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", new Object[] { fluxMiningChance }));
}
}
}
}

View File

@ -0,0 +1,80 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceExtractEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class SmeltingManager extends SkillManager {
public SmeltingManager(Player player) {
super(player, SkillType.SMELTING);
}
/**
* Increases burn time for furnace fuel.
*
* @param event The {@link FurnaceBurnEvent} to modify.
*/
public void fuelEfficiency(FurnaceBurnEvent event) {
if (Misc.isNPC(player) || !Permissions.fuelEfficiency(player)) {
return;
}
FuelEfficiencyEventHandler eventHandler = new FuelEfficiencyEventHandler(this, event);
eventHandler.calculateBurnModifier();
eventHandler.modifyBurnTime();
}
public void smeltProcessing(FurnaceSmeltEvent event) {
if (Misc.isNPC(player)) {
return;
}
SmeltResourceEventHandler eventHandler = new SmeltResourceEventHandler(this, event);
if (Permissions.smelting(player)) {
eventHandler.handleXPGain();
}
if (!Permissions.secondSmelt(player)) {
return;
}
eventHandler.calculateSkillModifier();
double chance = (Smelting.secondSmeltMaxChance / Smelting.secondSmeltMaxLevel) * eventHandler.skillModifier;
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.handleBonusSmelts();
}
}
public void fluxMining(BlockBreakEvent event) {
if (skillLevel < Smelting.fluxMiningUnlockLevel || !Permissions.fluxMining(player)) {
return;
}
if (Smelting.fluxMiningChance > Misc.getRandom().nextInt(activationChance)) {
FluxMiningEventHandler eventHandler = new FluxMiningEventHandler(this, event);
eventHandler.processDrops();
eventHandler.eventCancellationAndProcessing();
eventHandler.sendAbilityMessage();
}
}
public void vanillaXPBoost(FurnaceExtractEvent event) {
if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.smeltingVanillaXPBoost(player)) {
return;
}
SmeltingVanillaXPEventHandler eventHandler = new SmeltingVanillaXPEventHandler(this, event);
eventHandler.calculateModifier();
eventHandler.modifyVanillaXP();
}
}

View File

@ -0,0 +1,39 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.event.inventory.FurnaceExtractEvent;
public class SmeltingVanillaXPEventHandler {
private SmeltingManager manager;
private FurnaceExtractEvent event;
private int xpBoostModifier;
protected SmeltingVanillaXPEventHandler(SmeltingManager manager, FurnaceExtractEvent event) {
this.manager = manager;
this.event = event;
}
protected void calculateModifier() {
int skillLevel = manager.getSkillLevel();
if (skillLevel >= Smelting.vanillaXPBoostRank5Level) {
xpBoostModifier = 6;
}
else if (skillLevel >= Smelting.vanillaXPBoostRank4Level) {
xpBoostModifier = 5;
}
else if (skillLevel >= Smelting.vanillaXPBoostRank3Level) {
xpBoostModifier = 4;
}
else if (skillLevel >= Smelting.vanillaXPBoostRank2Level) {
xpBoostModifier = 3;
}
else {
xpBoostModifier = 2;
}
}
protected void modifyVanillaXP() {
int xp = event.getExpToDrop();
event.setExpToDrop(xp * xpBoostModifier);
}
}

View File

@ -303,4 +303,15 @@ public class BlockChecks {
return false;
}
public static boolean canBeFluxMined(Block block) {
switch (block.getType()) {
case IRON_ORE:
case GOLD_ORE:
return true;
default:
return false;
}
}
}

View File

@ -473,4 +473,21 @@ public class ItemChecks {
type == Material.SHEARS || type == Material.FISHING_ROD || type == Material.CARROT_STICK ||
type == Material.FLINT_AND_STEEL || type == Material.BOW;
}
public static boolean isSmeltable(ItemStack itemStack) {
switch (itemStack.getType()) {
case COAL_ORE:
case DIAMOND_ORE:
case GLOWING_REDSTONE_ORE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
case EMERALD_ORE:
return true;
default:
return false;
}
}
}

View File

@ -113,6 +113,10 @@ public class Permissions {
return hasPermission(player, "mcmmo.perks.lucky.repair");
}
public static boolean luckySmelting(Player player) {
return hasPermission(player, "mcmmo.perks.lucky.smelting");
}
public static boolean luckySwords(Player player) {
return hasPermission(player, "mcmmo.perks.lucky.swords");
}
@ -502,6 +506,26 @@ public class Permissions {
return hasPermission(player, "mcmmo.ability.blastmining.detonate");
}
/*
* MCMMO.ABILITY.SMELTING.*
*/
public static boolean fuelEfficiency(Player player) {
return hasPermission(player, "mcmmo.ability.smelting.fuelefficiency");
}
public static boolean secondSmelt(Player player) {
return hasPermission(player, "mcmmo.ability.smelting.secondsmelt");
}
public static boolean fluxMining(Player player) {
return hasPermission(player, "mcmmo.ability.smelting.fluxmining");
}
public static boolean smeltingVanillaXPBoost(Player player) {
return hasPermission(player, "mcmmo.ability.smelting.vanillaxpboost");
}
/*
* MCMMO.ITEM.*
*/
@ -602,4 +626,8 @@ public class Permissions {
public static boolean acrobatics(Player player) {
return hasPermission(player, "mcmmo.skills.acrobatics");
}
public static boolean smelting(Player player) {
return hasPermission(player, "mcmmo.skills.smelting");
}
}

View File

@ -143,6 +143,8 @@ Skills:
Salvage_UnlockLevel: 600
Salvage_tools: true
Salvage_armor: true
Smelting:
Level_Cap: 0
Swords:
Enabled_For_PVP: true
Enabled_For_PVE: true
@ -268,6 +270,14 @@ Experience:
End_Stone: 150
Moss_Stone: 30
Emerald: 1000
Smelting:
Coal: 10
Redstone: 15
Iron: 25
Gold: 35
Lapis: 40
Diamond: 75
Emerald: 100
Taming:
Animal_Taming:
Wolf: 250

View File

@ -557,6 +557,7 @@ Guides.Page.Invalid=Not a valid page number!
Guides.Page.OutOfRange=That page does not exist, there are only {0} total pages.
Guides.Repair=[[DARK_AQUA]]About Repair:\n[[YELLOW]]Repair allows you to use an iron block to repair armor and\n[[YELLOW]]tools, or a gold block to salvage armor and tools.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]Repair tools or armor using the mcMMO Anvil. This is an\n[[YELLOW]]iron block by default and should not be confused with\n[[YELLOW]]the Vanilla Minecraft Anvil.\n[[DARK_AQUA]]How can I use Repair?\n[[YELLOW]]Place down a mcMMO Anvil and right-click to repair the item \n[[YELLOW]]you're currently holding. This consumes 1 item on every use.\n\n[[DARK_AQUA]]How does Repair Mastery work?\n[[YELLOW]]Repair Mastery increases the repair amount. The extra amount\n[[YELLOW]]repaired is influenced by your Repair skill level.\n\n[[DARK_AQUA]]How does Super Repair work?\n[[YELLOW]]Super Repair is a passive ability. When repairing an item,\n[[YELLOW]]it grants players a chance to repair an item with\n[[YELLOW]]double effectiveness.\n\n\n\n\n[[DARK_AQUA]]How does Arcane Forging work?\n[[YELLOW]]This passive ability allows you to repair items with a certain\n[[YELLOW]]chance of maintaining its enchantments. The enchants may be\n[[YELLOW]]kept at their existing levels, downgraded to a lower level,\n[[YELLOW]]or lost entirely.\n\n\n\n[[DARK_AQUA]]How does Salvage work?\n[[YELLOW]]Place down a mcMMO Salvage Anvil and right-click to salvage\n[[YELLOW]]the item you're currently holding.\n[[YELLOW]]This will break the item apart en give back the used ingots.\n[[YELLOW]]Note: You can only salvage fully repaired tools or armor.
Guides.Swords=[[DARK_AQUA]]About Swords:\n[[YELLOW]]This skill awards combat bonuses to anyone fighting with a\n[[YELLOW]]sword.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]XP is gained based on the amount of damage dealt to mobs or \n[[YELLOW]]other players when wielding a sword.\n\n[[DARK_AQUA]]How does Serrated Strikes work?\n[[YELLOW]]Serrated Strikes is an active ability, you can activate it by\n[[YELLOW]]right-clicking with a sword. This ability allows you to deal \n[[YELLOW]]an AoE (Area of Effect) hit. This AoE will do a bonus 25%\n[[YELLOW]]damage and will inflict a bleed effect that lasts for 5 ticks.\n\n\n\n[[DARK_AQUA]]How does Counter Attack work?\n[[YELLOW]]Counter Attack is a passive ability. When taking hits from mobs,\n[[YELLOW]]you will have a chance to reflect 50% of the damage that was \n[[YELLOW]]taken.\n\n\n\n\n[[DARK_AQUA]]How does Bleed work?\n[[YELLOW]]Bleed causes enemies to take damage every two seconds. The \n[[YELLOW]]target will bleed until the effect wears off, or death, \n[[YELLOW]]whichever comes first.\n[[YELLOW]]The duration of the bleed is increased by your sword skill.
Guides.Smelting=Coming soon...
Guides.Taming=[[DARK_AQUA]]About Taming:\n[[YELLOW]]Taming will give players various combat bonuses when using\n[[YELLOW]]tamed wolves.\n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]To gain XP in this skill, you need to tame wolves/ocelots or\n[[YELLOW]]get into combat with your wolves.\n\n[[DARK_AQUA]]How does Call of the Wild work?\n[[YELLOW]]Call of the Wild is an active ability that will allow you to summon\n[[YELLOW]]a wolf or an ocelot by your side. You can do this by\n[[YELLOW]]left-clicking while holding bones or fish.\n\n[[DARK_AQUA]]How does Beast Lore work?\n[[YELLOW]]Beast Lore allows players to inspect pets and to check the\n[[YELLOW]]stats of wolves and ocelots. Left-click a wolf or ocelot to use\n[[YELLOW]]Beast Lore.\n[[DARK_AQUA]]How does Gore work?\n[[YELLOW]]Gore is a passive ability that has a chance of inflicting a\n[[YELLOW]]bleeding effect on your wolves' targets.\n\n[[DARK_AQUA]]How does Sharpened Claws work?\n[[YELLOW]]Sharpened Claws provides a damage bonus to damage dealt\n[[YELLOW]]by wolves. The damage bonus depends on your Taming level.\n\n[[DARK_AQUA]]How does Environmentally Aware work?\n[[YELLOW]]This passive ability will allow wolves to teleport to you when\n[[YELLOW]]they get near hazards, such as Cacti/Lava. It will also give\n[[YELLOW]]wolves fall damage immunity.\n\n[[DARK_AQUA]]How does Thick Fur work?\n[[YELLOW]]This passive ability will reduce damage and make wolves\n[[YELLOW]]fire resistant.\n[[DARK_AQUA]]How does Shock Proof work?\n[[YELLOW]]This passive ability reduces damage done to wolves\n[[YELLOW]]from explosions.\n[[DARK_AQUA]]How does Fast Food Service work?\n[[YELLOW]]This passive ability gives wolves a chance to heal whenever\n[[YELLOW]]they perform an attack.
Guides.Unarmed=[[DARK_AQUA]]About Unarmed:\n[[YELLOW]]Unarmed will give players various combat bonuses when using\n[[YELLOW]]your fists as a weapon. \n\n[[DARK_AQUA]]XP GAIN:\n[[YELLOW]]XP is gained based on the amount of damage dealt to mobs \n[[YELLOW]]or other players when unarmed.\n\n[[DARK_AQUA]]How does Berserk work?\n[[YELLOW]]Beserk is an active ability that is activated by\n[[YELLOW]]right-clicking. While in Beserk mode, you deal 50% more\n[[YELLOW]]damage and you can break weak materials instantly, such as\n[[YELLOW]]Dirt and Grass.\n[[DARK_AQUA]]How does Iron Arm work?\n[[YELLOW]]Iron Arm increases the damage dealt when hitting mobs or\n[[YELLOW]]players with your fists.\n[[DARK_AQUA]]How does Arrow Deflect work?\n[[YELLOW]]Arrow Deflect is a passive ability that gives you a chance\n[[YELLOW]]to deflect arrows shot by Skeletons or other players.\n[[YELLOW]]The arrow will fall harmlessly to the ground.\n\n[[DARK_AQUA]]How does Iron Grip work?\n[[YELLOW]]Iron Grip is a passive ability that counters disarm. As your\n[[YELLOW]]unarmed level increases, the chance of preventing a disarm increases.\n[[DARK_AQUA]]How does Disarm work?\n[[YELLOW]]This passive ability allows players to disarm other players,\n[[YELLOW]]causing the target's equipped item to fall to the ground.
Guides.Usage=[[RED]] Usage is /{0} ? [page]
@ -626,3 +627,22 @@ MOTD.PerksPrefix=[[RED]][mcMMO Perks]
MOTD.Vampire.Stats=[[GOLD]][mcMMO] [[DARK_AQUA]]Vampirism Stat Leech: [[DARK_RED]]{0}%
MOTD.Version=[[GOLD]][mcMMO] Running version [[DARK_AQUA]]{0}
MOTD.Website=[[GOLD]][mcMMO] [[GREEN]]{0}[[YELLOW]] - mcMMO Website
#SMELTING
Smelting.Ability.FluxMining=[[RED]]Flux Mining Chance: [[YELLOW]]{0}
Smelting.Ability.FuelEfficiency=[[RED]]Fuel Efficiency Multiplier: [[YELLOW]]{0}x
Smelting.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (VANILLA XP BOOST)
Smelting.Ability.Locked.1=LOCKED UNTIL {0}+ SKILL (FLUX MINING)
Smelting.Ability.SecondSmelt=[[RED]]Second Smelt Chance: [[YELLOW]{0}
Smelting.Ability.VanillaXPBoost=[[RED]]Vanilla XP Multiplier: [[YELLOW]]{0}x
Smelting.Effect.0=Fuel Efficiency
Smelting.Effect.1=Increase the burn time of fuel used in furnaces when smelting
Smelting.Effect.2=Second Smelt
Smelting.Effect.3=Double the resources gained from smelting
Smelting.Effect.4=Vanilla XP Boost
Smelting.Effect.5=Increase vanilla XP gained while smelting
Smelting.Effect.6=Flux Mining
Smelting.Effect.7=Chance for ores to be instantly smelted while mining
Smelting.FluxMining.Success=[[GREEN]]That ore smelted itself!
Smelting.Listener=Smelting:
Smelting.SkillName=SMELTING

View File

@ -124,6 +124,9 @@ commands:
fishing:
aliases: []
description: Detailed skill info
smelting:
aliases: []
description: Detailed skill info
a:
aliases: [ac]
description: Toggle Admin chat or send admin chat messages
@ -264,6 +267,7 @@ permissions:
mcmmo.perks.lucky.herbalism: true
mcmmo.perks.lucky.mining: true
mcmmo.perks.lucky.repair: true
mcmmo.perks.lucky.smelting: true
mcmmo.perks.lucky.swords: true
mcmmo.perks.lucky.taming: true
mcmmo.perks.lucky.unarmed: true
@ -292,6 +296,9 @@ permissions:
mcmmo.perks.lucky.repair:
default: false
description: Gives Repair abilities & skills a 33.3% better chance to activate.
mcmmo.perks.lucky.smelting:
default: false
description: Gives Smelting abilities & skills a 33.3% better chance to activate.
mcmmo.perks.lucky.swords:
default: false
description: Gives Swords abilities & skills a 33.3% better chance to activate.
@ -368,6 +375,7 @@ permissions:
mcmmo.ability.axes.all: true
mcmmo.ability.acrobatics.all: true
mcmmo.ability.blastmining.all: true
mcmmo.ability.smelting.all: true
mcmmo.ability.taming.*:
description: Allows access to all Taming abilities
children:
@ -657,6 +665,25 @@ permissions:
description: Allows access to the Demolitions Expertise ability
mcmmo.ability.blastmining.detonate:
description: Allows for remote TNT detonation
mcmmo.ability.smelting.*:
description: Allows access to all Smelting abilities
children:
mcmmo.ability.smelting.all: true
mcmmo.ability.smelting.all:
description: Allows access to all Smelting abilities
children:
mcmmo.ability.smelting.fluxmining: true
mcmmo.ability.smelting.fuelefficiency: true
mcmmo.ability.smelting.secondsmelt: true
mcmmo.ability.smelting.vanillaxpboost: true
mcmmo.ability.smelting.fluxmining:
description: Allows access to the Flux Mining ability
mcmmo.ability.smelting.fuelefficiency:
description: Allows access to the Fuel Efficiency ability
mcmmo.ability.smelting.secondsmelt:
description: Allows access to the Second Smelt ability
mcmmo.ability.smelting.vanillaxpboost:
description: Allows vanilla XP boost from Smelting
mcmmo.item.*:
description: Implies all mcmmo.item permissions
children:
@ -720,6 +747,7 @@ permissions:
mcmmo.skills.swords: true
mcmmo.skills.axes: true
mcmmo.skills.acrobatics: true
mcmmo.skills.smelting: true
mcmmo.skills.fishing:
description: Allows access to the Fishing skill
mcmmo.skills.taming:
@ -744,5 +772,7 @@ permissions:
description: Allows access to the Axes skill
mcmmo.skills.acrobatics:
description: Allows access to the Acrobatics skill
mcmmo.skills.smelting:
description: Allows access to the Smelting skill
mcmmo.skillreset:
description: Allow reset of skill levels