From 89cda9adf590d6e6d57aef91e410d3b590099cb1 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 1 Mar 2011 16:14:17 -0800 Subject: [PATCH] WIP of 0.8.11 v4 --- mcMMO/Changelog.txt | 26 + mcMMO/com/gmail/nossr50/mcAcrobatics.java | 82 + mcMMO/com/gmail/nossr50/mcBlockListener.java | 20 +- mcMMO/com/gmail/nossr50/mcCombat.java | 935 +++++++++ mcMMO/com/gmail/nossr50/mcConfig.java | 22 +- mcMMO/com/gmail/nossr50/mcEntityListener.java | 53 +- mcMMO/com/gmail/nossr50/mcExcavation.java | 157 ++ mcMMO/com/gmail/nossr50/mcHerbalism.java | 113 + mcMMO/com/gmail/nossr50/mcLoadProperties.java | 3 +- mcMMO/com/gmail/nossr50/mcMMO.java | 11 +- mcMMO/com/gmail/nossr50/mcMining.java | 140 ++ mcMMO/com/gmail/nossr50/mcParty.java | 58 + mcMMO/com/gmail/nossr50/mcPermissions.java | 7 + mcMMO/com/gmail/nossr50/mcPlayerListener.java | 125 +- mcMMO/com/gmail/nossr50/mcRepair.java | 375 ++++ mcMMO/com/gmail/nossr50/mcSkills.java | 79 + mcMMO/com/gmail/nossr50/mcTimer.java | 18 +- mcMMO/com/gmail/nossr50/mcUsers.java | 9 +- mcMMO/com/gmail/nossr50/mcWoodCutting.java | 59 + mcMMO/com/gmail/nossr50/mcm.java | 1822 +---------------- mcMMO/plugin.yml | 2 +- 21 files changed, 2195 insertions(+), 1921 deletions(-) create mode 100644 mcMMO/com/gmail/nossr50/mcAcrobatics.java create mode 100644 mcMMO/com/gmail/nossr50/mcCombat.java create mode 100644 mcMMO/com/gmail/nossr50/mcExcavation.java create mode 100644 mcMMO/com/gmail/nossr50/mcHerbalism.java create mode 100644 mcMMO/com/gmail/nossr50/mcMining.java create mode 100644 mcMMO/com/gmail/nossr50/mcParty.java create mode 100644 mcMMO/com/gmail/nossr50/mcRepair.java create mode 100644 mcMMO/com/gmail/nossr50/mcSkills.java create mode 100644 mcMMO/com/gmail/nossr50/mcWoodCutting.java diff --git a/mcMMO/Changelog.txt b/mcMMO/Changelog.txt index 49574ba49..ec5c4b0a5 100644 --- a/mcMMO/Changelog.txt +++ b/mcMMO/Changelog.txt @@ -1,5 +1,31 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code# +Version 0.8.11 + Performance improvements + Memory leak fixed + NPE error with MySpawn really fixed +Version 0.8.9 + Fixed NPE for My Spawn + Fixed NPE for onBlockDamage + Bleed proc now correctly checks for Swords permissions +Version 0.8.8 + Gold can now be repaired + Tweaked Mining XP gains + Reorganized code + Added /mcgod godmode command + Fixed the pvp toggle in the settings file +Version 0.8.7 + Removed packet-sending stuff wasn't working anyways + Fixed another NPE with the TimerTask + Skills now only show up in /stats if you have permissions for them +Version 0.8.6 + Added a null check in bleed simulation to prevent a NPE +Version 0.8.5 + Players are now added to files when they connect (to fix a NPE) + onPlayerCommand stuff moved into onPlayerCommandPreprocess +Version 0.8.4 + Fixed another nullpointer error for TimerTask + Fixed bug making regeneration take twice as long to kick in after combat Version 0.8.3 Modified the timer intervals (from 1 second to 2) All skills now have an individual modifier (Set by default to 2) diff --git a/mcMMO/com/gmail/nossr50/mcAcrobatics.java b/mcMMO/com/gmail/nossr50/mcAcrobatics.java new file mode 100644 index 000000000..0814ae25b --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcAcrobatics.java @@ -0,0 +1,82 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; + +public class mcAcrobatics { + private static volatile mcAcrobatics instance; + public static mcAcrobatics getInstance() { + if (instance == null) { + instance = new mcAcrobatics(); + } + return instance; + } + public void acrobaticsCheck(Player player, EntityDamageEvent event, Location loc, int xx, int y, int z){ + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 50 + && mcUsers.getProfile(player).getAcrobaticsInt() < 250 + && mcPermissions.getInstance().acrobatics(player)){ + if(Math.random() * 10 > 8){ + event.setCancelled(true); + player.sendMessage("**ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 250 + && mcUsers.getProfile(player).getAcrobaticsInt() < 450 + && mcPermissions.getInstance().acrobatics(player)){ + if(Math.random() * 10 > 6){ + event.setCancelled(true); + player.sendMessage("**ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 450 + && mcUsers.getProfile(player).getAcrobaticsInt() < 750 + && mcPermissions.getInstance().acrobatics(player)){ + if(Math.random() * 10 > 4){ + event.setCancelled(true); + player.sendMessage("**ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 750 + && mcUsers.getProfile(player).getAcrobaticsInt() < 950 + && mcPermissions.getInstance().acrobatics(player)){ + if(Math.random() * 10 > 2){ + event.setCancelled(true); + player.sendMessage("**BARREL ROLLED**"); + return; + } + } + if(mcUsers.getProfile(player).getAcrobaticsInt() >= 950 + && mcPermissions.getInstance().acrobatics(player)){ + event.setCancelled(true); + player.sendMessage("**ROLLED... LIKE A BOSS**"); + return; + } + if(player.getHealth() - event.getDamage() <= 0) + return; + if(!mcConfig.getInstance().isBlockWatched(loc.getWorld().getBlockAt(xx, y, z)) + && mcPermissions.getInstance().acrobatics(player)){ + mcUsers.getProfile(player).addAcrobaticsGather(event.getDamage() * 3); + if(mcUsers.getProfile(player).getAcrobaticsGatherInt() >= mcUsers.getProfile(player).getXpToLevel("acrobatics")){ + int skillups = 0; + while(mcUsers.getProfile(player).getAcrobaticsGatherInt() >= mcUsers.getProfile(player).getXpToLevel("acrobatics")){ + skillups++; + mcUsers.getProfile(player).removeAcrobaticsGather(mcUsers.getProfile(player).getXpToLevel("acrobatics")); + mcUsers.getProfile(player).skillUpAcrobatics(1); + } + player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getAcrobatics()+")"); + } + mcConfig.getInstance().addBlockWatch(loc.getWorld().getBlockAt(xx, y, z)); + if(player.getHealth() - event.getDamage() <= 0){ + if(mcUsers.getProfile(player).isDead()) + return; + mcUsers.getProfile(player).setDead(true); + } + } + } + +} diff --git a/mcMMO/com/gmail/nossr50/mcBlockListener.java b/mcMMO/com/gmail/nossr50/mcBlockListener.java index 8ade17af5..986e8485d 100644 --- a/mcMMO/com/gmail/nossr50/mcBlockListener.java +++ b/mcMMO/com/gmail/nossr50/mcBlockListener.java @@ -2,7 +2,6 @@ package com.gmail.nossr50; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -10,7 +9,6 @@ import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.inventory.ItemStack; public class mcBlockListener extends BlockListener { private final mcMMO plugin; @@ -30,8 +28,8 @@ public class mcBlockListener extends BlockListener { int y = block.getY(); int z = block.getZ(); String xyz = x+","+y+","+z; + if(mcm.getInstance().shouldBeWatched(block)) mcConfig.getInstance().addBlockWatch(block); - mcConfig.getInstance().addCoordsWatch(xyz); if(block.getTypeId() == 42 && mcLoadProperties.anvilmessages) event.getPlayer().sendMessage(ChatColor.DARK_RED+"You have placed an anvil, anvils can repair tools and armor."); } @@ -45,7 +43,6 @@ public class mcBlockListener extends BlockListener { int y = block.getY(); int z = block.getZ(); String xyz = x+","+y+","+z; - int type = block.getTypeId(); Location loc = block.getLocation(); int dmg = event.getDamageLevel().getLevel(); /* @@ -53,32 +50,31 @@ public class mcBlockListener extends BlockListener { */ if(dmg == 3){ if(mcPermissions.getInstance().herbalism(player)) - mcm.getInstance().herbalismProcCheck(block, player); + mcHerbalism.getInstance().herbalismProcCheck(block, player); } /* * MINING */ - if(dmg == 2 && !mcConfig.getInstance().isBlockWatched(block) && !mcConfig.getInstance().isCoordsWatched(xyz)){ + if(player != null && dmg == 2 && !mcConfig.getInstance().isBlockWatched(block)){ if(mcPermissions.getInstance().mining(player)) - mcm.getInstance().miningBlockCheck(player, block); + mcMining.getInstance().miningBlockCheck(player, block); /* * WOOD CUTTING */ - if(block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player)){ - mcm.getInstance().woodCuttingProcCheck(player, block, loc); + if(player != null && block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player)){ + mcWoodCutting.getInstance().woodCuttingProcCheck(player, block, loc); mcUsers.getProfile(player).addWoodcuttingGather(7); } /* * EXCAVATION */ if(mcPermissions.getInstance().excavation(player) && block != null && player != null) - mcm.getInstance().excavationProcCheck(block, player); + mcExcavation.getInstance().excavationProcCheck(block, player); /* * EXPLOIT COUNTERMEASURES */ - mcConfig.getInstance().addCoordsWatch(xyz); mcConfig.getInstance().addBlockWatch(block); - if(mcUsers.getProfile(player).getWoodCuttingGatherInt() >= mcUsers.getProfile(player).getXpToLevel("woodcutting")){ + if(player != null && mcUsers.getProfile(player).getWoodCuttingGatherInt() >= mcUsers.getProfile(player).getXpToLevel("woodcutting")){ int skillups = 0; while(mcUsers.getProfile(player).getWoodCuttingGatherInt() >= mcUsers.getProfile(player).getXpToLevel("woodcutting")){ skillups++; diff --git a/mcMMO/com/gmail/nossr50/mcCombat.java b/mcMMO/com/gmail/nossr50/mcCombat.java new file mode 100644 index 000000000..13cd2227f --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcCombat.java @@ -0,0 +1,935 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Animals; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Spider; +import org.bukkit.entity.Squid; +import org.bukkit.entity.Zombie; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageByProjectileEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +public class mcCombat { + private static mcMMO plugin; + public mcCombat(mcMMO instance) { + plugin = instance; + } + private static volatile mcCombat instance; + public static mcCombat getInstance() { + if (instance == null) { + instance = new mcCombat(plugin); + } + return instance; + } + public void playerVersusPlayerChecks(Entity x, Player attacker, EntityDamageByEntityEvent event){ + if(x instanceof Player){ + if(mcLoadProperties.pvp == false){ + event.setCancelled(true); + return; + } + Player defender = (Player)x; + if(mcUsers.getProfile(attacker).inParty() && mcUsers.getProfile(defender).inParty()){ + if(mcParty.getInstance().inSameParty(defender, attacker)){ + event.setCancelled(true); + return; + } + } + mcUsers.getProfile(defender).setRecentlyHurt(30); + /* + * AXE CRITICAL CHECK + */ + axeCriticalCheckPlayer(attacker, event, x, plugin); + if(!mcConfig.getInstance().isBleedTracked(x)){ + bleedCheck(attacker, x); + } + int healthbefore = defender.getHealth(); + if(mcPermissions.getInstance().unarmed(attacker) && attacker.getItemInHand().getTypeId() == 0){ + //DMG MODIFIER + if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ + defender.setHealth(calculateDamage(defender, 1)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ + defender.setHealth(calculateDamage(defender, 2)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ + defender.setHealth(calculateDamage(defender, 3)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ + defender.setHealth(calculateDamage(defender, 4)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ + defender.setHealth(calculateDamage(defender, 5)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ + defender.setHealth(calculateDamage(defender, 6)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ + defender.setHealth(calculateDamage(defender, 7)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ + defender.setHealth(calculateDamage(defender, 8)); + } + if(mcUsers.getProfile(defender).isDead()) + return; + //PROC + if(simulateUnarmedProc(attacker)){ + Location loc = defender.getLocation(); + if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0){ + attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force."); + defender.sendMessage(ChatColor.DARK_RED+"You have been disarmed!"); + ItemStack item = defender.getItemInHand(); + if(item != null){ + loc.getWorld().dropItemNaturally(loc, item); + ItemStack itemx = null; + defender.setItemInHand(itemx); + } + } + } + } + /* + * Make the defender drop items on death + */ + if(defender.getHealth()<= 0 && !mcUsers.getProfile(defender).isDead()){ + mcUsers.getProfile(defender).setDead(true); + event.setCancelled(true); //SEE IF THIS HELPS + //If it only would've died from mcMMO damage modifiers + if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ + mcm.getInstance().simulateNaturalDrops(defender); + } + for(ItemStack herp : defender.getInventory().getContents()){ + if(herp != null && herp.getTypeId() != 0) + defender.getLocation().getWorld().dropItemNaturally(defender.getLocation(), herp); + } + } + if(mcUsers.getProfile(defender).isDead()) + return; + if((mcUsers.getProfile(defender).inParty() && mcUsers.getProfile(attacker).inParty())&& mcUsers.getProfile(defender).getParty().equals(mcUsers.getProfile(attacker).getParty())) + event.setCancelled(true); + } + } + public void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ + if(x instanceof Squid){ + if(!mcConfig.getInstance().isBleedTracked(x)){ + bleedCheck(attacker, x); + } + Squid defender = (Squid)event.getEntity(); + if(mcm.getInstance().isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ + mcUsers.getProfile(attacker).addSwordsGather(10); + if(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ + skillups++; + mcUsers.getProfile(attacker).removeSwordsGather(mcUsers.getProfile(attacker).getXpToLevel("swords")); + mcUsers.getProfile(attacker).skillUpSwords(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getSwords()+")"); + } + } + if(mcm.getInstance().isAxes(attacker.getItemInHand()) + && defender.getHealth() > 0 + && mcPermissions.getInstance().axes(attacker)){ + mcUsers.getProfile(attacker).addAxesGather(10); + if(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ + skillups++; + mcUsers.getProfile(attacker).removeAxesGather(mcUsers.getProfile(attacker).getXpToLevel("axes")); + mcUsers.getProfile(attacker).skillUpAxes(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getAxes()+")"); + } + } + if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(defender.getHealth() <= 0) + return; + if(mcUsers.getProfile(attacker).getAxesInt() >= 500){ + defender.setHealth(calculateDamage(defender, (4 - axeNerf(attacker.getItemInHand().getTypeId())))); + } + if(defender.getHealth() <= 0) + mcm.getInstance().simulateNaturalDrops(defender); + } + /* + * UNARMED VS SQUID + */ + if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ + if(defender.getHealth() <= 0) + return; + if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ + defender.setHealth(calculateDamage(defender, 1)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ + defender.setHealth(calculateDamage(defender, 2)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ + defender.setHealth(calculateDamage(defender, 3)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ + defender.setHealth(calculateDamage(defender, 4)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ + defender.setHealth(calculateDamage(defender, 5)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ + defender.setHealth(calculateDamage(defender, 6)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ + defender.setHealth(calculateDamage(defender, 7)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ + defender.setHealth(calculateDamage(defender, 8)); + } + //XP + if(defender.getHealth() != 0){ + mcUsers.getProfile(attacker).addUnarmedGather(10); + if(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ + skillups++; + mcUsers.getProfile(attacker).removeUnarmedGather(mcUsers.getProfile(attacker).getXpToLevel("unarmed")); + mcUsers.getProfile(attacker).skillUpUnarmed(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getUnarmed()+")"); + } + } + if(defender.getHealth() <= 0) + mcm.getInstance().simulateNaturalDrops(defender); + } + } + } + public void playerVersusAnimalsChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, int type){ + if(x instanceof Animals){ + if(!mcConfig.getInstance().isBleedTracked(x)){ + bleedCheck(attacker, x); + } + Animals defender = (Animals)event.getEntity(); + if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(defender.getHealth() <= 0) + return; + if(mcUsers.getProfile(attacker).getAxesInt() >= 500){ + defender.setHealth(calculateDamage(defender, (4 - axeNerf(attacker.getItemInHand().getTypeId())))); + } + if(defender.getHealth() <= 0) + mcm.getInstance().simulateNaturalDrops(defender); + } + if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ + if(defender.getHealth() <= 0) + return; + if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ + defender.setHealth(calculateDamage(defender, 1)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ + defender.setHealth(calculateDamage(defender, 2)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ + defender.setHealth(calculateDamage(defender, 3)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ + defender.setHealth(calculateDamage(defender, 4)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ + defender.setHealth(calculateDamage(defender, 5)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ + defender.setHealth(calculateDamage(defender, 6)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ + defender.setHealth(calculateDamage(defender, 7)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ + defender.setHealth(calculateDamage(defender, 8)); + } + if(defender.getHealth() <= 0){ + mcm.getInstance().simulateNaturalDrops(defender); + } + } + } + } + public void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ + if(x instanceof Monster){ + /* + * AXE PROC CHECKS + */ + axeCriticalCheckMonster(attacker, event, x); + if(!mcConfig.getInstance().isBleedTracked(x)){ + bleedCheck(attacker, x); + } + Monster defender = (Monster)event.getEntity(); + if(mcm.getInstance().isSwords(attacker.getItemInHand()) + && defender.getHealth() > 0 + && mcPermissions.getInstance().swords(attacker)){ + if(!mcConfig.getInstance().isMobSpawnTracked(x)){ + if(x instanceof Creeper) + mcUsers.getProfile(attacker).addSwordsGather(10); + if(x instanceof Spider) + mcUsers.getProfile(attacker).addSwordsGather(7); + if(x instanceof Skeleton) + mcUsers.getProfile(attacker).addSwordsGather(5); + if(x instanceof Zombie) + mcUsers.getProfile(attacker).addSwordsGather(3); + if(x instanceof PigZombie) + mcUsers.getProfile(attacker).addSwordsGather(7); + } + if(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ + skillups++; + mcUsers.getProfile(attacker).removeSwordsGather(mcUsers.getProfile(attacker).getXpToLevel("swords")); + mcUsers.getProfile(attacker).skillUpSwords(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getSwords()+")"); + } + } + if(mcm.getInstance().isAxes(attacker.getItemInHand()) + && defender.getHealth() > 0 + && mcPermissions.getInstance().axes(attacker)){ + if(!mcConfig.getInstance().isMobSpawnTracked(x)){ + mcUsers.getProfile(attacker).addAxesGather(1); + if(x instanceof Creeper) + mcUsers.getProfile(attacker).addAxesGather(10); + if(x instanceof Spider) + mcUsers.getProfile(attacker).addAxesGather(7); + if(x instanceof Skeleton) + mcUsers.getProfile(attacker).addAxesGather(5); + if(x instanceof Zombie) + mcUsers.getProfile(attacker).addAxesGather(3); + if(x instanceof PigZombie) + mcUsers.getProfile(attacker).addAxesGather(7); + } + if(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ + skillups++; + mcUsers.getProfile(attacker).removeAxesGather(mcUsers.getProfile(attacker).getXpToLevel("axes")); + mcUsers.getProfile(attacker).skillUpAxes(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getAxes()+")"); + } + } + /* + * AXE DAMAGE SCALING && LOOT CHECKS + */ + if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(defender.getHealth() <= 0) + return; + if(mcUsers.getProfile(attacker).getAxesInt() >= 500){ + defender.setHealth(calculateDamage(defender, (4 - axeNerf(attacker.getItemInHand().getTypeId())))); + } + if(defender.getHealth() <= 0 || defender.getHealth() - event.getDamage() <= 0){ + mcm.getInstance().simulateNaturalDrops(defender); + } + } + if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ + if(defender.getHealth() <= 0) + return; + if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ + defender.setHealth(calculateDamage(defender, 1)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ + defender.setHealth(calculateDamage(defender, 2)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ + defender.setHealth(calculateDamage(defender, 3)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ + defender.setHealth(calculateDamage(defender, 4)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ + defender.setHealth(calculateDamage(defender, 5)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ + defender.setHealth(calculateDamage(defender, 6)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ + defender.setHealth(calculateDamage(defender, 7)); + } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ + defender.setHealth(calculateDamage(defender, 8)); + } + //XP + if(!mcConfig.getInstance().isMobSpawnTracked(x)){ + if(x instanceof Creeper) + mcUsers.getProfile(attacker).addUnarmedGather(20); + if(x instanceof Spider) + mcUsers.getProfile(attacker).addUnarmedGather(15); + if(x instanceof Skeleton) + mcUsers.getProfile(attacker).addUnarmedGather(10); + if(x instanceof Zombie) + mcUsers.getProfile(attacker).addUnarmedGather(5); + if(x instanceof PigZombie) + mcUsers.getProfile(attacker).addUnarmedGather(15); + } + if(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ + skillups++; + mcUsers.getProfile(attacker).removeUnarmedGather(mcUsers.getProfile(attacker).getXpToLevel("unarmed")); + mcUsers.getProfile(attacker).skillUpUnarmed(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getUnarmed()+")"); + } + if(defender.getHealth() <= 0 || defender.getHealth() - event.getDamage() <= 0){ + mcm.getInstance().simulateNaturalDrops(defender); + } + } + } + } + public void archeryCheck(EntityDamageByProjectileEvent event){ + Entity y = event.getDamager(); + Entity x = event.getEntity(); + /* + * Defender is player + */ + if(y instanceof Player){ + Player attacker = (Player)y; + if(event.getProjectile().toString().equals("CraftArrow") && mcPermissions.getInstance().archery(attacker)){ + if(!mcConfig.getInstance().isTracked(x) && event.getDamage() > 0){ + mcConfig.getInstance().addArrowTrack(x, 0); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 200){ + if(Math.random() * 10 > 8){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 200 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ + if(Math.random() * 10 > 6){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 400 && mcUsers.getProfile(attacker).getArcheryInt() < 600){ + if(Math.random() * 10 > 4){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 600 && mcUsers.getProfile(attacker).getArcheryInt() < 800){ + if(Math.random() * 10 > 2){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 800){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else { + if(event.getDamage() > 0){ + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 200){ + if(Math.random() * 10 > 8){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 200 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ + if(Math.random() * 10 > 6){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 400 && mcUsers.getProfile(attacker).getArcheryInt() < 600){ + if(Math.random() * 10 > 4){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 600 && mcUsers.getProfile(attacker).getArcheryInt() < 800){ + if(Math.random() * 10 > 2){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 800){ + mcConfig.getInstance().addArrowCount(x, 1); + } + } + } + /* + * Defender is Monster + */ + if(x instanceof Monster){ + Monster defender = (Monster)x; + /* + * TRACK ARROWS USED AGAINST THE ENTITY + */ + int healthbefore = defender.getHealth(); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) + defender.setHealth(calculateDamage(defender, 1)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) + defender.setHealth(calculateDamage(defender, 2)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) + defender.setHealth(calculateDamage(defender, 3)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(calculateDamage(defender, 4)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) + defender.setHealth(calculateDamage(defender, 5)); + //If it only would've died from mcMMO damage modifiers + if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ + mcm.getInstance().simulateNaturalDrops(defender); + } + //XP + if(!mcConfig.getInstance().isMobSpawnTracked(x)){ + if(x instanceof Creeper) + mcUsers.getProfile(attacker).addArcheryGather(10); + if(x instanceof Spider) + mcUsers.getProfile(attacker).addArcheryGather(7); + if(x instanceof Skeleton) + mcUsers.getProfile(attacker).addArcheryGather(5); + if(x instanceof Zombie) + mcUsers.getProfile(attacker).addArcheryGather(3); + if(x instanceof PigZombie) + mcUsers.getProfile(attacker).addArcheryGather(7); + } + if(mcUsers.getProfile(attacker).getArcheryGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("archery")){ + int skillups = 0; + while(mcUsers.getProfile(attacker).getArcheryGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("archery")){ + skillups++; + mcUsers.getProfile(attacker).removeArcheryGather(mcUsers.getProfile(attacker).getXpToLevel("archery")); + mcUsers.getProfile(attacker).skillUpArchery(1); + } + attacker.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getArchery()+")"); + } + } + /* + * Defender is Animals + */ + if(x instanceof Animals){ + Animals defender = (Animals)x; + int healthbefore = defender.getHealth(); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) + defender.setHealth(calculateDamage(defender, 1)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) + defender.setHealth(calculateDamage(defender, 2)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) + defender.setHealth(calculateDamage(defender, 3)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(calculateDamage(defender, 4)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) + defender.setHealth(calculateDamage(defender, 5)); + //If it only would've died from mcMMO damage modifiers + if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ + mcm.getInstance().simulateNaturalDrops(defender); + } + } + /* + * Defender is Squid + */ + if(x instanceof Squid){ + Squid defender = (Squid)x; + int healthbefore = defender.getHealth(); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) + defender.setHealth(calculateDamage(defender, 1)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) + defender.setHealth(calculateDamage(defender, 2)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) + defender.setHealth(calculateDamage(defender, 3)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(calculateDamage(defender, 4)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) + defender.setHealth(calculateDamage(defender, 5)); + //If it only would've died from mcMMO damage modifiers + if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ + mcm.getInstance().simulateNaturalDrops(defender); + } + } + /* + * Attacker is Player + */ + if(x instanceof Player){ + if(mcLoadProperties.pvp == false){ + event.setCancelled(true); + return; + } + Player defender = (Player)x; + /* + * Stuff for the daze proc + */ + if(mcUsers.getProfile(attacker).inParty() && mcUsers.getProfile(defender).inParty()){ + if(mcParty.getInstance().inSameParty(defender, attacker)){ + event.setCancelled(true); + return; + } + } + Location loc = defender.getLocation(); + if(Math.random() * 10 > 5){ + loc.setPitch(90); + } else { + loc.setPitch(-90); + } + /* + * Check the proc + */ + if(mcUsers.getProfile(attacker).getArcheryInt() >= 300 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ + if(Math.random() * 10 > 7){ + defender.teleportTo(loc); + defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); + attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); + } + } + if(mcUsers.getProfile(attacker).getArcheryInt() >= 600){ + if(Math.random() * 10 > 4){ + defender.teleportTo(loc); + defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); + attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); + } + } + int healthbefore = defender.getHealth(); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) + defender.setHealth(calculateDamage(defender, 1)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) + defender.setHealth(calculateDamage(defender, 2)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) + defender.setHealth(calculateDamage(defender, 3)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) + defender.setHealth(calculateDamage(defender, 4)); + if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) + defender.setHealth(calculateDamage(defender, 5)); + //If it only would've died from mcMMO damage modifiers + if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ + mcm.getInstance().simulateNaturalDrops(defender); + } + } + } + } + } + public boolean simulateUnarmedProc(Player player){ + if(mcUsers.getProfile(player).getUnarmedInt() >= 750){ + if(Math.random() * 10 > 4){ + return true; + } + }if(mcUsers.getProfile(player).getUnarmedInt() >= 350 && mcUsers.getProfile(player).getUnarmedInt() < 750){ + if(Math.random() * 10 > 4){ + return true; + } + } + return false; + } + public void bleedCheck(Player attacker, Entity x){ + if(mcPermissions.getInstance().swords(attacker) && mcm.getInstance().isSwords(attacker.getItemInHand()) && !mcConfig.getInstance().isBleedTracked(x)){ + if(mcUsers.getProfile(attacker).getSwordsInt() >= 50 && mcUsers.getProfile(attacker).getSwordsInt() < 200){ + if(Math.random() * 10 > 8){ + mcConfig.getInstance().addBleedTrack(x); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(4); + } + attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); + } + } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 200 && mcUsers.getProfile(attacker).getSwordsInt() < 600){ + if(Math.random() * 10 > 6){ + mcConfig.getInstance().addBleedTrack(x); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(4); + } + attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); + } + } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 600 && mcUsers.getProfile(attacker).getSwordsInt() < 900){ + if(Math.random() * 10 > 4){ + mcConfig.getInstance().addBleedTrack(x); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(6); + } + attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); + } + } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 900){ + if(Math.random() * 100 > 25){ + mcConfig.getInstance().addBleedTrack(x); + if(x instanceof Player){ + Player target = (Player)x; + mcUsers.getProfile(target).setBleedTicks(6); + } + attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); + } + } + } + } + public int axeNerf(int type){ + //GOLD OR WOOD + if(type == 271 || type == 286){ + return 3; + } else if (type == 258){ + return 1; + } else if (type == 275){ + return 1; + } else { + return 0; + } + } + public int calculateDamage(Player player, int dmg){ + int health = player.getHealth(); + if(health - dmg <0){ + return 0; + } else { + health-= dmg; + return health; + } + } + public int calculateDamage(Squid squid, int dmg){ + int health = squid.getHealth(); + if(health - dmg <0){ + return 0; + } else { + health-= dmg; + return health; + } + } + public int calculateDamage(Monster monster, int dmg){ + int health = monster.getHealth(); + if(health - dmg <0){ + return 0; + } else { + health-= dmg; + return health; + } + } + public int calculateDamage(Animals animal, int dmg){ + int health = animal.getHealth(); + if(health - dmg <0){ + return 0; + } else { + health-= dmg; + return health; + } + } + public void axeCriticalCheckAnimals(Player attacker, EntityDamageByEntityEvent event, Entity x){ + if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcUsers.getProfile(attacker).getAxesInt() >= 50 && mcUsers.getProfile(attacker).getAxesInt() < 250){ + if(Math.random() * 100 > 95){ + if(x instanceof Animals){ + Animals animal = (Animals)x; + animal.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 250 && mcUsers.getProfile(attacker).getAxesInt() < 500){ + if(Math.random() * 10 > 9){ + if(x instanceof Animals){ + Animals animal = (Animals)x; + animal.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 500 && mcUsers.getProfile(attacker).getAxesInt() < 750){ + if(Math.random() * 10 > 8){ + if(x instanceof Animals){ + Animals animal = (Animals)x; + animal.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 750 && mcUsers.getProfile(attacker).getAxesInt() < 1000){ + if(Math.random() * 10 > 7){ + if(x instanceof Animals){ + Animals animal = (Animals)x; + animal.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 1000){ + if(Math.random() * 10 > 6){ + if(x instanceof Animals){ + Animals animal = (Animals)x; + animal.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + } + } + public void axeCriticalCheckMonster(Player attacker, EntityDamageByEntityEvent event, Entity x){ + if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcUsers.getProfile(attacker).getAxesInt() >= 50 && mcUsers.getProfile(attacker).getAxesInt() < 250){ + if(Math.random() * 100 > 95){ + if(x instanceof Monster){ + Monster monster = (Monster)x; + monster.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 250 && mcUsers.getProfile(attacker).getAxesInt() < 500){ + if(Math.random() * 10 > 9){ + if(x instanceof Monster){ + Monster monster = (Monster)x; + monster.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 500 && mcUsers.getProfile(attacker).getAxesInt() < 750){ + if(Math.random() * 10 > 8){ + if(x instanceof Monster){ + Monster monster = (Monster)x; + monster.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 750 && mcUsers.getProfile(attacker).getAxesInt() < 1000){ + if(Math.random() * 10 > 7){ + if(x instanceof Monster){ + Monster monster = (Monster)x; + monster.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 1000){ + if(Math.random() * 10 > 6){ + if(x instanceof Monster){ + Monster monster = (Monster)x; + monster.setHealth(0); + mcm.getInstance().simulateNaturalDrops(x); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + } + } + } + } + } + public void axeCriticalCheckPlayer(Player attacker, EntityDamageByEntityEvent event, Entity x, Plugin plugin){ + if(mcm.getInstance().isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ + if(mcUsers.getProfile(attacker).getAxesInt() >= 50 && mcUsers.getProfile(attacker).getAxesInt() < 250){ + if(Math.random() * 100 > 95){ + if(x instanceof Player){ + Player player = (Player)x; + player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 250 && mcUsers.getProfile(attacker).getAxesInt() < 500){ + if(Math.random() * 10 > 9){ + if(x instanceof Player){ + Player player = (Player)x; + player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 500 && mcUsers.getProfile(attacker).getAxesInt() < 750){ + if(Math.random() * 10 > 8){ + if(x instanceof Player){ + Player player = (Player)x; + player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 750 && mcUsers.getProfile(attacker).getAxesInt() < 1000){ + if(Math.random() * 10 > 7){ + if(x instanceof Player){ + Player player = (Player)x; + player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + } + } + if(mcUsers.getProfile(attacker).getAxesInt() >= 1000){ + if(Math.random() * 10 > 6){ + if(x instanceof Player){ + Player player = (Player)x; + player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); + attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); + player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); + } + } + } + if(x instanceof Player){ + Player defender = (Player)x; + if(defender.getHealth()<= 0 && !mcUsers.getProfile(defender).isDead()){ + mcUsers.getProfile(defender).setDead(true); + event.setCancelled(true); //SEE IF THIS HELPS + for(ItemStack herp : defender.getInventory().getContents()){ + if(herp != null && herp.getTypeId() != 0) + defender.getLocation().getWorld().dropItemNaturally(defender.getLocation(), herp); + } + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"chopped "+ChatColor.GRAY+defender.getName() + " to death."); + mcUsers.getProfile(defender).setDead(true); + } + } + } + } + } + public void parryCheck(Player defender, EntityDamageByEntityEvent event, Entity y){ + if(mcm.getInstance().isSwords(defender.getItemInHand()) + && event.getDamage() > 0 + && mcPermissions.getInstance().swords(defender)){ + if(mcUsers.getProfile(defender).getSwordsInt() >= 50 && mcUsers.getProfile(defender).getSwordsInt() < 250){ + if(Math.random() * 100 > 95){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + return; + } + } + if(mcUsers.getProfile(defender).getSwordsInt() >= 250 && mcUsers.getProfile(defender).getSwordsInt() < 450){ + if(Math.random() * 100 > 90){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + return; + } + } + if(mcUsers.getProfile(defender).getSwordsInt() >= 450 && mcUsers.getProfile(defender).getSwordsInt() < 775){ + if(Math.random() * 100 > 85){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + return; + } + } + if(mcUsers.getProfile(defender).getSwordsInt() >= 775){ + if(Math.random() * 100 > 80){ + event.setCancelled(true); + defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); + defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); + if(y instanceof Player){ + Player attacker = (Player)y; + attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); + } + return; + } + } + } + } + public void bleedSimulate(){ + for(Entity x : mcConfig.getInstance().getBleedTracked()){ + if(x == null) + continue; + if(mcm.getInstance().getHealth(x) <= 0) + continue; + if(x instanceof Animals){ + Animals animals = (Animals)x; + if(animals.getHealth() >= 1){ + animals.setHealth(mcm.getInstance().calculateMinusHealth(animals.getHealth(), 2)); + } + if(animals.getHealth() <= 0){ + mcm.getInstance().simulateNaturalDrops(x); + } + } + if(x instanceof Monster){ + Monster monster = (Monster)x; + if(monster.getHealth() >= 1){ + monster.setHealth(mcm.getInstance().calculateMinusHealth(monster.getHealth(), 2)); + } + if(monster.getHealth() <= 0){ + mcm.getInstance().simulateNaturalDrops(x); + } + } + + if(x instanceof Player){ + Player player = (Player)x; + if(player.getHealth() >= 1 && mcUsers.getProfile(player).getBleedTicks() >= 1){ + player.setHealth(mcm.getInstance().calculateMinusHealth(player.getHealth(), 1)); + player.sendMessage(ChatColor.RED+"**BLEED**"); + if(player.getHealth() <= 0){ + mcUsers.getProfile(player).setBleedTicks(0); + for(ItemStack items : player.getInventory().getContents()){ + if(items.getTypeId() != 0) + player.getLocation().getWorld().dropItemNaturally(player.getLocation(), items); + } + } + if(mcUsers.getProfile(player).getBleedTicks() >= 1){ + mcUsers.getProfile(player).setBleedTicks(mcUsers.getProfile(player).getBleedTicks() - 1); + } + } + } + } + } + + +} diff --git a/mcMMO/com/gmail/nossr50/mcConfig.java b/mcMMO/com/gmail/nossr50/mcConfig.java index 8c170ab92..597a56bb8 100644 --- a/mcMMO/com/gmail/nossr50/mcConfig.java +++ b/mcMMO/com/gmail/nossr50/mcConfig.java @@ -1,34 +1,24 @@ package com.gmail.nossr50; -import java.io.*; import java.util.*; -import java.util.logging.Level; import java.util.logging.Logger; -import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import java.util.Map.Entry; public class mcConfig { private static volatile mcConfig instance; String location = "mcmmo.properties"; protected static final Logger log = Logger.getLogger("Minecraft"); static ArrayList adminChatList = new ArrayList(); - static ArrayList coordsWatchList = new ArrayList(); static ArrayList blockWatchList = new ArrayList(); static ArrayList partyChatList = new ArrayList(); + static ArrayList godModeList = new ArrayList(); HashMap arrowTracker = new HashMap(); static ArrayList bleedTracker = new ArrayList(); static ArrayList mobSpawnTracker = new ArrayList(); public boolean isBlockWatched(Block block) {return blockWatchList.contains(block);} - public boolean isCoordsWatched(String xyz) {return coordsWatchList.contains(xyz);} public void removeBlockWatch(Block block) {blockWatchList.remove(blockWatchList.indexOf(block));} - public void removeCoordsWatch(String xyz) {coordsWatchList.remove(coordsWatchList.indexOf(xyz));} public void addBlockWatch(Block block) {blockWatchList.add(block);} - public void addCoordsWatch(String xyz) {coordsWatchList.add(xyz);} public void addBleedTrack(Entity entity) {bleedTracker.add(entity);} public void addMobSpawnTrack(Entity entity) {mobSpawnTracker.add(entity);} public ArrayList getBleedTracked() {return bleedTracker;} @@ -66,8 +56,11 @@ public class mcConfig { } public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);} public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);} + public boolean isGodModeToggled(String playerName) {return godModeList.contains(playerName);} + public void removeGodModeToggled(String playerName) {godModeList.remove(godModeList.indexOf(playerName));} public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));} public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));} + public void addGodModeToggled(String playerName) {godModeList.add(playerName);} public void addPartyToggled(String playerName) {partyChatList.add(playerName);} public void addAdminToggled(String playerName) {adminChatList.add(playerName);} @@ -84,6 +77,13 @@ public class mcConfig { addAdminToggled(playerName); } } + public void toggleGodMode(String playerName){ + if(isGodModeToggled(playerName)){ + removeGodModeToggled(playerName); + } else { + addGodModeToggled(playerName); + } + } public void togglePartyChat(String playerName){ if(isPartyToggled(playerName)){ removePartyToggled(playerName); diff --git a/mcMMO/com/gmail/nossr50/mcEntityListener.java b/mcMMO/com/gmail/nossr50/mcEntityListener.java index eb79a5121..cf33dea4e 100644 --- a/mcMMO/com/gmail/nossr50/mcEntityListener.java +++ b/mcMMO/com/gmail/nossr50/mcEntityListener.java @@ -1,23 +1,11 @@ package com.gmail.nossr50; -import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.Animals; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; -import org.bukkit.entity.MobType; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Spider; -import org.bukkit.entity.Squid; -import org.bukkit.entity.Zombie; -import org.bukkit.event.Event; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -59,7 +47,7 @@ public class mcEntityListener extends EntityListener { int y = loc.getBlockY(); int z = loc.getBlockZ(); if(type == DamageCause.FALL){ - mcm.getInstance().acrobaticsCheck(player, event, loc, xx, y, z); + mcAcrobatics.getInstance().acrobaticsCheck(player, event, loc, xx, y, z); } } /* @@ -67,7 +55,7 @@ public class mcEntityListener extends EntityListener { */ if(event instanceof EntityDamageByProjectileEvent){ EntityDamageByProjectileEvent c = (EntityDamageByProjectileEvent)event; - mcm.getInstance().archeryCheck(c); + mcCombat.getInstance().archeryCheck(c); } /* * Entity Damage by Entity checks @@ -81,22 +69,15 @@ public class mcEntityListener extends EntityListener { */ if(e instanceof Player){ Player defender = (Player)e; + if(mcConfig.getInstance().isGodModeToggled(defender.getName())) + event.setCancelled(true); if(f instanceof Monster){ mcUsers.getProfile(defender).setRecentlyHurt(30); } /* * PARRYING CHECK, CHECK TO SEE IF ITS A SUCCESSFUL PARRY OR NOT */ - mcm.getInstance().parryCheck(defender, eventb, f); - /* - * PLAYER DEATH BY MONSTER MESSAGE CHECK, CHECKS TO SEE IF TO REPORT THE DEATH OR NOT - */ - //mcm.getInstance().playerDeathByMonsterMessageCheck(y, defender, plugin); - /* - * CHECKS IF THE PLAYER DIES, IF SO DROP HIS SHIT BECAUSE OF THE DAMAGE MODIFIERS - * MIGHT BE A BIT BUGGY, IT SEEMS TO WORK RIGHT NOW AT LEAST... - */ - + mcCombat.getInstance().parryCheck(defender, eventb, f); } /* * IF ATTACKER IS PLAYER @@ -108,20 +89,36 @@ public class mcEntityListener extends EntityListener { /* * Player versus Monster checks, this handles all skill damage modifiers and any procs. */ - mcm.getInstance().playerVersusMonsterChecks(eventb, attacker, e, typeid); + mcCombat.getInstance().playerVersusMonsterChecks(eventb, attacker, e, typeid); /* * Player versus Squid checks, this handles all skill damage modifiers and any procs. */ - mcm.getInstance().playerVersusSquidChecks(eventb, attacker, e, typeid); + mcCombat.getInstance().playerVersusSquidChecks(eventb, attacker, e, typeid); /* * Player versus Player checks, these checks make sure players are not in the same party, etc. They also check for any procs from skills and handle damage modifiers. */ if(mcm.getInstance().isPvpEnabled()) - mcm.getInstance().playerVersusPlayerChecks(e, attacker, eventb, plugin); + mcCombat.getInstance().playerVersusPlayerChecks(e, attacker, eventb); /* * Player versus Animals checks, these checks handle any skill modifiers or procs */ - mcm.getInstance().playerVersusAnimalsChecks(e, attacker, eventb, typeid); + mcCombat.getInstance().playerVersusAnimalsChecks(e, attacker, eventb, typeid); + } + if(f instanceof Player && e instanceof Player && !mcLoadProperties.pvp) + event.setCancelled(true); + if(e instanceof Monster || e instanceof Animals){ + if(e instanceof Monster){ + Monster monster = (Monster)e; + if(monster.getHealth() <= 0){ + mcConfig.getInstance().removeBleedTrack(e); + } + } + if(e instanceof Animals){ + Animals animals = (Animals)e; + if(animals.getHealth() <= 0){ + mcConfig.getInstance().removeBleedTrack(e); + } + } } } } diff --git a/mcMMO/com/gmail/nossr50/mcExcavation.java b/mcMMO/com/gmail/nossr50/mcExcavation.java new file mode 100644 index 000000000..187bf58f5 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcExcavation.java @@ -0,0 +1,157 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class mcExcavation { + private static mcMMO plugin; + public mcExcavation(mcMMO instance) { + plugin = instance; + } + private static volatile mcExcavation instance; + public static mcExcavation getInstance() { + if (instance == null) { + instance = new mcExcavation(plugin); + } + return instance; + } + + public void excavationProcCheck(Block block, Player player){ + int type = block.getTypeId(); + Location loc = block.getLocation(); + ItemStack is = null; + Material mat = null; + if(type == 2 && mcUsers.getProfile(player).getExcavationInt() > 250){ + //CHANCE TO GET EGGS + if(mcLoadProperties.eggs == true && Math.random() * 100 > 99){ + mcUsers.getProfile(player).addExcavationGather(10); + mat = Material.getMaterial(344); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + //CHANCE TO GET APPLES + if(mcLoadProperties.apples == true && Math.random() * 100 > 99){ + mcUsers.getProfile(player).addExcavationGather(10); + mat = Material.getMaterial(260); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + //DIRT SAND OR GRAVEL + if(type == 3 || type == 13 || type == 2 || type == 12){ + mcUsers.getProfile(player).addExcavationGather(3); + if(mcUsers.getProfile(player).getExcavationInt() > 750){ + //CHANCE TO GET CAKE + if(mcLoadProperties.cake == true && Math.random() * 2000 > 1999){ + mcUsers.getProfile(player).addExcavationGather(300); + mat = Material.getMaterial(354); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + if(mcUsers.getProfile(player).getExcavationInt() > 150){ + //CHANCE TO GET MUSIC + if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){ + mcUsers.getProfile(player).addExcavationGather(300); + mat = Material.getMaterial(2256); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + + } + if(mcUsers.getProfile(player).getExcavationInt() > 350){ + //CHANCE TO GET DIAMOND + if(mcLoadProperties.diamond == true && Math.random() * 500 > 499){ + mcUsers.getProfile(player).addExcavationGather(100); + mat = Material.getMaterial(264); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + if(mcUsers.getProfile(player).getExcavationInt() > 250){ + //CHANCE TO GET MUSIC + if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){ + mcUsers.getProfile(player).addExcavationGather(300); + mat = Material.getMaterial(2257); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + } + //SAND + if(type == 12){ + //CHANCE TO GET GLOWSTONE + if(mcLoadProperties.glowstone == true && mcUsers.getProfile(player).getExcavationInt() > 50 && Math.random() * 100 > 95){ + mcUsers.getProfile(player).addExcavationGather(3); + mat = Material.getMaterial(348); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + //CHANCE TO GET SLOWSAND + if(mcLoadProperties.slowsand == true && mcUsers.getProfile(player).getExcavationInt() > 650 && Math.random() * 200 > 199){ + mcUsers.getProfile(player).addExcavationGather(5); + mat = Material.getMaterial(88); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + //CHANCE TO GET DIAMOND + if(mcLoadProperties.diamond == true && mcUsers.getProfile(player).getExcavationInt() > 500 && Math.random() * 500 > 499){ + mcUsers.getProfile(player).addExcavationGather(100); + mat = Material.getMaterial(264); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + //GRASS OR DIRT + if((type == 2 || type == 3) && mcUsers.getProfile(player).getExcavationInt() > 25){ + //CHANCE TO GET GLOWSTONE + if(mcLoadProperties.glowstone == true && Math.random() * 100 > 95){ + mcUsers.getProfile(player).addExcavationGather(5); + mat = Material.getMaterial(348); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + //GRAVEL + if(type == 13){ + //CHANCE TO GET NETHERRACK + if(mcLoadProperties.netherrack == true && mcUsers.getProfile(player).getExcavationInt() > 850 && Math.random() * 200 > 199){ + mcUsers.getProfile(player).addExcavationGather(3); + mat = Material.getMaterial(87); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + //CHANCE TO GET SULPHUR + if(mcLoadProperties.sulphur == true && mcUsers.getProfile(player).getExcavationInt() > 75){ + if(Math.random() * 10 > 9){ + mcUsers.getProfile(player).addExcavationGather(3); + mat = Material.getMaterial(289); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + //CHANCE TO GET BONES + if(mcLoadProperties.bones == true && mcUsers.getProfile(player).getExcavationInt() > 175){ + if(Math.random() * 10 > 6){ + mcUsers.getProfile(player).addExcavationGather(3); + mat = Material.getMaterial(352); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + loc.getWorld().dropItemNaturally(loc, is); + } + } + } + if(mcUsers.getProfile(player).getExcavationGatherInt() >= mcUsers.getProfile(player).getXpToLevel("excavation")){ + int skillups = 0; + while(mcUsers.getProfile(player).getExcavationGatherInt() >= mcUsers.getProfile(player).getXpToLevel("excavation")){ + skillups++; + mcUsers.getProfile(player).removeExcavationGather(mcUsers.getProfile(player).getXpToLevel("excavation")); + mcUsers.getProfile(player).skillUpExcavation(1); + } + player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getExcavation()+")"); + } + } +} diff --git a/mcMMO/com/gmail/nossr50/mcHerbalism.java b/mcMMO/com/gmail/nossr50/mcHerbalism.java new file mode 100644 index 000000000..4869dc6ac --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcHerbalism.java @@ -0,0 +1,113 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class mcHerbalism { + private static mcMMO plugin; + public mcHerbalism(mcMMO instance) { + plugin = instance; + } + private static volatile mcHerbalism instance; + public static mcHerbalism getInstance() { + if (instance == null) { + instance = new mcHerbalism(plugin); + } + return instance; + } + public void herbalismProcCheck(Block block, Player player){ + int type = block.getTypeId(); + Location loc = block.getLocation(); + ItemStack is = null; + Material mat = null; + //player.sendMessage("mcMMO DEBUG: Data ("+block.getData()+")"+" TYPEID ("+block.getTypeId()+")"); + if(type == 59 && block.getData() == (byte) 0x7){ + mat = Material.getMaterial(296); + is = new ItemStack(mat, 1, (byte)0, (byte)0); + mcUsers.getProfile(player).addHerbalismGather(5); + if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ + if(Math.random() * 10 > 8) + loc.getWorld().dropItemNaturally(loc, is); + } + if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 350 ){ + if(Math.random() * 10 > 6) + loc.getWorld().dropItemNaturally(loc, is); + } + if(mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 500 ){ + if(Math.random() * 10 > 4) + loc.getWorld().dropItemNaturally(loc, is); + } + if(mcUsers.getProfile(player).getHerbalismInt() >= 500 && mcUsers.getProfile(player).getHerbalismInt() < 750 ){ + if(Math.random() * 10 > 2) + loc.getWorld().dropItemNaturally(loc, is); + } + } + /* + * We need to check not-wheat stuff for if it was placed by the player or not + */ + if(!mcConfig.getInstance().isBlockWatched(block)){ + //player.sendMessage("DEBUG CODE 2"); + if(type == 39 || type == 40){ + mcUsers.getProfile(player).addHerbalismGather(10); + } + if(type == 37 || type == 38){ + mcUsers.getProfile(player).addHerbalismGather(3); + } + } + if(mcUsers.getProfile(player).getHerbalismGatherInt() >= mcUsers.getProfile(player).getXpToLevel("herbalism")){ + int skillups = 0; + while(mcUsers.getProfile(player).getHerbalismGatherInt() >= mcUsers.getProfile(player).getXpToLevel("herbalism")){ + skillups++; + mcUsers.getProfile(player).removeHerbalismGather(mcUsers.getProfile(player).getXpToLevel("herbalism")); + mcUsers.getProfile(player).skillUpHerbalism(1); + } + player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getHerbalism()+")"); + } + } + public void breadCheck(Player player, ItemStack is){ + if(is.getTypeId() == 297){ + if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ + player.setHealth(player.getHealth() + 1); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){ + player.setHealth(player.getHealth() + 2); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 250 && mcUsers.getProfile(player).getHerbalismInt() < 350){ + player.setHealth(player.getHealth() + 3); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 450){ + player.setHealth(player.getHealth() + 4); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 450 && mcUsers.getProfile(player).getHerbalismInt() < 550){ + player.setHealth(player.getHealth() + 5); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 550 && mcUsers.getProfile(player).getHerbalismInt() < 650){ + player.setHealth(player.getHealth() + 6); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 650 && mcUsers.getProfile(player).getHerbalismInt() < 750){ + player.setHealth(player.getHealth() + 7); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ + player.setHealth(player.getHealth() + 8); + } + } + } + public void stewCheck(Player player, ItemStack is){ + if(is.getTypeId() == 282){ + if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ + player.setHealth(player.getHealth() + 1); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){ + player.setHealth(player.getHealth() + 2); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 250 && mcUsers.getProfile(player).getHerbalismInt() < 350){ + player.setHealth(player.getHealth() + 3); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 450){ + player.setHealth(player.getHealth() + 4); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 450 && mcUsers.getProfile(player).getHerbalismInt() < 550){ + player.setHealth(player.getHealth() + 5); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 550 && mcUsers.getProfile(player).getHerbalismInt() < 650){ + player.setHealth(player.getHealth() + 6); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 650 && mcUsers.getProfile(player).getHerbalismInt() < 750){ + player.setHealth(player.getHealth() + 7); + } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ + player.setHealth(player.getHealth() + 8); + } + } + } +} diff --git a/mcMMO/com/gmail/nossr50/mcLoadProperties.java b/mcMMO/com/gmail/nossr50/mcLoadProperties.java index d44825217..cca32a3f6 100644 --- a/mcMMO/com/gmail/nossr50/mcLoadProperties.java +++ b/mcMMO/com/gmail/nossr50/mcLoadProperties.java @@ -2,7 +2,7 @@ package com.gmail.nossr50; public class mcLoadProperties { public static Boolean pvp, eggs, apples, myspawnclearsinventory, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; - public static String mcmmo, mcc, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; + public static String mcmmo, mcc, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; public static int globalxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier; public static void loadMain(){ @@ -52,6 +52,7 @@ public class mcLoadProperties { */ mcmmo = properties.getString("/mcmmo", "mcmmo"); mcc = properties.getString("/mcc", "mcc"); + mcgod = properties.getString("/mcgod", "mcgod"); stats = properties.getString("/stats", "stats"); mmoedit = properties.getString("/mmoedit", "mmoedit"); ptp = properties.getString("/ptp", "ptp"); diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 5e5f1fba0..444873fe5 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -2,22 +2,16 @@ package com.gmail.nossr50; import com.nijikokun.bukkit.Permissions.Permissions; import com.nijiko.Messaging; import com.nijiko.permissions.PermissionHandler; -import com.nijiko.permissions.Control; -import com.nijikokun.bukkit.Permissions.Permissions; import org.bukkit.plugin.Plugin; import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.HashMap; import java.util.Timer; import java.util.logging.Level; import java.util.logging.Logger; -import org.bukkit.event.player.*; -import org.bukkit.Server; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event; import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.PluginManager; import org.bukkit.entity.Player; @@ -30,8 +24,7 @@ public class mcMMO extends JavaPlugin { private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcBlockListener blockListener = new mcBlockListener(this); private final mcEntityListener entityListener = new mcEntityListener(this); - private final mcServerListener serverListener = new mcServerListener(this); - private final HashMap debugees = new HashMap(); + //private final mcServerListener serverListener = new mcServerListener(this); private final String name = "mcMMO"; public static PermissionHandler PermissionsHandler = null; private Permissions permissions; @@ -71,7 +64,6 @@ public class mcMMO extends JavaPlugin { } } //Load the file - //sup mcLoadProperties.loadMain(); mcUsers.getInstance().loadUsers(); PluginManager pm = getServer().getPluginManager(); @@ -120,7 +112,6 @@ public class mcMMO extends JavaPlugin { return false; } } - public Permissions getPermissions() { return permissions; } diff --git a/mcMMO/com/gmail/nossr50/mcMining.java b/mcMMO/com/gmail/nossr50/mcMining.java new file mode 100644 index 000000000..9c441bb52 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcMining.java @@ -0,0 +1,140 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class mcMining { + private static mcMMO plugin; + public mcMining(mcMMO instance) { + plugin = instance; + } + private static volatile mcMining instance; + public static mcMining getInstance() { + if (instance == null) { + instance = new mcMining(plugin); + } + return instance; + } + public void blockProcSimulate(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() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16) + loc.getWorld().dropItemNaturally(loc, item); + //hurrdurr + 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 void blockProcCheck(Block block, Player player){ + if(mcUsers.getProfile(player).getMiningInt() > 2000){ + blockProcSimulate(block); + return; + } + if(mcUsers.getProfile(player).getMiningInt() > 1250){ + if((Math.random() * 10) > 2){ + blockProcSimulate(block); + return; + } + } + if(mcUsers.getProfile(player).getMiningInt() > 750){ + if((Math.random() * 10) > 4){ + blockProcSimulate(block); + return; + } + } + if(mcUsers.getProfile(player).getMiningInt() > 150){ + if((Math.random() * 10) > 6){ + blockProcSimulate(block); + return; + } + } + if(mcUsers.getProfile(player).getMiningInt() > 25){ + if((Math.random() * 10) > 8){ + blockProcSimulate(block); + return; + } + } + } + public void miningBlockCheck(Player player, Block block){ + if(block.getTypeId() == 1){ + mcUsers.getProfile(player).addMiningGather(1); + blockProcCheck(block, player); + } + //COAL + if(block.getTypeId() == 16){ + mcUsers.getProfile(player).addMiningGather(5); + blockProcCheck(block, player); + } + //GOLD + if(block.getTypeId() == 14){ + mcUsers.getProfile(player).addMiningGather(35); + blockProcCheck(block, player); + } + //DIAMOND + if(block.getTypeId() == 56){ + mcUsers.getProfile(player).addMiningGather(75); + blockProcCheck(block, player); + } + //IRON + if(block.getTypeId() == 15){ + mcUsers.getProfile(player).addMiningGather(20); + blockProcCheck(block, player); + } + //REDSTONE + if(block.getTypeId() == 73 || block.getTypeId() == 74){ + mcUsers.getProfile(player).addMiningGather(15); + blockProcCheck(block, player); + } + //LAPUS + if(block.getTypeId() == 21){ + mcUsers.getProfile(player).addMiningGather(40); + blockProcCheck(block, player); + } + if(mcUsers.getProfile(player).getMiningGatherInt() >= mcUsers.getProfile(player).getXpToLevel("mining")){ + int skillups = 0; + while(mcUsers.getProfile(player).getMiningGatherInt() >= mcUsers.getProfile(player).getXpToLevel("mining")){ + skillups++; + mcUsers.getProfile(player).removeMiningGather(mcUsers.getProfile(player).getXpToLevel("mining")); + mcUsers.getProfile(player).skillUpMining(1); + } + player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getMining()+")"); + } + } + +} diff --git a/mcMMO/com/gmail/nossr50/mcParty.java b/mcMMO/com/gmail/nossr50/mcParty.java new file mode 100644 index 000000000..721b1ede9 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcParty.java @@ -0,0 +1,58 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public class mcParty { + private static mcMMO plugin; + public mcParty(mcMMO instance) { + plugin = instance; + } + private static volatile mcParty instance; + public static mcParty getInstance() { + if (instance == null) { + instance = new mcParty(plugin); + } + return instance; + } + public boolean inSameParty(Player playera, Player playerb){ + if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ + return true; + } else { + return false; + } + } + public int partyCount(Player player, Player[] players){ + int x = 0; + for(Player hurrdurr : players){ + if(player != null && hurrdurr != null){ + if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty())) + x++; + } + } + return x; + } + public void informPartyMembers(Player player, Player[] players){ + int x = 0; + for(Player p : players){ + if(player != null && p != null){ + if(inSameParty(player, p) && !p.getName().equals(player.getName())){ + p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party"); + x++; + } + } + } + } + public void informPartyMembersQuit(Player player, Player[] players){ + int x = 0; + for(Player p : players){ + if(player != null && p != null){ + if(inSameParty(player, p) && !p.getName().equals(player.getName())){ + p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party"); + x++; + } + } + } + } + +} diff --git a/mcMMO/com/gmail/nossr50/mcPermissions.java b/mcMMO/com/gmail/nossr50/mcPermissions.java index 9f495a24d..9e5f26668 100644 --- a/mcMMO/com/gmail/nossr50/mcPermissions.java +++ b/mcMMO/com/gmail/nossr50/mcPermissions.java @@ -37,6 +37,13 @@ public class mcPermissions { return true; } } + public boolean mcgod(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.tools.mcgod"); + } else { + return true; + } + } public boolean regeneration(Player player){ if (permissionsEnabled) { return permission(player, "mcmmo.regeneration"); diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index 5cac15b4e..c345ecb70 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -5,22 +5,16 @@ import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerItemEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.plugin.*; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; -import com.nijikokun.bukkit.Permissions.Permissions; - public class mcPlayerListener extends PlayerListener { protected static final Logger log = Logger.getLogger("Minecraft"); public Location spawn = null; @@ -30,16 +24,15 @@ public class mcPlayerListener extends PlayerListener { plugin = instance; } public void onPlayerRespawn(PlayerRespawnEvent event) { - Player player = event.getPlayer(); + Player player = event.getPlayer(); + if(player != null){ Location mySpawn = mcUsers.getProfile(player).getMySpawn(player); - if(mcUsers.getProfile(player).getMySpawnWorld() != null && !mcUsers.getProfile(player).getMySpawnWorld().equals("")){ - if(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld()) != null) - mySpawn.setWorld(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld())); - } - if(mcPermissions.getInstance().mySpawn(player)){ - if(mcUsers.getProfile(player).getMySpawn(player) != null) + if(mcUsers.getProfile(player).getMySpawnWorld(plugin) != null && !mcUsers.getProfile(player).getMySpawnWorld(plugin).equals("") && plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld(plugin)) != null) + mySpawn.setWorld(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld(plugin))); + if(mcPermissions.getInstance().mySpawn(player) && mySpawn != null){ event.setRespawnLocation(mySpawn); } + } } public Player[] getPlayersOnline() { return plugin.getServer().getOnlinePlayers(); @@ -60,32 +53,6 @@ public class mcPlayerListener extends PlayerListener { } return null; } - public int partyCount(Player player){ - int x = 0; - for(Player hurrdurr: getPlayersOnline()){ - if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty())) - x++; - } - return x; - } - public void informPartyMembers(Player player){ - int x = 0; - for(Player p : getPlayersOnline()){ - if(mcm.getInstance().inSameParty(player, p) && !p.getName().equals(player.getName())){ - p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party"); - x++; - } - } - } - public void informPartyMembersQuit(Player player){ - int x = 0; - for(Player p : getPlayersOnline()){ - if(mcm.getInstance().inSameParty(player, p) && !p.getName().equals(player.getName())){ - p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party"); - x++; - } - } - } public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); mcUsers.addUser(player); @@ -104,13 +71,13 @@ public class mcPlayerListener extends PlayerListener { ItemStack is = player.getItemInHand(); if(mcPermissions.getInstance().herbalism(player)){ //BREADCHECK, CHECKS HERBALISM SKILL FOR BREAD HP MODIFIERS - mcm.getInstance().breadCheck(player, is); + mcHerbalism.getInstance().breadCheck(player, is); //STEW, CHECKS HERBALISM SKILL FOR BREAD HP MODIFIERS - mcm.getInstance().stewCheck(player, is); + mcHerbalism.getInstance().stewCheck(player, is); } if(mcPermissions.getInstance().repair(player)){ //REPAIRCHECK, CHECKS TO MAKE SURE PLAYER IS RIGHT CLICKING AN ANVIL, PLAYER HAS ENOUGH RESOURCES, AND THE ITEM IS NOT AT FULL DURABILITY. - mcm.getInstance().repairCheck(player, is, block); + mcRepair.getInstance().repairCheck(player, is, block); } } public void onPlayerCommandPreprocess(PlayerChatEvent event){ @@ -120,8 +87,22 @@ public class mcPlayerListener extends PlayerListener { //Check if the command is an mcMMO related help command mcm.getInstance().mcmmoHelpCheck(split, player, event); /* - * MMOEDIT COMMAND + * GODMODE COMMAND */ + if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcgod)){ + event.setCancelled(true); + if(!mcPermissions.getInstance().mcgod(player)){ + player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); + return; + } + if(mcConfig.getInstance().isGodModeToggled(playerName)){ + player.sendMessage(ChatColor.YELLOW+"mcMMO Godmode Disabled"); + mcConfig.getInstance().toggleGodMode(playerName); + } else { + player.sendMessage(ChatColor.YELLOW+"mcMMO Godmode Enabled"); + mcConfig.getInstance().toggleGodMode(playerName); + } + } if(mcPermissions.getInstance().mySpawn(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.clearmyspawn)){ event.setCancelled(true); double x = plugin.getServer().getWorlds().get(0).getSpawnLocation().getX(); @@ -141,14 +122,14 @@ public class mcPlayerListener extends PlayerListener { return; } if(split.length == 4){ - if(isPlayer(split[1]) && mcm.getInstance().isInt(split[3]) && mcm.getInstance().isSkill(split[2])){ + if(isPlayer(split[1]) && mcm.getInstance().isInt(split[3]) && mcSkills.getInstance().isSkill(split[2])){ int newvalue = Integer.valueOf(split[3]); mcUsers.getProfile(getPlayer(split[1])).modifyskill(newvalue, split[2]); player.sendMessage(ChatColor.RED+split[2]+" has been modified."); } } else if(split.length == 3){ - if(mcm.getInstance().isInt(split[2]) && mcm.getInstance().isSkill(split[1])){ + if(mcm.getInstance().isInt(split[2]) && mcSkills.getInstance().isSkill(split[1])){ int newvalue = Integer.valueOf(split[2]); mcUsers.getProfile(player).modifyskill(newvalue, split[1]); player.sendMessage(ChatColor.RED+split[1]+" has been modified."); @@ -198,34 +179,44 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage("Party: "+mcUsers.getProfile(target).getParty()); player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)"); player.sendMessage("OP: " + target.isOp()); - player.sendMessage(ChatColor.GREEN+"~~mcMMO stats~~"); + player.sendMessage(ChatColor.GREEN+"mcMMO Stats for "+ChatColor.YELLOW+target.getName()); + if(mcPermissions.getInstance().mining(target)) player.sendMessage(ChatColor.YELLOW + "Mining Skill: " + ChatColor.GREEN + mcUsers.getProfile(target).getMining()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getMiningGather() +"/"+mcUsers.getProfile(target).getXpToLevel("mining")+")"); + if(mcPermissions.getInstance().repair(target)) player.sendMessage(ChatColor.YELLOW + "Repair Skill: "+ ChatColor.GREEN + mcUsers.getProfile(target).getRepair()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getRepairGather() +"/"+mcUsers.getProfile(target).getXpToLevel("repair")+")"); + if(mcPermissions.getInstance().woodcutting(target)) player.sendMessage(ChatColor.YELLOW + "Woodcutting Skill: "+ ChatColor.GREEN + mcUsers.getProfile(target).getWoodCutting()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getWoodCuttingGather() +"/"+mcUsers.getProfile(target).getXpToLevel("woodcutting")+")"); + if(mcPermissions.getInstance().unarmed(target)) player.sendMessage(ChatColor.YELLOW + "Unarmed Skill: " + ChatColor.GREEN + mcUsers.getProfile(target).getUnarmed()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getUnarmedGather() +"/"+mcUsers.getProfile(target).getXpToLevel("unarmed")+")"); + if(mcPermissions.getInstance().herbalism(target)) player.sendMessage(ChatColor.YELLOW + "Herbalism Skill: "+ ChatColor.GREEN + mcUsers.getProfile(target).getHerbalism()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getHerbalismGather() +"/"+mcUsers.getProfile(target).getXpToLevel("herbalism")+")"); + if(mcPermissions.getInstance().excavation(target)) player.sendMessage(ChatColor.YELLOW + "Excavation Skill: "+ ChatColor.GREEN + mcUsers.getProfile(target).getExcavation()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getExcavationGather() +"/"+mcUsers.getProfile(target).getXpToLevel("excavation")+")"); + if(mcPermissions.getInstance().archery(target)) player.sendMessage(ChatColor.YELLOW + "Archery Skill: " + ChatColor.GREEN + mcUsers.getProfile(target).getArchery()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getArcheryGather() +"/"+mcUsers.getProfile(target).getXpToLevel("archery")+")"); + if(mcPermissions.getInstance().swords(target)) player.sendMessage(ChatColor.YELLOW + "Swords Skill: " + ChatColor.GREEN + mcUsers.getProfile(target).getSwords()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getSwordsGather() +"/"+mcUsers.getProfile(target).getXpToLevel("swords")+")"); + if(mcPermissions.getInstance().axes(target)) player.sendMessage(ChatColor.YELLOW + "Axes Skill: " + ChatColor.GREEN + mcUsers.getProfile(target).getAxes()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getAxesGather() +"/"+mcUsers.getProfile(target).getXpToLevel("axes")+")"); + if(mcPermissions.getInstance().acrobatics(target)) player.sendMessage(ChatColor.YELLOW + "Acrobatics Skill: " + ChatColor.GREEN + mcUsers.getProfile(target).getAcrobatics()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(target).getAcrobaticsGather() +"/"+mcUsers.getProfile(target).getXpToLevel("acrobatics")+")"); @@ -268,34 +259,46 @@ public class mcPlayerListener extends PlayerListener { */ if(split[0].equalsIgnoreCase("/"+mcLoadProperties.stats)){ event.setCancelled(true); - player.sendMessage(ChatColor.DARK_RED + "mcMMO stats"); + player.sendMessage(ChatColor.GREEN + "Your mcMMO Stats"); + if(mcPermissions.getInstance().permissionsEnabled) + player.sendMessage(ChatColor.DARK_GRAY+"If you don't have access to a skill it will not be shown here."); + if(mcPermissions.getInstance().mining(player)) player.sendMessage(ChatColor.YELLOW + "Mining Skill: " + ChatColor.GREEN + mcUsers.getProfile(player).getMining()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getMiningGather() +"/"+mcUsers.getProfile(player).getXpToLevel("mining")+")"); + if(mcPermissions.getInstance().repair(player)) player.sendMessage(ChatColor.YELLOW + "Repair Skill: "+ ChatColor.GREEN + mcUsers.getProfile(player).getRepair()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getRepairGather() +"/"+mcUsers.getProfile(player).getXpToLevel("repair")+")"); + if(mcPermissions.getInstance().woodcutting(player)) player.sendMessage(ChatColor.YELLOW + "Woodcutting Skill: "+ ChatColor.GREEN + mcUsers.getProfile(player).getWoodCutting()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getWoodCuttingGather() +"/"+mcUsers.getProfile(player).getXpToLevel("woodcutting")+")"); + if(mcPermissions.getInstance().unarmed(player)) player.sendMessage(ChatColor.YELLOW + "Unarmed Skill: " + ChatColor.GREEN + mcUsers.getProfile(player).getUnarmed()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getUnarmedGather() +"/"+mcUsers.getProfile(player).getXpToLevel("unarmed")+")"); + if(mcPermissions.getInstance().herbalism(player)) player.sendMessage(ChatColor.YELLOW + "Herbalism Skill: "+ ChatColor.GREEN + mcUsers.getProfile(player).getHerbalism()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getHerbalismGather() +"/"+mcUsers.getProfile(player).getXpToLevel("herbalism")+")"); + if(mcPermissions.getInstance().excavation(player)) player.sendMessage(ChatColor.YELLOW + "Excavation Skill: "+ ChatColor.GREEN + mcUsers.getProfile(player).getExcavation()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getExcavationGather() +"/"+mcUsers.getProfile(player).getXpToLevel("excavation")+")"); + if(mcPermissions.getInstance().archery(player)) player.sendMessage(ChatColor.YELLOW + "Archery Skill: " + ChatColor.GREEN + mcUsers.getProfile(player).getArchery()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getArcheryGather() +"/"+mcUsers.getProfile(player).getXpToLevel("archery")+")"); + if(mcPermissions.getInstance().swords(player)) player.sendMessage(ChatColor.YELLOW + "Swords Skill: " + ChatColor.GREEN + mcUsers.getProfile(player).getSwords()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getSwordsGather() +"/"+mcUsers.getProfile(player).getXpToLevel("swords")+")"); + if(mcPermissions.getInstance().axes(player)) player.sendMessage(ChatColor.YELLOW + "Axes Skill: " + ChatColor.GREEN + mcUsers.getProfile(player).getAxes()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getAxesGather() +"/"+mcUsers.getProfile(player).getXpToLevel("axes")+")"); + if(mcPermissions.getInstance().acrobatics(player)) player.sendMessage(ChatColor.YELLOW + "Acrobatics Skill: " + ChatColor.GREEN + mcUsers.getProfile(player).getAcrobatics()+ChatColor.DARK_AQUA + " XP("+mcUsers.getProfile(player).getAcrobaticsGather() +"/"+mcUsers.getProfile(player).getXpToLevel("acrobatics")+")"); @@ -334,10 +337,10 @@ public class mcPlayerListener extends PlayerListener { if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.accept)){ if(mcUsers.getProfile(player).hasPartyInvite()){ if(mcUsers.getProfile(player).inParty()){ - informPartyMembersQuit(player); + mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline()); } mcUsers.getProfile(player).acceptInvite(); - informPartyMembers(player); + mcParty.getInstance().informPartyMembers(player, getPlayersOnline()); player.sendMessage(ChatColor.GREEN+"Invite accepted. You have joined party ("+mcUsers.getProfile(player).getParty()+")"); } else { player.sendMessage(ChatColor.RED+"You have no invites at this time"); @@ -360,11 +363,11 @@ public class mcPlayerListener extends PlayerListener { for(Player p : plugin.getServer().getOnlinePlayers()) { if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(p).getParty())){ - if(p != null && x+1 >= partyCount(player)){ + if(p != null && x+1 >= mcParty.getInstance().partyCount(player, getPlayersOnline())){ tempList+= p.getName(); x++; } - if(p != null && x < partyCount(player)){ + if(p != null && x < mcParty.getInstance().partyCount(player, getPlayersOnline())){ tempList+= p.getName() +", "; x++; } @@ -374,18 +377,18 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage(ChatColor.GREEN + "Party Members ("+ChatColor.WHITE+tempList+ChatColor.GREEN+")"); } if(split.length > 1 && split[1].equals("q") && mcUsers.getProfile(player).inParty()){ - informPartyMembersQuit(player); + mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline()); mcUsers.getProfile(player).removeParty(); player.sendMessage(ChatColor.RED + "You have left that party"); return; } if(split.length >= 2){ - if(mcUsers.getProfile(player).inParty()) - informPartyMembersQuit(player); - mcUsers.getProfile(player).setParty(split[1]); - player.sendMessage("Joined Party: " + split[1]); - informPartyMembers(player); - } + if(mcUsers.getProfile(player).inParty()) + mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline()); + mcUsers.getProfile(player).setParty(split[1]); + player.sendMessage("Joined Party: " + split[1]); + mcParty.getInstance().informPartyMembers(player, getPlayersOnline()); + } } if(split[0].equalsIgnoreCase("/p")){ if(!mcPermissions.getInstance().party(player)){ @@ -432,8 +435,8 @@ public class mcPlayerListener extends PlayerListener { player.setHealth(20); Location mySpawn = mcUsers.getProfile(player).getMySpawn(player); //player.sendMessage("mcMMO DEBUG CODE 1"); - if(mcUsers.getProfile(player).getMySpawnWorld() != null && !mcUsers.getProfile(player).getMySpawnWorld().equals("")){ - mySpawn.setWorld(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld())); + if(mcUsers.getProfile(player).getMySpawnWorld(plugin) != null && !mcUsers.getProfile(player).getMySpawnWorld(plugin).equals("")){ + mySpawn.setWorld(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld(plugin))); //player.sendMessage("mcMMO DEBUG CODE 2"); } else { //player.sendMessage("mcMMO DEBUG CODE 5"); @@ -459,7 +462,7 @@ public class mcPlayerListener extends PlayerListener { log.log(Level.INFO, "[P]("+mcUsers.getProfile(player).getParty()+")"+"<"+player.getName()+"> "+event.getMessage()); for(Player herp : plugin.getServer().getOnlinePlayers()){ if(mcUsers.getProfile(herp).inParty()){ - if(mcm.getInstance().inSameParty(herp, player)){ + if(mcParty.getInstance().inSameParty(herp, player)){ herp.sendMessage(x+event.getMessage()); } } diff --git a/mcMMO/com/gmail/nossr50/mcRepair.java b/mcMMO/com/gmail/nossr50/mcRepair.java new file mode 100644 index 000000000..3553c8531 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcRepair.java @@ -0,0 +1,375 @@ +package com.gmail.nossr50; + +import org.bukkit.ChatColor; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class mcRepair { + private static mcMMO plugin; + public mcRepair(mcMMO instance) { + plugin = instance; + } + private static volatile mcRepair instance; + public static mcRepair getInstance() { + if (instance == null) { + instance = new mcRepair(plugin); + } + return instance; + } + public void repairCheck(Player player, ItemStack is, Block block){ + if(block != null + && block.getTypeId() == 42 + && mcPermissions.getInstance().repair(player)){ + if(player.getItemInHand().getDurability() > 0){ + /* + * ARMOR + */ + if(isArmor(is) && block.getTypeId() == 42){ + /* + * DIAMOND ARMOR + */ + if(isDiamondArmor(is) && hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() >= 50){ + removeDiamond(player); + player.getItemInHand().setDurability(getArmorRepairAmount(is, player)); + mcUsers.getProfile(player).addRepairGather(75); + } else if (isIronArmor(is) && hasIron(player)){ + /* + * IRON ARMOR + */ + removeIron(player); + player.getItemInHand().setDurability(getArmorRepairAmount(is, player)); + /* + * DISTRIBUTE REPAIR XP + */ + mcUsers.getProfile(player).addRepairGather(20); + //GOLD ARMOR + } else if (isGoldArmor(is) && hasGold(player)){ + removeGold(player); + player.getItemInHand().setDurability(getArmorRepairAmount(is, player)); + mcUsers.getProfile(player).addRepairGather(50); + } else { + needMoreVespeneGas(is, player); + } + } + /* + * TOOLS + */ + if(isTools(is) && block.getTypeId() == 42){ + /* + * IRON TOOLS + */ + if(isIronTools(is) && hasIron(player)){ + is.setDurability(getToolRepairAmount(is, player)); + removeIron(player); + mcUsers.getProfile(player).addRepairGather(20); + } else if (isDiamondTools(is) && hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() >= 50){ //Check if its diamond and the player has diamonds + /* + * DIAMOND TOOLS + */ + is.setDurability(getToolRepairAmount(is, player)); + removeDiamond(player); + mcUsers.getProfile(player).addRepairGather(75); + } else if(isGoldTools(is) && hasGold(player)){ + is.setDurability(getToolRepairAmount(is, player)); + removeGold(player); + mcUsers.getProfile(player).addRepairGather(50); + } else { + needMoreVespeneGas(is, player); + } + } + + } else { + player.sendMessage("That is at full durability."); + } + player.updateInventory(); + /* + * GIVE SKILL IF THERE IS ENOUGH XP + */ + if(mcUsers.getProfile(player).getRepairGatherInt() >= mcUsers.getProfile(player).getXpToLevel("repair")){ + int skillups = 0; + while(mcUsers.getProfile(player).getRepairGatherInt() >= mcUsers.getProfile(player).getXpToLevel("repair")){ + skillups++; + mcUsers.getProfile(player).removeRepairGather(mcUsers.getProfile(player).getXpToLevel("repair")); + mcUsers.getProfile(player).skillUpRepair(1); + } + player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getRepair()+")"); + } + } + } + public boolean isArmor(ItemStack is){ + if(is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 || + is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 || + is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317){ + return true; + } else { + return false; + } + } + public boolean isGoldArmor(ItemStack is){ + if(is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317){ + return true; + } else { + return false; + } + } + public boolean isIronArmor(ItemStack is){ + if(is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309) + { + return true; + } else { + return false; + } + } + public boolean isDiamondArmor(ItemStack is){ + if(is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313) + { + return true; + } else { + return false; + } + } + public boolean isTools(ItemStack is){ + if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON + is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND + is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284) //GOLD + { + return true; + } else { + return false; + } + } + public boolean isGoldTools(ItemStack is){ + if(is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294){ + return true; + } else { + return false; + } + } + public boolean isIronTools(ItemStack is){ + if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292) + { + return true; + } else { + return false; + } + } + + public boolean isDiamondTools(ItemStack is){ + if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293) + { + return true; + } else { + return false; + } + } + public void removeIron(Player player){ + ItemStack[] inventory = player.getInventory().getContents(); + for(ItemStack x : inventory){ + if(x.getTypeId() == 265){ + if(x.getAmount() == 1){ + x.setTypeId(0); + x.setAmount(0); + player.getInventory().setContents(inventory); + } else{ + x.setAmount(x.getAmount() - 1); + player.getInventory().setContents(inventory); + } + return; + } + } + } + public void removeGold(Player player){ + ItemStack[] inventory = player.getInventory().getContents(); + for(ItemStack x : inventory){ + if(x.getTypeId() == 266){ + if(x.getAmount() == 1){ + x.setTypeId(0); + x.setAmount(0); + player.getInventory().setContents(inventory); + } else{ + x.setAmount(x.getAmount() - 1); + player.getInventory().setContents(inventory); + } + return; + } + } + } + public void removeDiamond(Player player){ + ItemStack[] inventory = player.getInventory().getContents(); + for(ItemStack x : inventory){ + if(x.getTypeId() == 264){ + if(x.getAmount() == 1){ + x.setTypeId(0); + x.setAmount(0); + player.getInventory().setContents(inventory); + } else{ + x.setAmount(x.getAmount() - 1); + player.getInventory().setContents(inventory); + } + return; + } + } + } + public boolean hasGold(Player player){ + ItemStack[] inventory = player.getInventory().getContents(); + for(ItemStack x : inventory){ + if(x.getTypeId() == 266){ + return true; + } + } + return false; + } + public boolean hasDiamond(Player player){ + ItemStack[] inventory = player.getInventory().getContents(); + for(ItemStack x : inventory){ + if(x.getTypeId() == 264){ + return true; + } + } + return false; + } + public boolean hasIron(Player player){ + ItemStack[] inventory = player.getInventory().getContents(); + for(ItemStack x : inventory){ + if(x.getTypeId() == 265){ + return true; + } + } + return false; + } + public short getToolRepairAmount(ItemStack is, Player player){ + short durability = is.getDurability(); + switch(is.getTypeId()) + { + case 284: + durability = 0; + break; + case 256: + durability = 0; + break; + case 277: + durability = 0; + break; + case 257: + durability -= 84; + break; + case 258: + durability -= 84; + break; + case 267: + durability -= 84; + break; + case 292: + durability -= 84; + break; + case 276: + durability -= 509; + break; + case 278: + durability -= 509; + break; + case 279: + durability -= 509; + break; + case 293: + durability -= 509; + break; + case 283: + durability -= 13; + break; + case 285: + durability -= 13; + break; + case 286: + durability -= 13; + break; + case 294: + durability -= 13; + break; + } + if(durability < 0) + durability = 0; + if(checkPlayerProcRepair(player)) + durability = 0; + return durability; + } + //This determines how much we repair + public short getArmorRepairAmount(ItemStack is, Player player){ + short durability = is.getDurability(); + switch(is.getTypeId()) + { + case 306: + durability -= 27; + break; + case 310: + durability -= 55; + break; + case 307: + durability -= 24; + break; + case 311: + durability -= 48; + break; + case 308: + durability -= 27; + break; + case 312: + durability -= 53; + break; + case 309: + durability -= 40; + break; + case 313: + durability -= 80; + break; + } + if(durability < 0) + durability = 0; + if(checkPlayerProcRepair(player)) + durability = 0; + return durability; + } + public void needMoreVespeneGas(ItemStack is, Player player){ + if ((isDiamondTools(is) || isDiamondArmor(is)) && mcUsers.getProfile(player).getRepairInt() < 50){ + player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); + } else if (isDiamondTools(is) && !hasDiamond(player) || isIronTools(is) && !hasIron(player) || isGoldTools(is) && !hasGold(player)){ + if(isDiamondTools(is) && !hasDiamond(player)) + player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); + if(isIronTools(is) && !hasIron(player)) + player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); + //herp + if(isGoldTools(is) && !hasGold(player)) + player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold"); + } else if (isDiamondArmor(is) && !hasDiamond(player)){ + player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); + } else if (isIronArmor(is) && !hasIron(player)){ + player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); + } else if (isGoldArmor(is) && !hasGold(player)) + player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold"); + } + public boolean checkPlayerProcRepair(Player player){ + if(mcUsers.getProfile(player).getRepairInt() >= 750){ + if(Math.random() * 10 > 2){ + player.sendMessage(ChatColor.GRAY + "That took no effort."); + return true; + } + } else if (mcUsers.getProfile(player).getRepairInt() >= 450 && mcUsers.getProfile(player).getRepairInt() < 750){ + if(Math.random() * 10 > 4){ + player.sendMessage(ChatColor.GRAY + "That felt really easy."); + return true; + } + } else if (mcUsers.getProfile(player).getRepairInt() >= 150 && mcUsers.getProfile(player).getRepairInt() < 450){ + if(Math.random() * 10 > 6){ + player.sendMessage(ChatColor.GRAY + "That felt pretty easy."); + return true; + } + } else if (mcUsers.getProfile(player).getRepairInt() >= 50 && mcUsers.getProfile(player).getRepairInt() < 150){ + if(Math.random() * 10 > 8){ + player.sendMessage(ChatColor.GRAY + "That felt easy."); + return true; + } + } + return false; +} +} diff --git a/mcMMO/com/gmail/nossr50/mcSkills.java b/mcMMO/com/gmail/nossr50/mcSkills.java new file mode 100644 index 000000000..b6d1c5e65 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcSkills.java @@ -0,0 +1,79 @@ +package com.gmail.nossr50; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class mcSkills { + private static mcMMO plugin; + public mcSkills(mcMMO instance) { + plugin = instance; + } + private static volatile mcSkills instance; + public static mcSkills getInstance() { + if (instance == null) { + instance = new mcSkills(plugin); + } + return instance; + } + public boolean hasArrows(Player player){ + for(ItemStack x : player.getInventory().getContents()){ + if (x.getTypeId() == 262){ + return true; + } + } + return false; + } + public void addArrows(Player player){ + for(ItemStack x : player.getInventory().getContents()){ + if (x.getTypeId() == 262){ + x.setAmount(x.getAmount() + 1); + return; + } + } + } + public boolean isSkill(String skillname){ + 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; + } +} + public void arrowRetrievalCheck(Entity entity){ + if(mcConfig.getInstance().isTracked(entity)){ + Integer x = 0; + while(x < mcConfig.getInstance().getArrowCount(entity)){ + mcm.getInstance().mcDropItem(entity.getLocation(), 262); + x++; + } + } + } +} diff --git a/mcMMO/com/gmail/nossr50/mcTimer.java b/mcMMO/com/gmail/nossr50/mcTimer.java index 0685ea302..54962927f 100644 --- a/mcMMO/com/gmail/nossr50/mcTimer.java +++ b/mcMMO/com/gmail/nossr50/mcTimer.java @@ -1,12 +1,7 @@ package com.gmail.nossr50; -import java.util.List; -import java.util.Timer; import java.util.TimerTask; -import org.bukkit.ChatColor; -import org.bukkit.World; import org.bukkit.entity.*; -import org.bukkit.inventory.ItemStack; public class mcTimer extends TimerTask{ private final mcMMO plugin; @@ -16,8 +11,9 @@ public class mcTimer extends TimerTask{ this.plugin = plugin; } public void run() { + Player[] playerlist = plugin.getServer().getOnlinePlayers(); if(thecount == 5 || thecount == 10 || thecount == 15 || thecount == 20){ - for(Player player : plugin.getServer().getOnlinePlayers()){ + for(Player player : playerlist){ if(player != null && player.getHealth() > 0 && player.getHealth() < 20 && mcUsers.getProfile(player).getPowerLevel() >= 1000 @@ -28,7 +24,7 @@ public class mcTimer extends TimerTask{ } } if(thecount == 10 || thecount == 20){ - for(Player player : plugin.getServer().getOnlinePlayers()){ + for(Player player : playerlist){ if(player != null && player.getHealth() > 0 && player.getHealth() < 20 && mcUsers.getProfile(player).getPowerLevel() >= 500 @@ -40,7 +36,7 @@ public class mcTimer extends TimerTask{ } } if(thecount == 20){ - for(Player player : plugin.getServer().getOnlinePlayers()){ + for(Player player : playerlist){ if(player != null && player.getHealth() > 0 && player.getHealth() < 20 && mcUsers.getProfile(player).getPowerLevel() < 500 @@ -50,8 +46,8 @@ public class mcTimer extends TimerTask{ } } } - for(Player player : plugin.getServer().getOnlinePlayers()){ - if(player != null){ + for(Player player : playerlist){ + if(player != null && mcUsers.getProfile(player).getRecentlyHurt() >= 1){ mcUsers.getProfile(player).decreaseLastHurt(); } } @@ -63,6 +59,6 @@ public class mcTimer extends TimerTask{ } else { thecount = 1; } - mcm.getInstance().bleedSimulate(plugin); + mcCombat.getInstance().bleedSimulate(); } } diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index 324f3b441..e21104f80 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -8,6 +8,7 @@ import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.entity.*; +import org.bukkit.plugin.Plugin; public class mcUsers { private static volatile mcUsers instance; @@ -1239,8 +1240,12 @@ class PlayerList return false; } } - public String getMySpawnWorld(){ - return myspawnworld; + public String getMySpawnWorld(Plugin plugin){ + if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){ + return myspawnworld; + } else { + return plugin.getServer().getWorlds().get(0).toString(); + } } //Save a users spawn location public void setMySpawn(double x, double y, double z, String myspawnworldlocation){ diff --git a/mcMMO/com/gmail/nossr50/mcWoodCutting.java b/mcMMO/com/gmail/nossr50/mcWoodCutting.java new file mode 100644 index 000000000..ac1fc2974 --- /dev/null +++ b/mcMMO/com/gmail/nossr50/mcWoodCutting.java @@ -0,0 +1,59 @@ +package com.gmail.nossr50; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class mcWoodCutting { + private static mcMMO plugin; + public mcWoodCutting(mcMMO instance) { + plugin = instance; + } + private static volatile mcWoodCutting instance; + public static mcWoodCutting getInstance() { + if (instance == null) { + instance = new mcWoodCutting(plugin); + } + return instance; + } + public void woodCuttingProcCheck(Player player, Block block, Location loc){ + byte type = block.getData(); + Material mat = Material.getMaterial(block.getTypeId()); + byte damage = 0; + if(mcUsers.getProfile(player).getWoodCuttingInt() > 1000){ + ItemStack item = new ItemStack(mat, 1, type, damage); + loc.getWorld().dropItemNaturally(loc, item); + return; + } + if(mcUsers.getProfile(player).getWoodCuttingInt() > 750){ + if((Math.random() * 10) > 2){ + ItemStack item = new ItemStack(mat, 1, type, damage); + loc.getWorld().dropItemNaturally(loc, item); + return; + } + } + if(mcUsers.getProfile(player).getWoodCuttingInt() > 300){ + if((Math.random() * 10) > 4){ + ItemStack item = new ItemStack(mat, 1, type, damage); + loc.getWorld().dropItemNaturally(loc, item); + return; + } + } + if(mcUsers.getProfile(player).getWoodCuttingInt() > 100){ + if((Math.random() * 10) > 6){ + ItemStack item = new ItemStack(mat, 1, type, damage); + loc.getWorld().dropItemNaturally(loc, item); + return; + } + } + if(mcUsers.getProfile(player).getWoodCuttingInt() > 10){ + if((Math.random() * 10) > 8){ + ItemStack item = new ItemStack(mat, 1, type, damage); + loc.getWorld().dropItemNaturally(loc, item); + return; + } + } + } +} diff --git a/mcMMO/com/gmail/nossr50/mcm.java b/mcMMO/com/gmail/nossr50/mcm.java index 1b6aa8791..9405f4ad7 100644 --- a/mcMMO/com/gmail/nossr50/mcm.java +++ b/mcMMO/com/gmail/nossr50/mcm.java @@ -4,38 +4,17 @@ import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.server.Packet38EntityStatus; - import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.entity.Animals; -import org.bukkit.entity.Item; -import org.bukkit.entity.Cow; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Pig; -import org.bukkit.entity.PigZombie; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Spider; -import org.bukkit.entity.Squid; -import org.bukkit.entity.Zombie; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import org.bukkit.craftbukkit.entity.CraftPlayer; - public class mcm { /* * I'm storing my functions/methods in here in an unorganized manner. Spheal with it. @@ -105,46 +84,14 @@ public class mcm { return false; } } - - public void sendDamagedLookPackets(Entity damaged){ - for(Player x : plugin.getServer().getOnlinePlayers()){ - if(x != null && damaged != null){ - CraftPlayer cp = (CraftPlayer)x; - if(cp != null && x != null && damaged != null && x.getEntityId() != damaged.getEntityId()) - cp.getHandle().a.b(new Packet38EntityStatus(damaged.getEntityId(), (byte)2)); - } + public boolean shouldBeWatched(Block block){ + int id = block.getTypeId(); + if(id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40){ + return true; + } else { + return false; } } - public void sendDeathLookPackets(Entity damaged){ - for(Player x : plugin.getServer().getOnlinePlayers()){ - CraftPlayer cp = (CraftPlayer)x; - if(x.getEntityId() != damaged.getEntityId()) - cp.getHandle().a.b(new Packet38EntityStatus(damaged.getEntityId(), (byte)3)); - } - } - public boolean inSameParty(Player playera, Player playerb){ - if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ - return true; - } else { - return false; - } - } - public boolean hasArrows(Player player){ - for(ItemStack x : player.getInventory().getContents()){ - if (x.getTypeId() == 262){ - return true; - } - } - return false; - } - public void addArrows(Player player){ - for(ItemStack x : player.getInventory().getContents()){ - if (x.getTypeId() == 262){ - x.setAmount(x.getAmount() + 1); - return; - } - } - } public Integer calculateHealth(Integer health, Integer newvalue){ if((health + newvalue) > 20){ return 20; @@ -173,91 +120,6 @@ public class mcm { return 0; } } - public void bleedSimulate(Plugin plugin){ - for(Entity x : mcConfig.getInstance().getBleedTracked()){ - if(x == null) - continue; - if(!mcConfig.getInstance().isBleedTracked(x)) - continue; - if(getHealth(x) <= 0) - continue; - if(x instanceof Animals){ - Animals animals = (Animals)x; - if(animals.getHealth() >= 1){ - animals.setHealth(calculateMinusHealth(animals.getHealth(), 2)); - mcm.getInstance().sendDamagedLookPackets(x); - } - if(animals.getHealth() <= 0){ - mcm.getInstance().simulateNaturalDrops(x); - } - } - - if(x instanceof Monster){ - Monster monster = (Monster)x; - if(monster.getHealth() >= 1){ - mcm.getInstance().sendDamagedLookPackets(x); - monster.setHealth(calculateMinusHealth(monster.getHealth(), 2)); - } - if(monster.getHealth() <= 0){ - mcm.getInstance().simulateNaturalDrops(x); - } - } - - if(x instanceof Player){ - Player player = (Player)x; - if(player.getHealth() >= 1 && mcUsers.getProfile(player).getBleedTicks() >= 1){ - player.setHealth(calculateMinusHealth(player.getHealth(), 1)); - mcm.getInstance().sendDamagedLookPackets(x); - player.sendMessage(ChatColor.RED+"**BLEED**"); - if(player.getHealth() <= 0){ - mcUsers.getProfile(player).setBleedTicks(0); - for(ItemStack items : player.getInventory().getContents()){ - if(items.getTypeId() != 0) - player.getLocation().getWorld().dropItemNaturally(player.getLocation(), items); - } - } - if(mcUsers.getProfile(player).getBleedTicks() >= 1){ - mcUsers.getProfile(player).setBleedTicks(mcUsers.getProfile(player).getBleedTicks() - 1); - } - } - } - } - } - public boolean isSkill(String skillname){ - 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; - } - } public boolean isInt(String string){ try { int x = Integer.parseInt(string); @@ -267,296 +129,6 @@ public class mcm { } return true; } - public void arrowRetrievalCheck(Entity entity){ - if(mcConfig.getInstance().isTracked(entity)){ - Integer x = 0; - while(x < mcConfig.getInstance().getArrowCount(entity)){ - mcDropItem(entity.getLocation(), 262); - x++; - } - } - } - public void archeryCheck(EntityDamageByProjectileEvent event){ - Entity y = event.getDamager(); - Entity x = event.getEntity(); - /* - * Defender is player - */ - if(y instanceof Player){ - Player attacker = (Player)y; - if(event.getProjectile().toString().equals("CraftArrow") && mcPermissions.getInstance().archery(attacker)){ - if(!mcConfig.getInstance().isTracked(x) && event.getDamage() > 0){ - mcConfig.getInstance().addArrowTrack(x, 0); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 200){ - if(Math.random() * 10 > 8){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 200 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ - if(Math.random() * 10 > 6){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 400 && mcUsers.getProfile(attacker).getArcheryInt() < 600){ - if(Math.random() * 10 > 4){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 600 && mcUsers.getProfile(attacker).getArcheryInt() < 800){ - if(Math.random() * 10 > 2){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 800){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else { - if(event.getDamage() > 0){ - if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 200){ - if(Math.random() * 10 > 8){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 200 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ - if(Math.random() * 10 > 6){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 400 && mcUsers.getProfile(attacker).getArcheryInt() < 600){ - if(Math.random() * 10 > 4){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 600 && mcUsers.getProfile(attacker).getArcheryInt() < 800){ - if(Math.random() * 10 > 2){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } else if(mcUsers.getProfile(attacker).getArcheryInt() >= 800){ - mcConfig.getInstance().addArrowCount(x, 1); - } - } - } - /* - * Defender is Monster - */ - if(x instanceof Monster){ - Monster defender = (Monster)x; - /* - * TRACK ARROWS USED AGAINST THE ENTITY - */ - int healthbefore = defender.getHealth(); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 1)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 2)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 3)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 4)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 5)); - //If it only would've died from mcMMO damage modifiers - if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ - mcm.getInstance().sendDeathLookPackets(defender); - simulateNaturalDrops(defender); - } - //XP - if(!mcConfig.getInstance().isMobSpawnTracked(x)){ - if(x instanceof Creeper) - mcUsers.getProfile(attacker).addArcheryGather(10); - if(x instanceof Spider) - mcUsers.getProfile(attacker).addArcheryGather(7); - if(x instanceof Skeleton) - mcUsers.getProfile(attacker).addArcheryGather(5); - if(x instanceof Zombie) - mcUsers.getProfile(attacker).addArcheryGather(3); - if(x instanceof PigZombie) - mcUsers.getProfile(attacker).addArcheryGather(7); - } - if(mcUsers.getProfile(attacker).getArcheryGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("archery")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getArcheryGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("archery")){ - skillups++; - mcUsers.getProfile(attacker).removeArcheryGather(mcUsers.getProfile(attacker).getXpToLevel("archery")); - mcUsers.getProfile(attacker).skillUpArchery(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getArchery()+")"); - } - } - /* - * Defender is Animals - */ - if(x instanceof Animals){ - Animals defender = (Animals)x; - int healthbefore = defender.getHealth(); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 1)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 2)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 3)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 4)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 5)); - //If it only would've died from mcMMO damage modifiers - if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ - mcm.getInstance().sendDeathLookPackets(defender); - simulateNaturalDrops(defender); - } - } - /* - * Defender is Squid - */ - if(x instanceof Squid){ - Squid defender = (Squid)x; - int healthbefore = defender.getHealth(); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 1)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 2)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 3)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 4)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 5)); - //If it only would've died from mcMMO damage modifiers - if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ - mcm.getInstance().sendDeathLookPackets(defender); - simulateNaturalDrops(defender); - } - } - /* - * Attacker is Player - */ - if(x instanceof Player){ - if(mcLoadProperties.pvp == false){ - event.setCancelled(true); - return; - } - Player defender = (Player)x; - /* - * Stuff for the daze proc - */ - if(mcUsers.getProfile(attacker).inParty() && mcUsers.getProfile(defender).inParty()){ - if(mcm.getInstance().inSameParty(defender, attacker)){ - event.setCancelled(true); - return; - } - } - Location loc = defender.getLocation(); - if(Math.random() * 10 > 5){ - loc.setPitch(90); - } else { - loc.setPitch(-90); - } - /* - * Check the proc - */ - if(mcUsers.getProfile(attacker).getArcheryInt() >= 300 && mcUsers.getProfile(attacker).getArcheryInt() < 400){ - if(Math.random() * 10 > 7){ - defender.teleportTo(loc); - defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); - attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); - } - } - if(mcUsers.getProfile(attacker).getArcheryInt() >= 600){ - if(Math.random() * 10 > 4){ - defender.teleportTo(loc); - defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); - attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); - } - } - int healthbefore = defender.getHealth(); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 50 && mcUsers.getProfile(attacker).getArcheryInt() < 250) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 1)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 250 && mcUsers.getProfile(attacker).getArcheryInt() < 575) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 2)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 575 && mcUsers.getProfile(attacker).getArcheryInt() < 725) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 3)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 725 && mcUsers.getProfile(attacker).getArcheryInt() < 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 4)); - if(mcUsers.getProfile(attacker).getArcheryInt() >= 1000) - defender.setHealth(mcm.getInstance().calculateDamage(defender, 5)); - //If it only would've died from mcMMO damage modifiers - if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ - mcm.getInstance().sendDeathLookPackets(defender); - simulateNaturalDrops(defender); - } - - if(mcUsers.getProfile(defender).isDead()) - return; - /* - if(defender.getHealth() - event.getDamage() <= 0){ - for(Player derp : plugin.getServer().getOnlinePlayers()){ - derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName() + " with the bow and arrow."); - mcUsers.getProfile(defender).setDead(true); - } - } - */ - } - } - } - } - public void acrobaticsCheck(Player player, EntityDamageEvent event, Location loc, int xx, int y, int z){ - if(mcUsers.getProfile(player).getAcrobaticsInt() >= 50 - && mcUsers.getProfile(player).getAcrobaticsInt() < 250 - && mcPermissions.getInstance().acrobatics(player)){ - if(Math.random() * 10 > 8){ - event.setCancelled(true); - player.sendMessage("**ROLLED**"); - return; - } - } - if(mcUsers.getProfile(player).getAcrobaticsInt() >= 250 - && mcUsers.getProfile(player).getAcrobaticsInt() < 450 - && mcPermissions.getInstance().acrobatics(player)){ - if(Math.random() * 10 > 6){ - event.setCancelled(true); - player.sendMessage("**ROLLED**"); - return; - } - } - if(mcUsers.getProfile(player).getAcrobaticsInt() >= 450 - && mcUsers.getProfile(player).getAcrobaticsInt() < 750 - && mcPermissions.getInstance().acrobatics(player)){ - if(Math.random() * 10 > 4){ - event.setCancelled(true); - player.sendMessage("**ROLLED**"); - return; - } - } - if(mcUsers.getProfile(player).getAcrobaticsInt() >= 750 - && mcUsers.getProfile(player).getAcrobaticsInt() < 950 - && mcPermissions.getInstance().acrobatics(player)){ - if(Math.random() * 10 > 2){ - event.setCancelled(true); - player.sendMessage("**BARREL ROLLED**"); - return; - } - } - if(mcUsers.getProfile(player).getAcrobaticsInt() >= 950 - && mcPermissions.getInstance().acrobatics(player)){ - event.setCancelled(true); - player.sendMessage("**ROLLED... LIKE A BOSS**"); - return; - } - if(player.getHealth() - event.getDamage() <= 0) - return; - if(!mcConfig.getInstance().isBlockWatched(loc.getWorld().getBlockAt(xx, y, z)) - && mcPermissions.getInstance().acrobatics(player)){ - mcUsers.getProfile(player).addAcrobaticsGather(event.getDamage() * 3); - if(mcUsers.getProfile(player).getAcrobaticsGatherInt() >= mcUsers.getProfile(player).getXpToLevel("acrobatics")){ - int skillups = 0; - while(mcUsers.getProfile(player).getAcrobaticsGatherInt() >= mcUsers.getProfile(player).getXpToLevel("acrobatics")){ - skillups++; - mcUsers.getProfile(player).removeAcrobaticsGather(mcUsers.getProfile(player).getXpToLevel("acrobatics")); - mcUsers.getProfile(player).skillUpAcrobatics(1); - } - player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getAcrobatics()+")"); - } - mcConfig.getInstance().addBlockWatch(loc.getWorld().getBlockAt(xx, y, z)); - if(player.getHealth() - event.getDamage() <= 0){ - if(mcUsers.getProfile(player).isDead()) - return; - mcUsers.getProfile(player).setDead(true); - } - } - } public void simulateNaturalDrops(Entity entity){ Location loc = entity.getLocation(); if(entity instanceof Pig){ @@ -619,7 +191,7 @@ public class mcm { mcDropItem(loc, 351); } } - arrowRetrievalCheck(entity); + mcSkills.getInstance().arrowRetrievalCheck(entity); } public void mcDropItem(Location loc, int id){ if(loc != null){ @@ -629,271 +201,7 @@ public class mcm { loc.getWorld().dropItemNaturally(loc, item); } } - public boolean checkPlayerProcRepair(Player player){ - if(mcUsers.getProfile(player).getRepairInt() >= 750){ - if(Math.random() * 10 > 2){ - player.sendMessage(ChatColor.GRAY + "That took no effort."); - return true; - } - } else if (mcUsers.getProfile(player).getRepairInt() >= 450 && mcUsers.getProfile(player).getRepairInt() < 750){ - if(Math.random() * 10 > 4){ - player.sendMessage(ChatColor.GRAY + "That felt really easy."); - return true; - } - } else if (mcUsers.getProfile(player).getRepairInt() >= 150 && mcUsers.getProfile(player).getRepairInt() < 450){ - if(Math.random() * 10 > 6){ - player.sendMessage(ChatColor.GRAY + "That felt pretty easy."); - return true; - } - } else if (mcUsers.getProfile(player).getRepairInt() >= 50 && mcUsers.getProfile(player).getRepairInt() < 150){ - if(Math.random() * 10 > 8){ - player.sendMessage(ChatColor.GRAY + "That felt easy."); - return true; - } - } - return false; - } - - //This determines how much we repair - public short getArmorRepairAmount(ItemStack is, Player player){ - short durability = is.getDurability(); - switch(is.getTypeId()) - { - case 306: - durability -= 27; - break; - case 310: - durability -= 55; - break; - case 307: - durability -= 24; - break; - case 311: - durability -= 48; - break; - case 308: - durability -= 27; - break; - case 312: - durability -= 53; - break; - case 309: - durability -= 40; - break; - case 313: - durability -= 80; - break; - } - if(durability < 0) - durability = 0; - if(checkPlayerProcRepair(player)) - durability = 0; - return durability; - } - public short getToolRepairAmount(ItemStack is, short durability, Player player){ - //IRON SHOVEL - if(is.getTypeId() == 256){ - return 0; //full repair - } - //DIAMOND SHOVEL - if(is.getTypeId() == 277){ - return 0; //full repair - } - //IRON TOOLS - if(is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292){ - if(durability < 84){ - return 0; - }else { - if(checkPlayerProcRepair(player)) - return 0; - return (short) (durability-84); - } - //DIAMOND TOOLS - } else if(is.getTypeId() == 276 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293){ - if(durability < 509){ - return 0; - } else { - if(checkPlayerProcRepair(player)) - return 0; - return (short) (durability-509); - } - } else { - return durability; - } - } - public void blockProcSimulate(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() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16) - loc.getWorld().dropItemNaturally(loc, item); - //hurrdurr - 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 void blockProcCheck(Block block, Player player){ - if(mcUsers.getProfile(player).getMiningInt() > 3000){ - blockProcSimulate(block); - return; - } - if(mcUsers.getProfile(player).getMiningInt() > 2000){ - if((Math.random() * 10) > 2){ - blockProcSimulate(block); - return; - } - } - if(mcUsers.getProfile(player).getMiningInt() > 750){ - if((Math.random() * 10) > 4){ - blockProcSimulate(block); - return; - } - } - if(mcUsers.getProfile(player).getMiningInt() > 150){ - if((Math.random() * 10) > 6){ - blockProcSimulate(block); - return; - } - } - if(mcUsers.getProfile(player).getMiningInt() > 25){ - if((Math.random() * 10) > 8){ - blockProcSimulate(block); - return; - } - } - - } - public void miningBlockCheck(Player player, Block block){ - if(block.getTypeId() == 1){ - mcUsers.getProfile(player).addMiningGather(1); - mcm.getInstance().blockProcCheck(block, player); - } - //COAL - if(block.getTypeId() == 16){ - mcUsers.getProfile(player).addMiningGather(3); - mcm.getInstance().blockProcCheck(block, player); - } - //GOLD - if(block.getTypeId() == 14){ - mcUsers.getProfile(player).addMiningGather(20); - mcm.getInstance().blockProcCheck(block, player); - } - //DIAMOND - if(block.getTypeId() == 56){ - mcUsers.getProfile(player).addMiningGather(50); - mcm.getInstance().blockProcCheck(block, player); - } - //IRON - if(block.getTypeId() == 15){ - mcUsers.getProfile(player).addMiningGather(10); - mcm.getInstance().blockProcCheck(block, player); - } - //REDSTONE - if(block.getTypeId() == 73 || block.getTypeId() == 74){ - mcUsers.getProfile(player).addMiningGather(10); - mcm.getInstance().blockProcCheck(block, player); - } - //LAPUS - if(block.getTypeId() == 21){ - mcUsers.getProfile(player).addMiningGather(20); - mcm.getInstance().blockProcCheck(block, player); - } - if(mcUsers.getProfile(player).getMiningGatherInt() >= mcUsers.getProfile(player).getXpToLevel("mining")){ - int skillups = 0; - while(mcUsers.getProfile(player).getMiningGatherInt() >= mcUsers.getProfile(player).getXpToLevel("mining")){ - skillups++; - mcUsers.getProfile(player).removeMiningGather(mcUsers.getProfile(player).getXpToLevel("mining")); - mcUsers.getProfile(player).skillUpMining(1); - } - player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getMining()+")"); - } - } - public void breadCheck(Player player, ItemStack is){ - if(is.getTypeId() == 297){ - if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ - player.setHealth(player.getHealth() + 1); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){ - player.setHealth(player.getHealth() + 2); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 250 && mcUsers.getProfile(player).getHerbalismInt() < 350){ - player.setHealth(player.getHealth() + 3); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 450){ - player.setHealth(player.getHealth() + 4); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 450 && mcUsers.getProfile(player).getHerbalismInt() < 550){ - player.setHealth(player.getHealth() + 5); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 550 && mcUsers.getProfile(player).getHerbalismInt() < 650){ - player.setHealth(player.getHealth() + 6); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 650 && mcUsers.getProfile(player).getHerbalismInt() < 750){ - player.setHealth(player.getHealth() + 7); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ - player.setHealth(player.getHealth() + 8); - } - } - } - public void stewCheck(Player player, ItemStack is){ - if(is.getTypeId() == 282){ - if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ - player.setHealth(player.getHealth() + 1); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){ - player.setHealth(player.getHealth() + 2); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 250 && mcUsers.getProfile(player).getHerbalismInt() < 350){ - player.setHealth(player.getHealth() + 3); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 450){ - player.setHealth(player.getHealth() + 4); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 450 && mcUsers.getProfile(player).getHerbalismInt() < 550){ - player.setHealth(player.getHealth() + 5); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 550 && mcUsers.getProfile(player).getHerbalismInt() < 650){ - player.setHealth(player.getHealth() + 6); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 650 && mcUsers.getProfile(player).getHerbalismInt() < 750){ - player.setHealth(player.getHealth() + 7); - } else if (mcUsers.getProfile(player).getHerbalismInt() >= 750){ - player.setHealth(player.getHealth() + 8); - } - } - } - public void needMoreVespeneGas(ItemStack is, Player player){ - if ((mcm.getInstance().isDiamondTools(is) || mcm.getInstance().isDiamondArmor(is) ) && mcUsers.getProfile(player).getRepairInt() < 50){ - player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); - } else if (mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player) || mcm.getInstance().isIronTools(is) && !mcm.getInstance().hasIron(player)){ - if(mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player)) - player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); - if(mcm.getInstance().isIronTools(is) && !mcm.getInstance().hasIron(player)) - player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); - } else if (mcm.getInstance().isDiamondArmor(is) && !mcm.getInstance().hasDiamond(player)){ - player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); - } else if (mcm.getInstance().isIronArmor(is) && !mcm.getInstance().hasIron(player)) - player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); - } + public boolean isSwords(ItemStack is){ if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276){ return true; @@ -908,665 +216,7 @@ public class mcm { return false; } } - public boolean simulateUnarmedProc(Player player){ - if(mcUsers.getProfile(player).getUnarmedInt() >= 750){ - if(Math.random() * 10 > 4){ - return true; - } - }if(mcUsers.getProfile(player).getUnarmedInt() >= 350 && mcUsers.getProfile(player).getUnarmedInt() < 750){ - if(Math.random() * 10 > 4){ - return true; - } - } - return false; - } - public void bleedCheck(Player attacker, Entity x){ - if(mcm.getInstance().isSwords(attacker.getItemInHand()) && !mcConfig.getInstance().isBleedTracked(x)){ - if(mcUsers.getProfile(attacker).getSwordsInt() >= 50 && mcUsers.getProfile(attacker).getSwordsInt() < 200){ - if(Math.random() * 10 > 8){ - mcConfig.getInstance().addBleedTrack(x); - if(x instanceof Player){ - Player target = (Player)x; - mcUsers.getProfile(target).setBleedTicks(4); - } - attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); - } - } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 200 && mcUsers.getProfile(attacker).getSwordsInt() < 600){ - if(Math.random() * 10 > 6){ - mcConfig.getInstance().addBleedTrack(x); - if(x instanceof Player){ - Player target = (Player)x; - mcUsers.getProfile(target).setBleedTicks(4); - } - attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); - } - } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 600 && mcUsers.getProfile(attacker).getSwordsInt() < 900){ - if(Math.random() * 10 > 4){ - mcConfig.getInstance().addBleedTrack(x); - if(x instanceof Player){ - Player target = (Player)x; - mcUsers.getProfile(target).setBleedTicks(6); - } - attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); - } - } else if(mcUsers.getProfile(attacker).getSwordsInt() >= 900){ - if(Math.random() * 100 > 25){ - mcConfig.getInstance().addBleedTrack(x); - if(x instanceof Player){ - Player target = (Player)x; - mcUsers.getProfile(target).setBleedTicks(6); - } - attacker.sendMessage(ChatColor.RED+"**Your target is bleeding**"); - } - } - } - } - public void playerVersusPlayerChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, Plugin plugin){ - if(x instanceof Player){ - if(mcLoadProperties.pvp == false){ - event.setCancelled(true); - return; - } - Player defender = (Player)x; - if(mcUsers.getProfile(attacker).inParty() && mcUsers.getProfile(defender).inParty()){ - if(inSameParty(defender, attacker)){ - event.setCancelled(true); - return; - } - } - mcUsers.getProfile(defender).setRecentlyHurt(30); - /* - * AXE CRITICAL CHECK - */ - axeCriticalCheckPlayer(attacker, event, x, plugin); - if(!mcConfig.getInstance().isBleedTracked(x)){ - bleedCheck(attacker, x); - } - int healthbefore = defender.getHealth(); - if(mcPermissions.getInstance().unarmed(attacker) && attacker.getItemInHand().getTypeId() == 0){ - //DMG MODIFIER - if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ - defender.setHealth(calculateDamage(defender, 1)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ - defender.setHealth(calculateDamage(defender, 2)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ - defender.setHealth(calculateDamage(defender, 3)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ - defender.setHealth(calculateDamage(defender, 4)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ - defender.setHealth(calculateDamage(defender, 5)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ - defender.setHealth(calculateDamage(defender, 6)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ - defender.setHealth(calculateDamage(defender, 7)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ - defender.setHealth(calculateDamage(defender, 8)); - } - if(mcUsers.getProfile(defender).isDead()) - return; - //PROC - if(simulateUnarmedProc(attacker)){ - Location loc = defender.getLocation(); - if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0){ - attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force."); - defender.sendMessage(ChatColor.DARK_RED+"You have been disarmed!"); - ItemStack item = defender.getItemInHand(); - if(item != null){ - loc.getWorld().dropItemNaturally(loc, item); - Material mat; - mat = Material.getMaterial(0); - ItemStack itemx = null; - defender.setItemInHand(itemx); - } - } - } - } - /* - * Make the defender drop items on death - */ - if(defender.getHealth()<= 0 && !mcUsers.getProfile(defender).isDead()){ - mcUsers.getProfile(defender).setDead(true); - event.setCancelled(true); //SEE IF THIS HELPS - //If it only would've died from mcMMO damage modifiers - if(defender.getHealth() <= 0 && healthbefore - event.getDamage() >= 1){ - mcm.getInstance().sendDeathLookPackets(defender); - simulateNaturalDrops(defender); - } - for(ItemStack herp : defender.getInventory().getContents()){ - if(herp != null && herp.getTypeId() != 0) - defender.getLocation().getWorld().dropItemNaturally(defender.getLocation(), herp); - } - } - if(mcUsers.getProfile(defender).isDead()) - return; - if((mcUsers.getProfile(defender).inParty() && mcUsers.getProfile(attacker).inParty())&& mcUsers.getProfile(defender).getParty().equals(mcUsers.getProfile(attacker).getParty())) - event.setCancelled(true); - } - } - public void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ - if(x instanceof Squid){ - if(!mcConfig.getInstance().isBleedTracked(x)){ - bleedCheck(attacker, x); - } - Squid defender = (Squid)event.getEntity(); - if(isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ - mcUsers.getProfile(attacker).addSwordsGather(10); - if(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ - skillups++; - mcUsers.getProfile(attacker).removeSwordsGather(mcUsers.getProfile(attacker).getXpToLevel("swords")); - mcUsers.getProfile(attacker).skillUpSwords(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getSwords()+")"); - } - } - if(isAxes(attacker.getItemInHand()) - && defender.getHealth() > 0 - && mcPermissions.getInstance().axes(attacker)){ - mcUsers.getProfile(attacker).addAxesGather(10); - if(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ - skillups++; - mcUsers.getProfile(attacker).removeAxesGather(mcUsers.getProfile(attacker).getXpToLevel("axes")); - mcUsers.getProfile(attacker).skillUpAxes(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getAxes()+")"); - } - } - if(isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(defender.getHealth() <= 0) - return; - if(mcUsers.getProfile(attacker).getAxesInt() >= 500){ - defender.setHealth(calculateDamage(defender, (4 - axeNerf(attacker.getItemInHand().getTypeId())))); - } - if(defender.getHealth() <= 0) - mcm.getInstance().simulateNaturalDrops(defender); - } - /* - * UNARMED VS SQUID - */ - if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ - if(defender.getHealth() <= 0) - return; - if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ - defender.setHealth(calculateDamage(defender, 1)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ - defender.setHealth(calculateDamage(defender, 2)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ - defender.setHealth(calculateDamage(defender, 3)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ - defender.setHealth(calculateDamage(defender, 4)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ - defender.setHealth(calculateDamage(defender, 5)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ - defender.setHealth(calculateDamage(defender, 6)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ - defender.setHealth(calculateDamage(defender, 7)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ - defender.setHealth(calculateDamage(defender, 8)); - } - //XP - if(defender.getHealth() != 0){ - mcUsers.getProfile(attacker).addUnarmedGather(10); - if(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ - skillups++; - mcUsers.getProfile(attacker).removeUnarmedGather(mcUsers.getProfile(attacker).getXpToLevel("unarmed")); - mcUsers.getProfile(attacker).skillUpUnarmed(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getUnarmed()+")"); - } - } - if(defender.getHealth() <= 0) - mcm.getInstance().simulateNaturalDrops(defender); - } - } - } - public void playerVersusAnimalsChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, int type){ - if(x instanceof Animals){ - if(!mcConfig.getInstance().isBleedTracked(x)){ - bleedCheck(attacker, x); - } - Animals defender = (Animals)event.getEntity(); - if(isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(defender.getHealth() <= 0) - return; - if(mcUsers.getProfile(attacker).getAxesInt() >= 500){ - defender.setHealth(calculateDamage(defender, (4 - axeNerf(attacker.getItemInHand().getTypeId())))); - } - if(defender.getHealth() <= 0) - mcm.getInstance().simulateNaturalDrops(defender); - } - if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ - if(defender.getHealth() <= 0) - return; - if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ - defender.setHealth(calculateDamage(defender, 1)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ - defender.setHealth(calculateDamage(defender, 2)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ - defender.setHealth(calculateDamage(defender, 3)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ - defender.setHealth(calculateDamage(defender, 4)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ - defender.setHealth(calculateDamage(defender, 5)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ - defender.setHealth(calculateDamage(defender, 6)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ - defender.setHealth(calculateDamage(defender, 7)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ - defender.setHealth(calculateDamage(defender, 8)); - } - if(defender.getHealth() <= 0){ - mcm.getInstance().simulateNaturalDrops(defender); - } - } - } - } - public void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ - if(x instanceof Monster){ - /* - * AXE PROC CHECKS - */ - axeCriticalCheckMonster(attacker, event, x); - if(!mcConfig.getInstance().isBleedTracked(x)){ - bleedCheck(attacker, x); - } - Monster defender = (Monster)event.getEntity(); - if(isSwords(attacker.getItemInHand()) - && defender.getHealth() > 0 - && mcPermissions.getInstance().swords(attacker)){ - if(!mcConfig.getInstance().isMobSpawnTracked(x)){ - if(x instanceof Creeper) - mcUsers.getProfile(attacker).addSwordsGather(10); - if(x instanceof Spider) - mcUsers.getProfile(attacker).addSwordsGather(7); - if(x instanceof Skeleton) - mcUsers.getProfile(attacker).addSwordsGather(5); - if(x instanceof Zombie) - mcUsers.getProfile(attacker).addSwordsGather(3); - if(x instanceof PigZombie) - mcUsers.getProfile(attacker).addSwordsGather(7); - } - if(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getSwordsGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("swords")){ - skillups++; - mcUsers.getProfile(attacker).removeSwordsGather(mcUsers.getProfile(attacker).getXpToLevel("swords")); - mcUsers.getProfile(attacker).skillUpSwords(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getSwords()+")"); - } - } - if(isAxes(attacker.getItemInHand()) - && defender.getHealth() > 0 - && mcPermissions.getInstance().axes(attacker)){ - if(!mcConfig.getInstance().isMobSpawnTracked(x)){ - mcUsers.getProfile(attacker).addAxesGather(1); - if(x instanceof Creeper) - mcUsers.getProfile(attacker).addAxesGather(10); - if(x instanceof Spider) - mcUsers.getProfile(attacker).addAxesGather(7); - if(x instanceof Skeleton) - mcUsers.getProfile(attacker).addAxesGather(5); - if(x instanceof Zombie) - mcUsers.getProfile(attacker).addAxesGather(3); - if(x instanceof PigZombie) - mcUsers.getProfile(attacker).addAxesGather(7); - } - if(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getAxesGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("axes")){ - skillups++; - mcUsers.getProfile(attacker).removeAxesGather(mcUsers.getProfile(attacker).getXpToLevel("axes")); - mcUsers.getProfile(attacker).skillUpAxes(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getAxes()+")"); - } - } - /* - * AXE DAMAGE SCALING && LOOT CHECKS - */ - if(isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(defender.getHealth() <= 0) - return; - if(mcUsers.getProfile(attacker).getAxesInt() >= 500){ - defender.setHealth(calculateDamage(defender, (4 - axeNerf(attacker.getItemInHand().getTypeId())))); - } - if(defender.getHealth() <= 0 || defender.getHealth() - event.getDamage() <= 0){ - simulateNaturalDrops(defender); - } - } - if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ - if(defender.getHealth() <= 0) - return; - if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ - defender.setHealth(calculateDamage(defender, 1)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 100 && mcUsers.getProfile(attacker).getUnarmedInt() < 200){ - defender.setHealth(calculateDamage(defender, 2)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 200 && mcUsers.getProfile(attacker).getUnarmedInt() < 325){ - defender.setHealth(calculateDamage(defender, 3)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 325 && mcUsers.getProfile(attacker).getUnarmedInt() < 475){ - defender.setHealth(calculateDamage(defender, 4)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 475 && mcUsers.getProfile(attacker).getUnarmedInt() < 600){ - defender.setHealth(calculateDamage(defender, 5)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 600 && mcUsers.getProfile(attacker).getUnarmedInt() < 775){ - defender.setHealth(calculateDamage(defender, 6)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 775 && mcUsers.getProfile(attacker).getUnarmedInt() < 950){ - defender.setHealth(calculateDamage(defender, 7)); - } else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){ - defender.setHealth(calculateDamage(defender, 8)); - } - //XP - if(!mcConfig.getInstance().isMobSpawnTracked(x)){ - if(x instanceof Creeper) - mcUsers.getProfile(attacker).addUnarmedGather(20); - if(x instanceof Spider) - mcUsers.getProfile(attacker).addUnarmedGather(15); - if(x instanceof Skeleton) - mcUsers.getProfile(attacker).addUnarmedGather(10); - if(x instanceof Zombie) - mcUsers.getProfile(attacker).addUnarmedGather(5); - if(x instanceof PigZombie) - mcUsers.getProfile(attacker).addUnarmedGather(15); - } - if(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ - int skillups = 0; - while(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= mcUsers.getProfile(attacker).getXpToLevel("unarmed")){ - skillups++; - mcUsers.getProfile(attacker).removeUnarmedGather(mcUsers.getProfile(attacker).getXpToLevel("unarmed")); - mcUsers.getProfile(attacker).skillUpUnarmed(1); - } - attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getUnarmed()+")"); - } - if(defender.getHealth() <= 0 || defender.getHealth() - event.getDamage() <= 0){ - simulateNaturalDrops(defender); - } - } - } - } - public int axeNerf(int type){ - //GOLD OR WOOD - if(type == 271 || type == 286){ - return 3; - } else if (type == 258){ - return 1; - } else if (type == 275){ - return 1; - } else { - return 0; - } - } - public int calculateDamage(Player player, int dmg){ - int health = player.getHealth(); - if(health - dmg <0){ - return 0; - } else { - health-= dmg; - return health; - } - } - public int calculateDamage(Squid squid, int dmg){ - int health = squid.getHealth(); - if(health - dmg <0){ - return 0; - } else { - health-= dmg; - return health; - } - } - public int calculateDamage(Monster monster, int dmg){ - int health = monster.getHealth(); - if(health - dmg <0){ - return 0; - } else { - health-= dmg; - return health; - } - } - public int calculateDamage(Animals animal, int dmg){ - int health = animal.getHealth(); - if(health - dmg <0){ - return 0; - } else { - health-= dmg; - return health; - } - } - public void axeCriticalCheckAnimals(Player attacker, EntityDamageByEntityEvent event, Entity x){ - if(isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(mcUsers.getProfile(attacker).getAxesInt() >= 50 && mcUsers.getProfile(attacker).getAxesInt() < 250){ - if(Math.random() * 100 > 95){ - if(x instanceof Animals){ - Animals animal = (Animals)x; - animal.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 250 && mcUsers.getProfile(attacker).getAxesInt() < 500){ - if(Math.random() * 10 > 9){ - if(x instanceof Animals){ - Animals animal = (Animals)x; - animal.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 500 && mcUsers.getProfile(attacker).getAxesInt() < 750){ - if(Math.random() * 10 > 8){ - if(x instanceof Animals){ - Animals animal = (Animals)x; - animal.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 750 && mcUsers.getProfile(attacker).getAxesInt() < 1000){ - if(Math.random() * 10 > 7){ - if(x instanceof Animals){ - Animals animal = (Animals)x; - animal.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 1000){ - if(Math.random() * 10 > 6){ - if(x instanceof Animals){ - Animals animal = (Animals)x; - animal.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - } - } - public void axeCriticalCheckMonster(Player attacker, EntityDamageByEntityEvent event, Entity x){ - if(isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(mcUsers.getProfile(attacker).getAxesInt() >= 50 && mcUsers.getProfile(attacker).getAxesInt() < 250){ - if(Math.random() * 100 > 95){ - if(x instanceof Monster){ - Monster monster = (Monster)x; - monster.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 250 && mcUsers.getProfile(attacker).getAxesInt() < 500){ - if(Math.random() * 10 > 9){ - if(x instanceof Monster){ - Monster monster = (Monster)x; - monster.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 500 && mcUsers.getProfile(attacker).getAxesInt() < 750){ - if(Math.random() * 10 > 8){ - if(x instanceof Monster){ - Monster monster = (Monster)x; - monster.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 750 && mcUsers.getProfile(attacker).getAxesInt() < 1000){ - if(Math.random() * 10 > 7){ - if(x instanceof Monster){ - Monster monster = (Monster)x; - monster.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 1000){ - if(Math.random() * 10 > 6){ - if(x instanceof Monster){ - Monster monster = (Monster)x; - monster.setHealth(0); - simulateNaturalDrops(x); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - } - } - } - } - } - public void axeCriticalCheckPlayer(Player attacker, EntityDamageByEntityEvent event, Entity x, Plugin plugin){ - if(isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ - if(mcUsers.getProfile(attacker).getAxesInt() >= 50 && mcUsers.getProfile(attacker).getAxesInt() < 250){ - if(Math.random() * 100 > 95){ - if(x instanceof Player){ - Player player = (Player)x; - player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 250 && mcUsers.getProfile(attacker).getAxesInt() < 500){ - if(Math.random() * 10 > 9){ - if(x instanceof Player){ - Player player = (Player)x; - player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 500 && mcUsers.getProfile(attacker).getAxesInt() < 750){ - if(Math.random() * 10 > 8){ - if(x instanceof Player){ - Player player = (Player)x; - player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 750 && mcUsers.getProfile(attacker).getAxesInt() < 1000){ - if(Math.random() * 10 > 7){ - if(x instanceof Player){ - Player player = (Player)x; - player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - } - } - if(mcUsers.getProfile(attacker).getAxesInt() >= 1000){ - if(Math.random() * 10 > 6){ - if(x instanceof Player){ - Player player = (Player)x; - player.setHealth(calculateDamage(player, (player.getHealth() - event.getDamage()))); - attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!"); - player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!"); - } - } - } - if(x instanceof Player){ - Player defender = (Player)x; - if(defender.getHealth()<= 0 && !mcUsers.getProfile(defender).isDead()){ - mcUsers.getProfile(defender).setDead(true); - event.setCancelled(true); //SEE IF THIS HELPS - for(ItemStack herp : defender.getInventory().getContents()){ - if(herp != null && herp.getTypeId() != 0) - defender.getLocation().getWorld().dropItemNaturally(defender.getLocation(), herp); - } - for(Player derp : plugin.getServer().getOnlinePlayers()){ - derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"chopped "+ChatColor.GRAY+defender.getName() + " to death."); - mcUsers.getProfile(defender).setDead(true); - } - } - } - } - } - public void parryCheck(Player defender, EntityDamageByEntityEvent event, Entity y){ - if(isSwords(defender.getItemInHand()) - && event.getDamage() > 0 - && mcPermissions.getInstance().swords(defender)){ - if(mcUsers.getProfile(defender).getSwordsInt() >= 50 && mcUsers.getProfile(defender).getSwordsInt() < 250){ - if(Math.random() * 100 > 95){ - event.setCancelled(true); - defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); - defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - if(y instanceof Player){ - Player attacker = (Player)y; - attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); - } - return; - } - } - if(mcUsers.getProfile(defender).getSwordsInt() >= 250 && mcUsers.getProfile(defender).getSwordsInt() < 450){ - if(Math.random() * 100 > 90){ - event.setCancelled(true); - defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); - defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - if(y instanceof Player){ - Player attacker = (Player)y; - attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); - } - return; - } - } - if(mcUsers.getProfile(defender).getSwordsInt() >= 450 && mcUsers.getProfile(defender).getSwordsInt() < 775){ - if(Math.random() * 100 > 85){ - event.setCancelled(true); - defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); - defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - if(y instanceof Player){ - Player attacker = (Player)y; - attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); - } - return; - } - } - if(mcUsers.getProfile(defender).getSwordsInt() >= 775){ - if(Math.random() * 100 > 80){ - event.setCancelled(true); - defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); - defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - if(y instanceof Player){ - Player attacker = (Player)y; - attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); - } - return; - } - } - } - } + public void mcmmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ if(split[0].equalsIgnoreCase("/woodcutting")){ event.setCancelled(true); @@ -1670,434 +320,38 @@ public class mcm { } if(split[0].equalsIgnoreCase("/"+mcLoadProperties.mcc)){ event.setCancelled(true); - player.sendMessage(ChatColor.GRAY+"mcMMO has a party system included"); - player.sendMessage(ChatColor.GREEN+"~~Commands~~"); + player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mcMMO Commands"+ChatColor.RED+"[]---"); if(mcPermissions.getInstance().party(player)){ - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.party+" - to join a party"); - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.party+" q - to quit a party"); + player.sendMessage(ChatColor.GREEN+"--PARTY COMMANDS--"); + player.sendMessage("/"+mcLoadProperties.party+" [party name] "+ChatColor.RED+"- Create/Join designated party"); + player.sendMessage("/"+mcLoadProperties.party+" q "+ChatColor.RED+"- Leave your current party"); + if(mcPermissions.getInstance().partyChat(player)) + player.sendMessage("/p "+ChatColor.RED+" - Toggle Party Chat"); + player.sendMessage("/"+mcLoadProperties.invite+" [player name] "+ChatColor.RED+"- Send party invite"); + player.sendMessage("/"+mcLoadProperties.accept+" "+ChatColor.RED+"- Accept party invite"); + if(mcPermissions.getInstance().partyTeleport(player)) + player.sendMessage("/"+mcLoadProperties.ptp+" [party member name] "+ChatColor.RED+"- Teleport to party member"); } - if(mcPermissions.getInstance().partyTeleport(player)) - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.ptp+" - party teleport"); - if(mcPermissions.getInstance().partyChat(player)) - player.sendMessage(ChatColor.GRAY+"/p - toggles party chat"); - player.sendMessage(ChatColor.GREEN+"/"+mcLoadProperties.stats+ChatColor.GRAY+" - Check current skill levels"); - if(mcPermissions.getInstance().setMySpawn(player)) - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.setmyspawn+" - Sets your spawn"); if(mcPermissions.getInstance().mySpawn(player)){ - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.myspawn+" - travel to myspawn, clears inventory"); - player.sendMessage(ChatColor.GREEN+"/"+mcLoadProperties.clearmyspawn+" - resets your myspawn to default spawn location"); + player.sendMessage(ChatColor.GREEN+"--MYSPAWN COMMANDS--"); + player.sendMessage("/"+mcLoadProperties.myspawn+" "+ChatColor.RED+"- Teleports you to your MySpawn"); + player.sendMessage("/"+mcLoadProperties.clearmyspawn+" "+ChatColor.RED+"- Clears your MySpawn"); } - if(mcPermissions.getInstance().whois(player) || player.isOp()) - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.whois+" - view detailed info about a player (req op)"); - player.sendMessage(ChatColor.GRAY+"/woodcutting - Skill info"); - player.sendMessage(ChatColor.GRAY+"/mining - Skill info"); - player.sendMessage(ChatColor.GRAY+"/repair - Skill info"); - player.sendMessage(ChatColor.GRAY+"/unarmed - Skill info"); - player.sendMessage(ChatColor.GRAY+"/herbalism - Skill info"); - player.sendMessage(ChatColor.GRAY+"/excavation - Skill info"); - player.sendMessage(ChatColor.GRAY+"/archery - Skill info"); - player.sendMessage(ChatColor.GRAY+"/swords - Skill info"); - player.sendMessage(ChatColor.GRAY+"/acrobatics - Skill info"); - player.sendMessage(ChatColor.GRAY+"/axes - Skill info"); - player.sendMessage(ChatColor.GRAY+"/invite - Invite players to your party"); - player.sendMessage(ChatColor.GRAY+"/accept - Accept an invite"); - if(mcPermissions.getInstance().mmoedit(player)) - player.sendMessage(ChatColor.GRAY+"/"+mcLoadProperties.mmoedit+" - Modify mcMMO skills of players/yourself"); + if(mcPermissions.getInstance().adminChat(player)){ + player.sendMessage(ChatColor.GREEN+"--ADMIN COMMANDS--"); + player.sendMessage("/a "+ChatColor.RED+"- Toggle admin chat"); + } + player.sendMessage(ChatColor.GREEN+"--OTHER COMMANDS--"); + if(mcPermissions.getInstance().whois(player)) + player.sendMessage("/"+mcLoadProperties.whois+" [playername] "+ChatColor.RED+"- View detailed player info"); + if(mcPermissions.getInstance().mmoedit(player)){ + player.sendMessage("/"+mcLoadProperties.mmoedit+" [skill] [newvalue] "+ChatColor.RED+"Modify the designated skill value"); + player.sendMessage("/"+mcLoadProperties.mmoedit+" [playername] [skill] [newvalue] "+ChatColor.RED+"- Modify target"); + } + if(mcPermissions.getInstance().mcgod(player)) + player.sendMessage("/"+mcLoadProperties.mcgod+ChatColor.RED+" - God Mode"); + player.sendMessage("/[skillname] "+ChatColor.RED+" View detailed information about a skill"); + player.sendMessage("/"+mcLoadProperties.mcmmo+" "+ChatColor.RED+"- Read brief mod description"); } } - public void repairCheck(Player player, ItemStack is, Block block){ - if(block != null - && block.getTypeId() == 42 - && mcPermissions.getInstance().repair(player)){ - short durability = is.getDurability(); - if(player.getItemInHand().getDurability() > 0){ - /* - * ARMOR - */ - if(mcm.getInstance().isArmor(is) && block.getTypeId() == 42){ - /* - * DIAMOND ARMOR - */ - if(mcm.getInstance().isDiamondArmor(is) && mcm.getInstance().hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() >= 50){ - mcm.getInstance().removeDiamond(player); - player.getItemInHand().setDurability(mcm.getInstance().getArmorRepairAmount(is, player)); - mcUsers.getProfile(player).addRepairGather(50); - } else if (mcm.getInstance().isIronArmor(is) && mcm.getInstance().hasIron(player)){ - /* - * IRON ARMOR - */ - mcm.getInstance().removeIron(player); - player.getItemInHand().setDurability(mcm.getInstance().getArmorRepairAmount(is, player)); - /* - * DISTRIBUTE REPAIR XP - */ - mcUsers.getProfile(player).addRepairGather(20); - } else { - needMoreVespeneGas(is, player); - } - } - /* - * TOOLS - */ - if(mcm.getInstance().isTools(is) && block.getTypeId() == 42){ - /* - * IRON TOOLS - */ - if(mcm.getInstance().isIronTools(is) && mcm.getInstance().hasIron(player)){ - is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player)); - mcm.getInstance().removeIron(player); - mcUsers.getProfile(player).addRepairGather(20); - } else if (mcm.getInstance().isDiamondTools(is) && mcm.getInstance().hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() >= 50){ //Check if its diamond and the player has diamonds - /* - * DIAMOND TOOLS - */ - is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player)); - mcm.getInstance().removeDiamond(player); - mcUsers.getProfile(player).addRepairGather(50); - } else { - needMoreVespeneGas(is, player); - } - } - - } else { - player.sendMessage("That is at full durability."); - } - player.updateInventory(); - /* - * GIVE SKILL IF THERE IS ENOUGH XP - */ - if(mcUsers.getProfile(player).getRepairGatherInt() >= mcUsers.getProfile(player).getXpToLevel("repair")){ - int skillups = 0; - while(mcUsers.getProfile(player).getRepairGatherInt() >= mcUsers.getProfile(player).getXpToLevel("repair")){ - skillups++; - mcUsers.getProfile(player).removeRepairGather(mcUsers.getProfile(player).getXpToLevel("repair")); - mcUsers.getProfile(player).skillUpRepair(1); - } - player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getRepair()+")"); - } - } - } - public void herbalismProcCheck(Block block, Player player){ - int type = block.getTypeId(); - Location loc = block.getLocation(); - ItemStack is = null; - Material mat = null; - //player.sendMessage("mcMMO DEBUG: Data ("+block.getData()+")"+" TYPEID ("+block.getTypeId()+")"); - if(type == 59 && block.getData() == (byte) 0x7){ - mat = Material.getMaterial(296); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - mcUsers.getProfile(player).addHerbalismGather(5); - if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ - if(Math.random() * 10 > 8) - loc.getWorld().dropItemNaturally(loc, is); - } - if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 350 ){ - if(Math.random() * 10 > 6) - loc.getWorld().dropItemNaturally(loc, is); - } - if(mcUsers.getProfile(player).getHerbalismInt() >= 350 && mcUsers.getProfile(player).getHerbalismInt() < 500 ){ - if(Math.random() * 10 > 4) - loc.getWorld().dropItemNaturally(loc, is); - } - if(mcUsers.getProfile(player).getHerbalismInt() >= 500 && mcUsers.getProfile(player).getHerbalismInt() < 750 ){ - if(Math.random() * 10 > 2) - loc.getWorld().dropItemNaturally(loc, is); - } - } - /* - * We need to check not-wheat stuff for if it was placed by the player or not - */ - if(!mcConfig.getInstance().isBlockWatched(block)){ - //player.sendMessage("DEBUG CODE 2"); - if(type == 39 || type == 40){ - mcUsers.getProfile(player).addHerbalismGather(10); - } - if(type == 37 || type == 38){ - mcUsers.getProfile(player).addHerbalismGather(3); - } - } - if(mcUsers.getProfile(player).getHerbalismGatherInt() >= mcUsers.getProfile(player).getXpToLevel("herbalism")){ - int skillups = 0; - while(mcUsers.getProfile(player).getHerbalismGatherInt() >= mcUsers.getProfile(player).getXpToLevel("herbalism")){ - skillups++; - mcUsers.getProfile(player).removeHerbalismGather(mcUsers.getProfile(player).getXpToLevel("herbalism")); - mcUsers.getProfile(player).skillUpHerbalism(1); - } - player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getHerbalism()+")"); - } - } - public void excavationProcCheck(Block block, Player player){ - int type = block.getTypeId(); - Location loc = block.getLocation(); - ItemStack is = null; - Material mat = null; - if(type == 2 && mcUsers.getProfile(player).getExcavationInt() > 250){ - //CHANCE TO GET EGGS - if(mcLoadProperties.eggs == true && Math.random() * 100 > 99){ - mcUsers.getProfile(player).addExcavationGather(10); - mat = Material.getMaterial(344); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - //CHANCE TO GET APPLES - if(mcLoadProperties.apples == true && Math.random() * 100 > 99){ - mcUsers.getProfile(player).addExcavationGather(10); - mat = Material.getMaterial(260); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - //DIRT SAND OR GRAVEL - if(type == 3 || type == 13 || type == 2 || type == 12){ - mcUsers.getProfile(player).addExcavationGather(3); - if(mcUsers.getProfile(player).getExcavationInt() > 750){ - //CHANCE TO GET CAKE - if(mcLoadProperties.cake == true && Math.random() * 2000 > 1999){ - mcUsers.getProfile(player).addExcavationGather(300); - mat = Material.getMaterial(354); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - if(mcUsers.getProfile(player).getExcavationInt() > 150){ - //CHANCE TO GET MUSIC - if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){ - mcUsers.getProfile(player).addExcavationGather(300); - mat = Material.getMaterial(2256); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - - } - if(mcUsers.getProfile(player).getExcavationInt() > 350){ - //CHANCE TO GET DIAMOND - if(mcLoadProperties.diamond == true && Math.random() * 500 > 499){ - mcUsers.getProfile(player).addExcavationGather(100); - mat = Material.getMaterial(264); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - if(mcUsers.getProfile(player).getExcavationInt() > 250){ - //CHANCE TO GET MUSIC - if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){ - mcUsers.getProfile(player).addExcavationGather(300); - mat = Material.getMaterial(2257); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - } - //SAND - if(type == 12){ - //CHANCE TO GET GLOWSTONE - if(mcLoadProperties.glowstone == true && mcUsers.getProfile(player).getExcavationInt() > 50 && Math.random() * 100 > 95){ - mcUsers.getProfile(player).addExcavationGather(3); - mat = Material.getMaterial(348); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - //CHANCE TO GET SLOWSAND - if(mcLoadProperties.slowsand == true && mcUsers.getProfile(player).getExcavationInt() > 650 && Math.random() * 200 > 199){ - mcUsers.getProfile(player).addExcavationGather(5); - mat = Material.getMaterial(88); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - //CHANCE TO GET DIAMOND - if(mcLoadProperties.diamond == true && mcUsers.getProfile(player).getExcavationInt() > 500 && Math.random() * 500 > 499){ - mcUsers.getProfile(player).addExcavationGather(100); - mat = Material.getMaterial(264); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - //GRASS OR DIRT - if((type == 2 || type == 3) && mcUsers.getProfile(player).getExcavationInt() > 25){ - //CHANCE TO GET GLOWSTONE - if(mcLoadProperties.glowstone == true && Math.random() * 100 > 95){ - mcUsers.getProfile(player).addExcavationGather(5); - mat = Material.getMaterial(348); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - //GRAVEL - if(type == 13){ - //CHANCE TO GET NETHERRACK - if(mcLoadProperties.netherrack == true && mcUsers.getProfile(player).getExcavationInt() > 850 && Math.random() * 200 > 199){ - mcUsers.getProfile(player).addExcavationGather(3); - mat = Material.getMaterial(87); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - //CHANCE TO GET SULPHUR - if(mcLoadProperties.sulphur == true && mcUsers.getProfile(player).getExcavationInt() > 75){ - if(Math.random() * 10 > 9){ - mcUsers.getProfile(player).addExcavationGather(3); - mat = Material.getMaterial(289); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - //CHANCE TO GET BONES - if(mcLoadProperties.bones == true && mcUsers.getProfile(player).getExcavationInt() > 175){ - if(Math.random() * 10 > 6){ - mcUsers.getProfile(player).addExcavationGather(3); - mat = Material.getMaterial(352); - is = new ItemStack(mat, 1, (byte)0, (byte)0); - loc.getWorld().dropItemNaturally(loc, is); - } - } - } - if(mcUsers.getProfile(player).getExcavationGatherInt() >= mcUsers.getProfile(player).getXpToLevel("excavation")){ - int skillups = 0; - while(mcUsers.getProfile(player).getExcavationGatherInt() >= mcUsers.getProfile(player).getXpToLevel("excavation")){ - skillups++; - mcUsers.getProfile(player).removeExcavationGather(mcUsers.getProfile(player).getXpToLevel("excavation")); - mcUsers.getProfile(player).skillUpExcavation(1); - } - player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getExcavation()+")"); - } - } - public void woodCuttingProcCheck(Player player, Block block, Location loc){ - byte type = block.getData(); - Material mat = Material.getMaterial(block.getTypeId()); - byte damage = 0; - if(mcUsers.getProfile(player).getWoodCuttingInt() > 1000){ - ItemStack item = new ItemStack(mat, 1, type, damage); - loc.getWorld().dropItemNaturally(loc, item); - return; - } - if(mcUsers.getProfile(player).getWoodCuttingInt() > 750){ - if((Math.random() * 10) > 2){ - ItemStack item = new ItemStack(mat, 1, type, damage); - loc.getWorld().dropItemNaturally(loc, item); - return; - } - } - if(mcUsers.getProfile(player).getWoodCuttingInt() > 300){ - if((Math.random() * 10) > 4){ - ItemStack item = new ItemStack(mat, 1, type, damage); - loc.getWorld().dropItemNaturally(loc, item); - return; - } - } - if(mcUsers.getProfile(player).getWoodCuttingInt() > 100){ - if((Math.random() * 10) > 6){ - ItemStack item = new ItemStack(mat, 1, type, damage); - loc.getWorld().dropItemNaturally(loc, item); - return; - } - } - if(mcUsers.getProfile(player).getWoodCuttingInt() > 10){ - if((Math.random() * 10) > 8){ - ItemStack item = new ItemStack(mat, 1, type, damage); - loc.getWorld().dropItemNaturally(loc, item); - return; - } - } - } - // IS TOOLS FUNCTION - public boolean isArmor(ItemStack is){ - if(is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 || - is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313){ - return true; - } else { - return false; - } - } - public boolean isIronArmor(ItemStack is){ - if(is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309) - { - return true; - } else { - return false; - } - } - public boolean isDiamondArmor(ItemStack is){ - if(is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313) - { - return true; - } else { - return false; - } - } - public boolean isTools(ItemStack is){ - if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 ||//IRON - is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293) //DIAMOND - { - return true; - } else { - return false; - } - } - - public boolean isIronTools(ItemStack is){ - if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292) - { - return true; - } else { - return false; - } - } - - public boolean isDiamondTools(ItemStack is){ - if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293) - { - return true; - } else { - return false; - } - } - public void removeIron(Player player){ - ItemStack[] inventory = player.getInventory().getContents(); - for(ItemStack x : inventory){ - if(x.getTypeId() == 265){ - if(x.getAmount() == 1){ - x.setTypeId(0); - x.setAmount(0); - player.getInventory().setContents(inventory); - } else{ - x.setAmount(x.getAmount() - 1); - player.getInventory().setContents(inventory); - } - return; - } - } - } - public void removeDiamond(Player player){ - ItemStack[] inventory = player.getInventory().getContents(); - for(ItemStack x : inventory){ - if(x.getTypeId() == 264){ - if(x.getAmount() == 1){ - x.setTypeId(0); - x.setAmount(0); - player.getInventory().setContents(inventory); - } else{ - x.setAmount(x.getAmount() - 1); - player.getInventory().setContents(inventory); - } - return; - } - } - } - public boolean hasDiamond(Player player){ - ItemStack[] inventory = player.getInventory().getContents(); - for(ItemStack x : inventory){ - if(x.getTypeId() == 264){ - return true; - } - } - return false; - } - public boolean hasIron(Player player){ - ItemStack[] inventory = player.getInventory().getContents(); - for(ItemStack x : inventory){ - if(x.getTypeId() == 265){ - return true; - } - } - return false; - } } diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 389df2fb7..5bb44c6dd 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.8.6 \ No newline at end of file +version: 0.8.11 WIP no. 4 \ No newline at end of file