mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Cooldowns for Blast Mining are now fully functional (BUILD IS SAFE AGAIN)
This commit is contained in:
parent
8254a8ab0f
commit
f5fc941916
@ -96,6 +96,7 @@ public class Database {
|
||||
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` 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;");
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
@ -129,6 +130,7 @@ public class Database {
|
||||
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"spawn`");
|
||||
|
||||
checkDatabaseStructure();
|
||||
checkDatabaseStructureForBlastMining();
|
||||
}
|
||||
|
||||
public void checkDatabaseStructure()
|
||||
@ -151,7 +153,7 @@ public class Database {
|
||||
}
|
||||
}
|
||||
} 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 + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
@ -177,8 +179,8 @@ public class Database {
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Updating mcMMO MySQL tables...");
|
||||
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(10) NOT NULL DEFAULT '0' ;");
|
||||
System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"),
|
||||
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, 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 String abilityOn;
|
||||
@ -118,6 +118,8 @@ public enum AbilityType
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case BLAST_MINING:
|
||||
return PP.getBlastMiningInformed();
|
||||
case BERSERK:
|
||||
return PP.getBerserkInformed();
|
||||
case SUPER_BREAKER:
|
||||
@ -140,6 +142,9 @@ public enum AbilityType
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case BLAST_MINING:
|
||||
PP.setBlastMiningInformed(bool);
|
||||
break;
|
||||
case BERSERK:
|
||||
PP.setBerserkInformed(bool);
|
||||
break;
|
||||
|
@ -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);
|
||||
//lastlogin = Integer.parseInt(users.get(1).get(0));
|
||||
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
|
||||
* its not pretty but it works
|
||||
|
@ -56,6 +56,7 @@ import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
|
||||
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 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);
|
||||
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);
|
||||
b.setType(Material.AIR);
|
||||
tnt.setFuseTicks(0);
|
||||
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
|
||||
PP.setBlastMiningInformed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import org.bukkit.entity.*;
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
@ -63,13 +64,14 @@ public class mcTimer implements Runnable
|
||||
/*
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.AXES);
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.EXCAVATION);
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.HERBALISM);
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.MINING);
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.SWORDS);
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.UNARMED);
|
||||
Skills.watchCooldown(player, PP, curTime, SkillType.WOODCUTTING);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
|
||||
|
||||
/*
|
||||
* PLAYER BLEED MONITORING
|
||||
|
@ -55,10 +55,8 @@ public class Skills
|
||||
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))
|
||||
{
|
||||
ability.setInformed(PP, true);
|
||||
|
@ -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.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.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!
|
Loading…
Reference in New Issue
Block a user