Another mcMMO WIP, now with 100% more BukkitContrib stuff

This commit is contained in:
nossr50 2011-07-19 13:57:08 -07:00
parent 6592b3db75
commit 463c044b5e
9 changed files with 569 additions and 123 deletions

View File

@ -1,9 +1,16 @@
Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 1.0.37
Berserk mode stops items from being collected
Taming no longer receives xp from wolves being harmed
Fixed bug where players with mcgod could be harmed by AoE
Fixed bug where modifying a skill also modified the xp to the same amount (when it should be zero)
BukkitContrib Stuff
Added 'notifications' on levelup (BukkitContrib)
Added sound effects to abilities
Added an extra cool sound for WoodCutting
Code Stuff
Added getPlayerProfile() which returns a PlayerProfile object for plugin devs
100% more enums

View File

@ -0,0 +1,263 @@
package com.gmail.nossr50.contrib;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkitcontrib.BukkitContrib;
import org.bukkitcontrib.player.ContribCraftPlayer;
import org.bukkitcontrib.player.ContribPlayer;
import org.bukkitcontrib.sound.SoundEffect;
import org.bukkitcontrib.sound.SoundManager;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
public class contribStuff
{
public static void playSoundForPlayer(SoundEffect effect, Player player, Location location)
{
//Contrib stuff
ContribPlayer cPlayer = ContribCraftPlayer.getContribPlayer(player);
if(cPlayer.isBukkitContribEnabled())
{
SoundManager SM = BukkitContrib.getSoundManager();
SM.playSoundEffect(cPlayer, effect, location);
}
}
public static void levelUpNotification(SkillType skillType, ContribPlayer cPlayer)
{
PlayerProfile PP = Users.getProfile(cPlayer);
Material mat = null;
switch(skillType)
{
case SORCERY:
mat = Material.PORTAL;
break;
case TAMING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.PORK;
break;
case 2:
mat = Material.PORK;
break;
case 3:
mat = Material.GRILLED_PORK;
break;
case 4:
mat = Material.GRILLED_PORK;
break;
case 5:
mat = Material.BONE;
break;
}
break;
case MINING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.COAL_ORE;
break;
case 2:
mat = Material.IRON_ORE;
break;
case 3:
mat = Material.GOLD_ORE;
break;
case 4:
mat = Material.LAPIS_ORE;
break;
case 5:
mat = Material.DIAMOND_ORE;
break;
}
break;
case WOODCUTTING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD;
break;
case 2:
mat = Material.WOOD;
break;
case 3:
mat = Material.WOOD;
break;
case 4:
mat = Material.LOG;
break;
case 5:
mat = Material.LOG;
break;
}
break;
case REPAIR:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.COBBLESTONE;
break;
case 2:
mat = Material.IRON_BLOCK;
break;
case 3:
mat = Material.GOLD_BLOCK;
break;
case 4:
mat = Material.LAPIS_BLOCK;
break;
case 5:
mat = Material.DIAMOND_BLOCK;
break;
}
break;
case HERBALISM:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.YELLOW_FLOWER;
break;
case 2:
mat = Material.RED_ROSE;
break;
case 3:
mat = Material.BROWN_MUSHROOM;
break;
case 4:
mat = Material.RED_MUSHROOM;
break;
case 5:
mat = Material.PUMPKIN;
break;
}
break;
case ACROBATICS:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.LEATHER_BOOTS;
break;
case 2:
mat = Material.CHAINMAIL_BOOTS;
break;
case 3:
mat = Material.IRON_BOOTS;
break;
case 4:
mat = Material.GOLD_BOOTS;
break;
case 5:
mat = Material.DIAMOND_BOOTS;
break;
}
break;
case SWORDS:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD_SWORD;
break;
case 2:
mat = Material.STONE_SWORD;
break;
case 3:
mat = Material.IRON_SWORD;
break;
case 4:
mat = Material.GOLD_SWORD;
break;
case 5:
mat = Material.DIAMOND_SWORD;
break;
}
break;
case ARCHERY:
mat = Material.ARROW;
break;
case UNARMED:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.LEATHER_HELMET;
break;
case 2:
mat = Material.CHAINMAIL_HELMET;
break;
case 3:
mat = Material.IRON_HELMET;
break;
case 4:
mat = Material.GOLD_HELMET;
break;
case 5:
mat = Material.DIAMOND_HELMET;
break;
}
break;
case EXCAVATION:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD_SPADE;
break;
case 2:
mat = Material.STONE_SPADE;
break;
case 3:
mat = Material.IRON_SPADE;
break;
case 4:
mat = Material.GOLD_SPADE;
break;
case 5:
mat = Material.DIAMOND_SPADE;
break;
}
break;
case AXES:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD_AXE;
break;
case 2:
mat = Material.STONE_AXE;
break;
case 3:
mat = Material.IRON_AXE;
break;
case 4:
mat = Material.GOLD_AXE;
break;
case 5:
mat = Material.DIAMOND_AXE;
break;
}
break;
default:
mat = Material.WATCH;
break;
}
cPlayer.sendNotification(ChatColor.GREEN+"Level Up!", ChatColor.YELLOW+m.getCapitalized(skillType.toString())+ChatColor.DARK_AQUA+" ("+ChatColor.GREEN+PP.getSkillLevel(skillType)+ChatColor.DARK_AQUA+")", mat);
}
public static Integer getNotificationTier(Integer level)
{
if(level < 200)
return 1;
else if (level >= 200 && level < 400)
return 2;
else if (level >= 400 && level < 600)
return 3;
else if (level >= 600 && level < 800)
return 4;
else
return 5;
}
}

