Cooldowns for Blast Mining are now fully functional (BUILD IS SAFE AGAIN)

This commit is contained in:
nossr50 2012-03-01 13:01:41 -08:00
parent 8254a8ab0f
commit f5fc941916
7 changed files with 44 additions and 17 deletions

View File

@ -96,6 +96,7 @@ public class Database {
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0'," + "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0'," + "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL," Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
@ -129,6 +130,7 @@ public class Database {
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"spawn`"); Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"spawn`");
checkDatabaseStructure(); checkDatabaseStructure();
checkDatabaseStructureForBlastMining();
} }
public void checkDatabaseStructure() public void checkDatabaseStructure()
@ -151,7 +153,7 @@ public class Database {
} }
} }
} catch (SQLException ex) { } catch (SQLException ex) {
System.out.println("Updating mcMMO MySQL tables..."); System.out.println("Updating mcMMO MySQL tables for Fishing...");
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
} }
@ -177,8 +179,8 @@ public class Database {
} }
} }
} catch (SQLException ex) { } catch (SQLException ex) {
System.out.println("Updating mcMMO MySQL tables..."); System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(10) NOT NULL DEFAULT '0' ;"); Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
} }
} }

View File

@ -15,7 +15,7 @@ public enum AbilityType
SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter"), "Skills.SkullSplitterPlayerOff"), 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"), 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"), SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"), "Skills.SerratedStrikesPlayerOff"),
BLAST_MINING(LoadProperties.blastMiningCooldown, mcLocale.getString("Skills.BlastMiningOn"), mcLocale.getString("Skills.BlastMiningOff"), "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), "Skills.BlastMiningPlayerOff"); BLAST_MINING(LoadProperties.blastMiningCooldown, "NOT NEEDED FOR BLAST MINING", "NOT NEEDED FOR BLAST MINING", "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), "NOT NEEDED FOR BLAST MINING");
private int cooldown; private int cooldown;
private String abilityOn; private String abilityOn;
@ -118,6 +118,8 @@ public enum AbilityType
{ {
switch(this) switch(this)
{ {
case BLAST_MINING:
return PP.getBlastMiningInformed();
case BERSERK: case BERSERK:
return PP.getBerserkInformed(); return PP.getBerserkInformed();
case SUPER_BREAKER: case SUPER_BREAKER:
@ -140,6 +142,9 @@ public enum AbilityType
{ {
switch(this) switch(this)
{ {
case BLAST_MINING:
PP.setBlastMiningInformed(bool);
break;
case BERSERK: case BERSERK:
PP.setBerserkInformed(bool); PP.setBerserkInformed(bool);
break; break;

View File

@ -171,7 +171,7 @@ public class PlayerProfile
HashMap<Integer, ArrayList<String>> users = mcMMO.database.Read("SELECT lastlogin, party FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = " + id); HashMap<Integer, ArrayList<String>> users = mcMMO.database.Read("SELECT lastlogin, party FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = " + id);
//lastlogin = Integer.parseInt(users.get(1).get(0)); //lastlogin = Integer.parseInt(users.get(1).get(0));
party = users.get(1).get(1); party = users.get(1).get(1);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.Read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id); HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.Read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id);
/* /*
* I'm still learning MySQL, this is a fix for adding a new table * I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works * its not pretty but it works

View File

@ -56,6 +56,7 @@ import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask; import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
@ -282,14 +283,31 @@ public class mcPlayerListener implements Listener
} }
} }
if(action == Action.RIGHT_CLICK_AIR && is.getTypeId() == LoadProperties.detonatorID) //BLAST MINING
if((action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) && is.getTypeId() == LoadProperties.detonatorID)
{ {
Block b = player.getTargetBlock(null, 100); Block b = player.getTargetBlock(null, 100);
if(b.getType().equals(Material.TNT)) if(b.getType().equals(Material.TNT))
{ {
AbilityType ability = AbilityType.BLAST_MINING;
//Check cooldown
if(!Skills.cooldownOver(player, (PP.getSkillDATS(ability) * 1000), ability.getCooldown()))
{
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(player, (PP.getSkillDATS(ability) * 1000), ability.getCooldown()) + "s)");
return;
}
//Send message to nearby players
for(Player y : player.getWorld().getPlayers())
{
if(y != player && m.isNear(player.getLocation(), y.getLocation(), 10))
y.sendMessage(ability.getAbilityPlayer(player));
}
TNTPrimed tnt = player.getWorld().spawn(b.getLocation(), TNTPrimed.class); TNTPrimed tnt = player.getWorld().spawn(b.getLocation(), TNTPrimed.class);
b.setType(Material.AIR); b.setType(Material.AIR);
tnt.setFuseTicks(0); tnt.setFuseTicks(0);
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
PP.setBlastMiningInformed(false);
} }
} }
} }

View File

@ -20,6 +20,7 @@ import org.bukkit.entity.*;
import com.gmail.nossr50.Combat; import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
@ -63,13 +64,14 @@ public class mcTimer implements Runnable
/* /*
* COOLDOWN MONITORING * COOLDOWN MONITORING
*/ */
Skills.watchCooldown(player, PP, curTime, SkillType.AXES); Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
Skills.watchCooldown(player, PP, curTime, SkillType.EXCAVATION); Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
Skills.watchCooldown(player, PP, curTime, SkillType.HERBALISM); Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
Skills.watchCooldown(player, PP, curTime, SkillType.MINING); Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
Skills.watchCooldown(player, PP, curTime, SkillType.SWORDS); Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
Skills.watchCooldown(player, PP, curTime, SkillType.UNARMED); Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
Skills.watchCooldown(player, PP, curTime, SkillType.WOODCUTTING); Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
/* /*
* PLAYER BLEED MONITORING * PLAYER BLEED MONITORING

View File

@ -55,10 +55,8 @@ public class Skills
return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000); return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000);
} }
public static void watchCooldown(Player player, PlayerProfile PP, long curTime, SkillType skill) public static void watchCooldown(Player player, PlayerProfile PP, long curTime, AbilityType ability)
{ {
AbilityType ability = skill.getAbility();
if(!ability.getInformed(PP) && curTime - (PP.getSkillDATS(ability) * 1000) >= (ability.getCooldown() * 1000)) if(!ability.getInformed(PP) && curTime - (PP.getSkillDATS(ability) * 1000) >= (ability.getCooldown() * 1000))
{ {
ability.setInformed(PP, true); ability.setInformed(PP, true);

View File

@ -412,4 +412,6 @@ Skills.TreeFellerPlayerOff=[[RED]]Tree Feller[[GREEN]] has worn off for [[YELLOW
Skills.SuperBreakerPlayerOff=[[RED]]Super Breaker[[GREEN]] has worn off for [[YELLOW]]{0} Skills.SuperBreakerPlayerOff=[[RED]]Super Breaker[[GREEN]] has worn off for [[YELLOW]]{0}
Skills.SkullSplitterPlayerOff=[[RED]]Skull Splitter[[GREEN]] has worn off for [[YELLOW]]{0} Skills.SkullSplitterPlayerOff=[[RED]]Skull Splitter[[GREEN]] has worn off for [[YELLOW]]{0}
Skills.GigaDrillBreakerPlayerOff=[[RED]]Giga Drill Breaker[[GREEN]] has worn off for [[YELLOW]]{0} Skills.GigaDrillBreakerPlayerOff=[[RED]]Giga Drill Breaker[[GREEN]] has worn off for [[YELLOW]]{0}
Skills.SerratedStrikesPlayerOff=[[RED]]Serrated Strikes[[GREEN]] has worn off for [[YELLOW]]{0} Skills.SerratedStrikesPlayerOff=[[RED]]Serrated Strikes[[GREEN]] has worn off for [[YELLOW]]{0}
Skills.BlastMiningPlayer=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]Blast Mining!
Skills.YourBlastMining=[[GREEN]]Your [[YELLOW]]Blast Mining [[GREEN]]ability is refreshed!