Fixed double explosion for Blast Mining, added isSneaking requirement

This commit is contained in:
bm01 2012-04-29 00:42:21 +02:00
parent 2fad8f2ad7
commit d32b32842a
3 changed files with 63 additions and 42 deletions

View File

@ -18,7 +18,6 @@ Version 1.3.06-dev
= Fixed bug where Herbalism required double drops permission to give XP = Fixed bug where Herbalism required double drops permission to give XP
= Fixed bug where {0} would be displayed in front of your power level in mcstats = Fixed bug where {0} would be displayed in front of your power level in mcstats
= Fixed mmoupdate not being useable from console = Fixed mmoupdate not being useable from console
= Fixed bug with repairing wooden tools
= Fixed bug with repairing wooden tools = Fixed bug with repairing wooden tools
= Fixed bug with Nether Wart not awarding XP = Fixed bug with Nether Wart not awarding XP
= Fixed bug with fishing treasures when treasures list is empty = Fixed bug with fishing treasures when treasures list is empty
@ -26,7 +25,6 @@ Version 1.3.06-dev
= Fixed bugs with the way /mctop displayed = Fixed bugs with the way /mctop displayed
= Fixed issues with custom characters & locale files. = Fixed issues with custom characters & locale files.
! Changed how we handled the config file to prevent any bugs when returning values ! Changed how we handled the config file to prevent any bugs when returning values
! Changed default locale name to en-US rather than en_us for the sake of compliance
! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO ! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO
! Changed mcremove to check for users in the MySQL DB before sending queries to remove them ! Changed mcremove to check for users in the MySQL DB before sending queries to remove them
! Changed how the tree feller threshold worked for the better ! Changed how the tree feller threshold worked for the better
@ -40,7 +38,8 @@ Version 1.3.06-dev
! Changed /mcrefresh to work from console ! Changed /mcrefresh to work from console
! Changed /mcrefresh to work for offline players ! Changed /mcrefresh to work for offline players
! Changed UpdateXPBar function to hopefully avoid errors ! Changed UpdateXPBar function to hopefully avoid errors
! Changed /party to show offline party members ! Changed /party to show offline party members
! Changed Blast Mining requirements, now asks for the player to be crouching
Version 1.3.05 Version 1.3.05
+ Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) + Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%)

View File

@ -232,8 +232,8 @@ public class PlayerListener implements Listener {
} }
/* BLAST MINING CHECK */ /* BLAST MINING CHECK */
if (Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) { if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
BlastMining.remoteDetonation(player, plugin); BlastMining.detonate(event, player, plugin);
} }
break; break;
@ -255,8 +255,8 @@ public class PlayerListener implements Listener {
Item.itemchecks(player); Item.itemchecks(player);
/* BLAST MINING CHECK */ /* BLAST MINING CHECK */
if (Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) { if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
BlastMining.remoteDetonation(player, plugin); BlastMining.detonate(event, player, plugin);
} }
break; break;

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.AbilityType; import com.gmail.nossr50.datatypes.AbilityType;
@ -237,52 +238,73 @@ public class BlastMining {
} }
/** /**
* Remotely detonate TNT for Blast Mining. * Detonate TNT for Blast Mining
* *
* @param player Player detonating the TNT * @param player Player detonating the TNT
* @param plugin mcMMO plugin instance * @param plugin mcMMO plugin instance
*/ */
public static void remoteDetonation(Player player, mcMMO plugin) { public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) {
final byte SNOW = 78;
final byte AIR = 0;
final int BLOCKS_AWAY = 100;
final int TIME_CONVERSION_FACTOR = 1000;
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
HashSet<Byte> transparent = new HashSet<Byte>();
transparent.add(SNOW); if (PP.getSkillLevel(SkillType.MINING) < 125)
transparent.add(AIR); return;
Block block = player.getTargetBlock(transparent, BLOCKS_AWAY); Block block = event.getClickedBlock();
if (block.getType().equals(Material.TNT) && Misc.blockBreakSimulate(block, player, true) && PP.getSkillLevel(SkillType.MINING) >= 125) { if (block == null || block.getType() != Material.TNT) {
final double MAX_DISTANCE_AWAY = 10.0; final byte SNOW = 78;
AbilityType ability = AbilityType.BLAST_MINING; final byte AIR = 0;
final int BLOCKS_AWAY = 100;
/* Check Cooldown */ HashSet<Byte> transparent = new HashSet<Byte>();
if(!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)"); transparent.add(SNOW);
transparent.add(AIR);
block = player.getTargetBlock(transparent, BLOCKS_AWAY);
if (block.getType() != Material.TNT) {
return; return;
} }
/* Send message to nearby players */
for(Player y : player.getWorld().getPlayers()) {
if(y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
y.sendMessage(ability.getAbilityPlayer(player));
}
}
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
/* Create the TNT entity */
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
plugin.tntTracker.put(tnt.getEntityId(), player);
block.setType(Material.AIR);
tnt.setFuseTicks(0);
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
PP.setAbilityInformed(ability, false);
} }
else if (block.getType() == Material.TNT) {
event.setCancelled(true); // This is the only way I know to avoid the original TNT to be triggered (in case the player is close to it)
}
if (!Misc.blockBreakSimulate(block, player, true)) {
return;
}
final double MAX_DISTANCE_AWAY = 10.0;
final int TIME_CONVERSION_FACTOR = 1000;
AbilityType ability = AbilityType.BLAST_MINING;
/* Check Cooldown */
if(!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
}
/* Send message to nearby players */
for(Player y : player.getWorld().getPlayers()) {
if(y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
y.sendMessage(ability.getAbilityPlayer(player));
}
}
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
/* Create the TNT entity */
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
plugin.tntTracker.put(tnt.getEntityId(), player);
tnt.setFuseTicks(0);
/* Disable the original one */
block.setType(Material.AIR);
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
PP.setAbilityInformed(ability, false);
} }
} }