View File

@ -5,6 +5,7 @@ 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.contrib.contribStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@ -18,6 +19,7 @@ import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkitcontrib.sound.SoundEffect;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.*;
@ -91,9 +93,18 @@ public class mcBlockListener extends BlockListener {
if(LoadProperties.miningrequirespickaxe)
{
if(m.isMiningPick(inhand))
Mining.miningBlockCheck(player, block, plugin);
} else {
Mining.miningBlockCheck(player, block, plugin);
{
if(PP.getSkillLevel(SkillType.MINING) >= 500)
Mining.miningBlockCheck(false, player, block, plugin);
else
Mining.miningBlockCheck(true, player, block, plugin);
}
} else
{
if(PP.getSkillLevel(SkillType.MINING) >= 500)
Mining.miningBlockCheck(false, player, block, plugin);
else
Mining.miningBlockCheck(true, player, block, plugin);
}
}
/*
@ -144,8 +155,9 @@ public class mcBlockListener extends BlockListener {
if(mcPermissions.getInstance().woodCuttingAbility(player)
&& PP.getTreeFellerMode()
&& block.getTypeId() == 17
&& m.blockBreakSimulate(block, player, plugin)){
&& m.blockBreakSimulate(block, player, plugin))
{
contribStuff.playSoundForPlayer(SoundEffect.EXPLODE, player, block.getLocation());
WoodCutting.treeFeller(block, player, plugin);
for(Block blockx : plugin.misc.treeFeller)
{
@ -187,7 +199,7 @@ public class mcBlockListener extends BlockListener {
* EXCAVATION
*/
if(mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5)
Excavation.excavationProcCheck(block, player);
Excavation.excavationProcCheck(block.getTypeId(), block.getLocation(), player);
/*
* HERBALISM
*/
@ -237,6 +249,39 @@ public class mcBlockListener extends BlockListener {
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
Unarmed.berserkActivationCheck(player, plugin);
if(mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(block) &&
m.blockBreakSimulate(block, player, plugin) && PP.getSkillLevel(SkillType.MINING) >= 250 && block.getType() != Material.STONE)
{
contribStuff.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
if(PP.getSkillLevel(SkillType.MINING) >= 500)
{
if(Math.random() * 100 > 99)
{
Mining.blockProcSmeltSimulate(block);
Mining.miningBlockCheck(true, player, block, plugin); //PROC
block.setType(Material.AIR);
contribStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
} else
{
if(Math.random() * 100 > 97)
{
Mining.blockProcSmeltSimulate(block);
Mining.miningBlockCheck(true, player, block, plugin); //PROC
block.setType(Material.AIR);
contribStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
}
/*
* TREE FELLAN STUFF
*/
if(block.getTypeId() == 17 && Users.getProfile(player).getTreeFellerMode())
contribStuff.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
/*
* GREEN TERRA STUFF
*/
@ -247,14 +292,18 @@ public class mcBlockListener extends BlockListener {
/*
* GIGA DRILL BREAKER CHECKS
*/
if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player, plugin) && Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand)){
if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player, plugin)
&& Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand)
&& block.getData() != (byte) 5){
int x = 1;
while(x < 4)
{
Excavation.excavationProcCheck(block.getTypeId(), block.getLocation(), player);
x++;
}
if(m.getTier(player) >= 2)
Excavation.excavationProcCheck(block, player);
if(m.getTier(player) >= 3)
Excavation.excavationProcCheck(block, player);
if(m.getTier(player) >= 4)
Excavation.excavationProcCheck(block, player);
Material mat = Material.getMaterial(block.getTypeId());
if(block.getTypeId() == 2)
mat = Material.DIRT;
@ -265,6 +314,9 @@ public class mcBlockListener extends BlockListener {
if(LoadProperties.toolsLoseDurabilityFromAbilities)
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
//Contrib stuff
contribStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
/*
* BERSERK MODE CHECKS
@ -283,6 +335,8 @@ public class mcBlockListener extends BlockListener {
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
block.setType(Material.AIR);
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
contribStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
/*
@ -315,6 +369,7 @@ public class mcBlockListener extends BlockListener {
}
block.setType(Material.AIR);
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
contribStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
if(block.getType() == Material.AIR && plugin.misc.blockWatchList.contains(block))
{

View File

@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
@ -43,6 +44,14 @@ public class mcPlayerListener extends PlayerListener
{
plugin = instance;
}
public void onPlayerPickupItem(PlayerPickupItemEvent event)
{
if(Users.getProfile(event.getPlayer()).getBerserkMode())
{
event.setCancelled(true);
}
}
public void onPlayerRespawn(PlayerRespawnEvent event)
@ -78,7 +87,7 @@ public class mcPlayerListener extends PlayerListener
* GARBAGE COLLECTION
*/
//Discard the PlayerProfile object from players array in the Users object stored for this player as it is no longer needed
//Discard the PlayerProfile object
Users.removeUser(event.getPlayer());
}

View File

@ -27,6 +27,15 @@ public class m
*/
//The lazy way to default to 0
public static String getCapitalized(String target)
{
String firstLetter = target.substring(0,1);
String remainder = target.substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
return capitalized;
}
public static int getInt(String string)
{
if(isInt(string))

View File

@ -90,6 +90,7 @@ public class mcMMO extends JavaPlugin
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Normal, this);
//Block Stuff
pm.registerEvent(Event.Type.BLOCK_DAMAGE, blockListener, Priority.Highest, this);
@ -1133,18 +1134,23 @@ public class mcMMO extends JavaPlugin
//Invite Command
if(LoadProperties.inviteEnable && mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase(LoadProperties.invite)){
if(!PP.inParty()){
if(!PP.inParty())
{
player.sendMessage(mcLocale.getString("mcPlayerListener.NotInParty"));
return true;
}
if(split.length < 2){
if(split.length < 2)
{
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.invite+" <playername>");
return true;
}
if(PP.inParty() && split.length >= 2 && isPlayer(split[1])){
if(PP.inParty() && split.length >= 2 && isPlayer(split[1]))
{
Player target = getPlayer(split[1]);
PlayerProfile PPt = Users.getProfile(target);
PPt.modifyInvite(PP.getParty());
player.sendMessage(mcLocale.getString("mcPlayerListener.InviteSuccess"));
//target.sendMessage(ChatColor.RED+"ALERT: "+ChatColor.GREEN+"You have received a party invite for "+PPt.getInvite()+" from "+player.getName());
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite1", new Object[] {PPt.getInvite(), player.getName()}));

View File

@ -63,16 +63,12 @@ public class Excavation
return false;
}
}
public static void excavationProcCheck(Block block, Player player)
public static void excavationProcCheck(int type, Location loc, Player player)
{
PlayerProfile PP = Users.getProfile(player);
int type = block.getTypeId();
Location loc = block.getLocation();
ItemStack is = null;
Material mat = null;
if(block.getData() == (byte) 5){
return;
}
if(type == 2)
{
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 250)

View File

@ -7,11 +7,13 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkitcontrib.sound.SoundEffect;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.contrib.contribStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
@ -58,9 +60,77 @@ public class Mining {
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
if(block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56
&& block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
loc.getWorld().dropItemNaturally(loc, item);
if(block.getTypeId() == 89){
if(block.getTypeId() == 89)
{
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 73 || block.getTypeId() == 74)
{
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
if(Math.random() * 10 > 5){
loc.getWorld().dropItemNaturally(loc, item);
}
}
if(block.getTypeId() == 21)
{
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 56)
{
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 1)
{
mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 16)
{
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
}
public static void blockProcSmeltSimulate(Block block)
{
Location loc = block.getLocation();
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 14 && block.getTypeId() != 15 && block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74
&& block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
loc.getWorld().dropItemNaturally(loc, item);
if(block.getTypeId() == 14)
{
mat = Material.getMaterial(266);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 15)
{
mat = Material.getMaterial(265);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 89)
{
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
@ -102,14 +172,28 @@ public class Mining {
public static void blockProcCheck(Block block, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null){
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING)){
blockProcSimulate(block);
return;
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING))
{
blockProcSimulate(block);
return;
}
}
}
public static void miningBlockCheck(Player player, Block block, mcMMO plugin)
public static void blockProcSmeltCheck(Block block, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING))
{
blockProcSmeltSimulate(block);
return;
}
}
}
public static void miningBlockCheck(Boolean smelt, Player player, Block block, mcMMO plugin)
{
PlayerProfile PP = Users.getProfile(player);
if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5)
@ -117,52 +201,90 @@ public class Mining {
int xp = 0;
if(block.getTypeId() == 1 || block.getTypeId() == 24){
xp += LoadProperties.mstone;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//OBSIDIAN
if(block.getTypeId() == 49){
if(block.getTypeId() == 49)
{
xp += LoadProperties.mobsidian;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//NETHERRACK
if(block.getTypeId() == 87){
if(block.getTypeId() == 87)
{
xp += LoadProperties.mnetherrack;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//GLOWSTONE
if(block.getTypeId() == 89){
if(block.getTypeId() == 89)
{
xp += LoadProperties.mglowstone;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//COAL
if(block.getTypeId() == 16){
if(block.getTypeId() == 16)
{
xp += LoadProperties.mcoal;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//GOLD
if(block.getTypeId() == 14){
if(block.getTypeId() == 14)
{
xp += LoadProperties.mgold;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//DIAMOND
if(block.getTypeId() == 56){
xp += LoadProperties.mdiamond;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//IRON
if(block.getTypeId() == 15){
if(block.getTypeId() == 15)
{
xp += LoadProperties.miron;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//REDSTONE
if(block.getTypeId() == 73 || block.getTypeId() == 74){
if(block.getTypeId() == 73 || block.getTypeId() == 74)
{
xp += LoadProperties.mredstone;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
//LAPUS
if(block.getTypeId() == 21){
if(block.getTypeId() == 21)
{
xp += LoadProperties.mlapus;
blockProcCheck(block, player);
if(smelt = false)
blockProcCheck(block, player);
else
blockProcSmeltCheck(block, player);
}
PP.addXP(SkillType.MINING, xp * LoadProperties.xpGainMultiplier);
Skills.XpCheckSkill(SkillType.MINING, player);
@ -351,6 +473,9 @@ public class Mining {
}
if(block.getData() != (byte) 5)
PP.addXP(SkillType.MINING, xp * LoadProperties.xpGainMultiplier);
contribStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
Skills.XpCheckSkill(SkillType.MINING, player);
}
}

View File

@ -6,12 +6,16 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkitcontrib.player.ContribCraftPlayer;
import org.bukkitcontrib.player.ContribPlayer;
import com.gmail.nossr50.Leaderboard;
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.contrib.contribStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
@ -55,22 +59,6 @@ public class Skills {
return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000);
}
public static boolean isAllCooldownsOver(PlayerProfile PP)
{
long t = System.currentTimeMillis();
if(t - PP.getGreenTerraDeactivatedTimeStamp() >= (LoadProperties.greenTerraCooldown * 1000) &&
t - PP.getTreeFellerDeactivatedTimeStamp() >= (LoadProperties.treeFellerCooldown * 1000) &&
t - PP.getSuperBreakerDeactivatedTimeStamp() >= (LoadProperties.superBreakerCooldown * 1000) &&
t - PP.getSerratedStrikesDeactivatedTimeStamp() >= (LoadProperties.serratedStrikeCooldown * 1000) &&
t - PP.getBerserkDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000) &&
t - PP.getSkullSplitterDeactivatedTimeStamp() >= (LoadProperties.skullSplitterCooldown * 1000) &&
t - PP.getGigaDrillBreakerDeactivatedTimeStamp() >= (LoadProperties.gigaDrillBreakerCooldown * 1000))
{
return true;
}
else
return false;
}
public static void watchCooldowns(Player player){
PlayerProfile PP = Users.getProfile(player);
if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - PP.getGreenTerraDeactivatedTimeStamp() >= (LoadProperties.greenTerraCooldown * 1000)){
@ -216,13 +204,17 @@ public class Skills {
}
}
}
public static void abilityActivationCheck(Player player){
public static void abilityActivationCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(PP != null){
if(PP != null)
{
if(!PP.getAbilityUse())
return;
if(mcPermissions.getInstance().miningAbility(player) && m.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode()){
if(!PP.getSuperBreakerMode() && !cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)){
if(mcPermissions.getInstance().miningAbility(player) && m.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode())
{
if(!PP.getSuperBreakerMode() && !cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)+"s)");
return;
@ -231,8 +223,10 @@ public class Skills {
PP.setPickaxePreparationATS(System.currentTimeMillis());
PP.setPickaxePreparationMode(true);
}
if(mcPermissions.getInstance().excavationAbility(player) && m.isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode()){
if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown)){
if(mcPermissions.getInstance().excavationAbility(player) && m.isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode())
{
if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown)+"s)");
return;
@ -241,8 +235,10 @@ public class Skills {
PP.setShovelPreparationATS(System.currentTimeMillis());
PP.setShovelPreparationMode(true);
}
if(mcPermissions.getInstance().swordsAbility(player) && m.isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode()){
if(!PP.getSerratedStrikesMode() && !cooldownOver(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown)){
if(mcPermissions.getInstance().swordsAbility(player) && m.isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode())
{
if(!PP.getSerratedStrikesMode() && !cooldownOver(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown)+"s)");
return;
@ -251,8 +247,10 @@ public class Skills {
PP.setSwordsPreparationATS(System.currentTimeMillis());
PP.setSwordsPreparationMode(true);
}
if(mcPermissions.getInstance().unarmedAbility(player) && player.getItemInHand().getTypeId() == 0 && !PP.getFistsPreparationMode()){
if(!PP.getBerserkMode() && !cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)){
if(mcPermissions.getInstance().unarmedAbility(player) && player.getItemInHand().getTypeId() == 0 && !PP.getFistsPreparationMode())
{
if(!PP.getBerserkMode() && !cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)+"s)");
return;
@ -261,8 +259,10 @@ public class Skills {
PP.setFistsPreparationATS(System.currentTimeMillis());
PP.setFistsPreparationMode(true);
}
if((mcPermissions.getInstance().axes(player) || mcPermissions.getInstance().woodcutting(player)) && !PP.getAxePreparationMode()){
if(m.isAxes(player.getItemInHand())){
if((mcPermissions.getInstance().axes(player) || mcPermissions.getInstance().woodcutting(player)) && !PP.getAxePreparationMode())
{
if(m.isAxes(player.getItemInHand()))
{
player.sendMessage(mcLocale.getString("Skills.ReadyAxe"));
PP.setAxePreparationATS(System.currentTimeMillis());
PP.setAxePreparationMode(true);
@ -276,7 +276,10 @@ public class Skills {
PlayerProfile PP = Users.getProfile(player);
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getSkillLevel(skillType);
if(skillType != SkillType.ALL)
ps.statVal = PP.getSkillLevel(skillType);
else
ps.statVal = m.getPowerLevel(player);
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, skillType);
}
@ -297,13 +300,22 @@ public class Skills {
}
if(!LoadProperties.useMySQL)
{
ProcessLeaderboardUpdate(skillType, player);
ProcessLeaderboardUpdate(SkillType.ALL, player);
}
String firstLetter = skillType.toString().substring(0,1);
String remainder = skillType.toString().substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
String capitalized = m.getCapitalized(skillType.toString());
//Contrib stuff
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
ContribPlayer cPlayer = ContribCraftPlayer.getContribPlayer(player);
if(cPlayer.isBukkitContribEnabled())
{
contribStuff.levelUpNotification(skillType, cPlayer);
} else {
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
}
}
@ -328,49 +340,13 @@ public class Skills {
return null;
}
public static boolean isSkill(String skillname){
skillname = skillname.toLowerCase();
if(skillname.equals("all")){
return true;
skillname = skillname.toUpperCase();
for(SkillType x : SkillType.values())
{
if(x.toString().equals(skillname))
return true;
}
else if(skillname.equals("sorcery")){
return true;
}
else if(skillname.equals("taming")){
return true;
}
else if(skillname.equals("mining")){
return true;
}
else if(skillname.equals("woodcutting")){
return true;
}
else if(skillname.equals("excavation")){
return true;
}
else if(skillname.equals("repair")){
return true;
}
else if(skillname.equals("herbalism")){
return true;
}
else if(skillname.equals("acrobatics")){
return true;
}
else if(skillname.equals("swords")){
return true;
}
else if(skillname.equals("archery")){
return true;
}
else if(skillname.equals("unarmed")){
return true;
}
else if(skillname.equals("axes")){
return true;
}
else {
return false;
}
return false;
}
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin)
{