mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Begin trying to remove newly-deprecated "magic numbers"
This commit is contained in:
parent
a639a37637
commit
fd8d9b02a9
@ -29,6 +29,7 @@ import org.bukkit.entity.Skeleton.SkeletonType;
|
|||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.Wool;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
@ -386,7 +387,7 @@ public class FishingManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drop.setDurability(sheep.getColor().getWoolData());
|
drop.setData(new Wool(sheep.getColor()));
|
||||||
sheep.setSheared(true);
|
sheep.setSheared(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -226,7 +226,6 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockState.setRawData((byte) 0x0);
|
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
|
|
||||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||||
|
@ -105,7 +105,6 @@ public class MiningManager extends SkillManager {
|
|||||||
|
|
||||||
tnt.setMetadata(mcMMO.tntMetadataKey, new FixedMetadataValue(mcMMO.p, player.getName()));
|
tnt.setMetadata(mcMMO.tntMetadataKey, new FixedMetadataValue(mcMMO.p, player.getName()));
|
||||||
tnt.setFuseTicks(0);
|
tnt.setFuseTicks(0);
|
||||||
targetBlock.setData((byte) 0x0);
|
|
||||||
targetBlock.setType(Material.AIR);
|
targetBlock.setType(Material.AIR);
|
||||||
|
|
||||||
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||||
|
@ -77,7 +77,7 @@ public class RepairManager extends SkillManager {
|
|||||||
|
|
||||||
// Level check
|
// Level check
|
||||||
if (skillLevel < minimumRepairableLevel) {
|
if (skillLevel < minimumRepairableLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(itemId)));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(item.getType())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ public class SmeltingManager extends SkillManager {
|
|||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
blockState.setRawData((byte) 0x0);
|
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
|
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
|
||||||
return true;
|
return true;
|
||||||
|
@ -206,7 +206,7 @@ public class TamingManager extends SkillManager {
|
|||||||
int heldItemAmount = heldItem.getAmount();
|
int heldItemAmount = heldItem.getAmount();
|
||||||
|
|
||||||
if (heldItemAmount < summonAmount) {
|
if (heldItemAmount < summonAmount) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getTypeId())));
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.SmoothBrick;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@ -51,13 +53,22 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean blockCrackerCheck(BlockState blockState) {
|
public boolean blockCrackerCheck(BlockState blockState) {
|
||||||
Material type = blockState.getType();
|
MaterialData data = blockState.getData();
|
||||||
|
|
||||||
switch (type) {
|
switch (blockState.getType()) {
|
||||||
case SMOOTH_BRICK:
|
case SMOOTH_BRICK:
|
||||||
if (Unarmed.blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) {
|
if (!Unarmed.blockCrackerSmoothBrick) {
|
||||||
blockState.setRawData((byte) 0x2);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Yes, this is awkward, but it's the *right* way to do it.
|
||||||
|
SmoothBrick smoothBrick = (SmoothBrick) data;
|
||||||
|
|
||||||
|
if (smoothBrick.getMaterial() != Material.STONE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
smoothBrick.setMaterial(Material.COBBLESTONE);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -103,9 +103,9 @@ public final class Woodcutting {
|
|||||||
else {
|
else {
|
||||||
Location location = blockState.getLocation();
|
Location location = blockState.getLocation();
|
||||||
Tree tree = (Tree) blockState.getData();
|
Tree tree = (Tree) blockState.getData();
|
||||||
ItemStack item = new ItemStack(Material.LOG, 1, tree.getSpecies().getData());
|
ItemStack item = tree.toItemStack(1);
|
||||||
|
|
||||||
switch (((Tree) blockState.getData()).getSpecies()) {
|
switch (tree.getSpecies()) {
|
||||||
case GENERIC:
|
case GENERIC:
|
||||||
if (Config.getInstance().getOakDoubleDropsEnabled()) {
|
if (Config.getInstance().getOakDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
|
@ -8,7 +8,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.Tree;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@ -161,18 +160,17 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
|
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Tree tree = (Tree) blockState.getData();
|
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case LOG:
|
case LOG:
|
||||||
if (canGetDoubleDrops()) {
|
if (canGetDoubleDrops()) {
|
||||||
Woodcutting.checkForDoubleDrop(blockState);
|
Woodcutting.checkForDoubleDrop(blockState);
|
||||||
}
|
}
|
||||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||||
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData()));
|
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
|
Misc.randomDropItem(blockState.getLocation(), blockState.getData().toItemStack(1), 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -180,7 +178,6 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockState.setRawData((byte) 0x0);
|
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.DyeColor;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.Dye;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.api.SpoutToolsAPI;
|
import com.gmail.nossr50.api.SpoutToolsAPI;
|
||||||
@ -499,7 +500,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
return item.getData().getData() == DyeColor.BLUE.getDyeData();
|
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -545,7 +546,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
return item.getData().getData() == DyeColor.BLUE.getDyeData();
|
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -580,7 +581,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
return item.getData().getData() == DyeColor.BROWN.getDyeData();
|
return ((Dye) item.getData()).getColor() == DyeColor.BROWN;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user