Assorted bug fixes & cleanup.

This commit is contained in:
GJ 2012-03-09 01:23:32 -05:00
parent 9dfcbf1797
commit 6e8cfe5ec9
5 changed files with 136 additions and 97 deletions

View File

@ -21,6 +21,8 @@ Version 2.0.00-dev
= Fixed issue where every block broken had a herbalism check applied
= Fixed issue where blocks weren't being removed from the watchlist
= Fixed exploit where you could use /ptp to teleport to anyone
= Fixed bug where Green Terra didn't work on Stone Brick
= Fixed bug where Tree Feller could be used without permissions
! Changed inspect failed message to say inspect rather than whois
! Changed Call of the Wild to activate on left-click rather than right-click
! Changed Blast Mining to track based on Entity ID vs. Location

View File

@ -1,10 +1,15 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Excavation;
import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining;
public enum AbilityType
{
@ -15,7 +20,8 @@ public enum AbilityType
SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter"), "Skills.SkullSplitterPlayerOff"),
TREE_FELLER(LoadProperties.treeFellerCooldown, mcLocale.getString("Skills.TreeFellerOn"), mcLocale.getString("Skills.TreeFellerOff"), "Skills.TreeFellerPlayer", mcLocale.getString("Skills.YourTreeFeller"), "Skills.TreeFellerPlayerOff"),
SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"), "Skills.SerratedStrikesPlayerOff"),
BLAST_MINING(LoadProperties.blastMiningCooldown, null, null, "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), null);
BLAST_MINING(LoadProperties.blastMiningCooldown, null, null, "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), null),
LEAF_BLOWER(0, null, null, null, null, null);
private int cooldown;
private String abilityOn;
@ -118,10 +124,10 @@ public enum AbilityType
{
switch(this)
{
case BLAST_MINING:
return PP.getBlastMiningInformed();
case BERSERK:
return PP.getBerserkInformed();
case BLAST_MINING:
return PP.getBlastMiningInformed();
case SUPER_BREAKER:
return PP.getSuperBreakerInformed();
case GIGA_DRILL_BREAKER:
@ -142,12 +148,12 @@ public enum AbilityType
{
switch(this)
{
case BLAST_MINING:
PP.setBlastMiningInformed(bool);
break;
case BERSERK:
PP.setBerserkInformed(bool);
break;
case BLAST_MINING:
PP.setBlastMiningInformed(bool);
break;
case SUPER_BREAKER:
PP.setSuperBreakerInformed(bool);
break;
@ -175,10 +181,14 @@ public enum AbilityType
{
case BERSERK:
return mcPermissions.getInstance().unarmedAbility(player);
case BLAST_MINING:
return mcPermissions.getInstance().blastMining(player);
case GIGA_DRILL_BREAKER:
return mcPermissions.getInstance().excavationAbility(player);
case GREEN_TERRA:
return mcPermissions.getInstance().herbalismAbility(player);
case LEAF_BLOWER:
return mcPermissions.getInstance().woodcutting(player);
case SERRATED_STRIKES:
return mcPermissions.getInstance().swordsAbility(player);
case SKULL_SPLIITER:
@ -187,9 +197,26 @@ public enum AbilityType
return mcPermissions.getInstance().miningAbility(player);
case TREE_FELLER:
return mcPermissions.getInstance().woodCuttingAbility(player);
case BLAST_MINING:
return mcPermissions.getInstance().blastMining(player);
}
return false;
}
public boolean blockCheck(Block block) {
switch (this) {
case BERSERK:
return (Excavation.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW));
case GIGA_DRILL_BREAKER:
return Excavation.canBeGigaDrillBroken(block);
case GREEN_TERRA:
return Herbalism.canBeGreenTerra(block);
case LEAF_BLOWER:
return block.getType().equals(Material.LEAVES);
case SUPER_BREAKER:
return Mining.canBeSuperBroken(block);
case TREE_FELLER:
return block.getType().equals(Material.LOG);
default:
return false;
}
}
}

View File

@ -3,14 +3,15 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.BlockChecks;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -21,6 +22,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager;
@ -138,28 +140,27 @@ public class mcBlockListener implements Listener {
* WOOD CUTTING
*/
if(mcPermissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
if (mcPermissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
if (LoadProperties.woodcuttingrequiresaxe && ItemChecks.isAxe(inhand)) {
WoodCutting.woodcuttingBlockCheck(player, block, plugin);
}
else if (!LoadProperties.woodcuttingrequiresaxe) {
WoodCutting.woodcuttingBlockCheck(player, block, plugin);
}
if (PP.getTreeFellerMode()) {
WoodCutting.treeFeller(event, plugin);
}
}
if (PP.getTreeFellerMode() && mcPermissions.getInstance().woodCuttingAbility(player)) {
WoodCutting.treeFeller(event, plugin);
}
/*
* EXCAVATION
*/
if (Excavation.canBeGigaDrillBroken(block) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 0x5) {
if(LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player);
}
else if(!LoadProperties.excavationRequiresShovel) {
else if (!LoadProperties.excavationRequiresShovel) {
Excavation.excavationProcCheck(block, player);
}
}
@ -173,119 +174,92 @@ public class mcBlockListener implements Listener {
}
}
/**
* Monitor BlockDamage events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event)
{
public void onBlockDamage(BlockDamageEvent event) {
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
ItemStack inhand = player.getItemInHand();
Block block = event.getBlock();
int id = block.getTypeId();
Material mat = block.getType();
/*
* ABILITY PREPARATION CHECKS
*/
if(BlockChecks.abilityBlockCheck(mat))
{
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
Skills.abilityCheck(player, SkillType.HERBALISM);
if(PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().woodCuttingAbility(player))
if (BlockChecks.abilityBlockCheck(mat)) {
if (PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block)) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().woodCuttingAbility(player)) { //Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING);
if(PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block))
}
else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block)) {
Skills.abilityCheck(player, SkillType.MINING);
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
}
else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block)) {
Skills.abilityCheck(player, SkillType.EXCAVATION);
}
else if (PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || mat.equals(Material.SNOW))) {
Skills.abilityCheck(player, SkillType.UNARMED);
}
}
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || mat.equals(Material.SNOW)))
Skills.abilityCheck(player, SkillType.UNARMED);
/*
* TREE FELLER STUFF
*/
if(LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getTreeFellerMode())
/* TREE FELLER SOUNDS */
if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getTreeFellerMode()) {
SpoutStuff.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
}
/*
* GREEN TERRA STUFF
* ABILITY TRIGGER CHECKS
*/
if(PP.getGreenTerraMode() && mcPermissions.getInstance().herbalismAbility(player))
Herbalism.greenTerra(player, block);
/*
* GIGA DRILL BREAKER CHECKS
*/
if(PP.getGigaDrillBreakerMode() && Excavation.canBeGigaDrillBroken(block) && m.blockBreakSimulate(block, player, true) && mcPermissions.getInstance().excavationAbility(player))
{
if(LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand))
{
if (Skills.triggerCheck(player, block, AbilityType.GREEN_TERRA)) {
Herbalism.greenTerra(player, block);
}
else if (Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
else if(!LoadProperties.excavationRequiresShovel)
{
else if (!LoadProperties.excavationRequiresShovel) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
/*
* BERSERK MODE CHECKS
*/
if(PP.getBerserkMode()
&& m.blockBreakSimulate(block, player, true)
&& player.getItemInHand().getTypeId() == 0
&& (Excavation.canBeGigaDrillBroken(block) || id == 78)
&& mcPermissions.getInstance().unarmedAbility(player))
{
event.setInstaBreak(true);
if(LoadProperties.spoutEnabled)
else if (Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
if (inhand.getType().equals(Material.AIR)) {
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
}
if (LoadProperties.spoutEnabled) {
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
/*
* SUPER BREAKER CHECKS
*/
if(PP.getSuperBreakerMode()
&& Mining.canBeSuperBroken(block)
&& m.blockBreakSimulate(block, player, true)
&& mcPermissions.getInstance().miningAbility(player))
{
if(LoadProperties.miningrequirespickaxe)
{
if(ItemChecks.isMiningPick(inhand)){
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
}
} else {
else if (Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
}
else if (!LoadProperties.miningrequirespickaxe) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
}
}
/*
* LEAF BLOWER CHECKS
*/
if(id == 18
&& mcPermissions.getInstance().woodCuttingAbility(player)
&& PP.getSkillLevel(SkillType.WOODCUTTING) >= 100
&& m.blockBreakSimulate(block, player, true))
{
if(LoadProperties.woodcuttingrequiresaxe)
{
if(ItemChecks.isAxe(inhand)){
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}
}
else if(inhand.getTypeId() != 359)
{
else if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100) {
if (LoadProperties.woodcuttingrequiresaxe && ItemChecks.isAxe(inhand)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}
else if (!LoadProperties.woodcuttingrequiresaxe && inhand.getType().equals(Material.SHEARS)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}
}
}

View File

@ -22,7 +22,7 @@ public class Herbalism
public static void greenTerra(Player player, Block block){
PlayerInventory inventory = player.getInventory();
boolean hasSeeds = inventory.contains(Material.SEEDS);
if(block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT){
if(block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT || block.getType() == Material.SMOOTH_BRICK){
if(!hasSeeds)
player.sendMessage("You need more seeds to spread Green Terra");
if(hasSeeds && block.getType() != Material.WHEAT)

View File

@ -4,6 +4,7 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -305,4 +306,39 @@ public class Skills
}
}
}
public static boolean triggerCheck(Player player, Block block, AbilityType ability) {
boolean activate = true;
PlayerProfile PP = Users.getProfile(player);
if (!ability.getPermissions(player)) {
activate = false;
return activate;
}
if (!ability.equals(AbilityType.LEAF_BLOWER)) {
if (!ability.getMode(PP)) {
activate = false;
return activate;
}
}
switch (ability) {
case BERSERK:
case GIGA_DRILL_BREAKER:
case SUPER_BREAKER:
case LEAF_BLOWER:
if (!m.blockBreakSimulate(block, player, true)) {
activate = false;
break;
}
if (!ability.blockCheck(block)) {
activate = false;
break;
}
default:
break;
}
return activate;
}
}