mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
0.3.2 Release
Changed excavation loot tables Made sand give normal xp Fixed herbalism skill exploit Mobs killed with unarmed now drop loot properly Squids now effected by unarmed Unarmed xp rate depends on mob Huge player-crashing bug with unarmed fixed
This commit is contained in:
parent
8fa4960beb
commit
7d77a5b514
@ -29,6 +29,7 @@ public class mcBlockListener extends BlockListener {
|
||||
//STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
int type = block.getTypeId();
|
||||
Location loc = block.getLocation();
|
||||
int dmg = event.getDamageLevel().getLevel();
|
||||
//Smooth Stone
|
||||
@ -44,6 +45,7 @@ public class mcBlockListener extends BlockListener {
|
||||
}
|
||||
mcm.getInstance().excavationProcCheck(block, player);
|
||||
}
|
||||
if(mcConfig.getInstance().isBlockWatched(block) && !(type == 39 || type == 40 || type == 37 || type == 38));
|
||||
mcm.getInstance().herbalismProcCheck(block, player); //You place the blocks so we wont check if they are being watched
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,10 @@ import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
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.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
@ -25,9 +29,46 @@ public class mcEntityListener extends EntityListener {
|
||||
Entity y = event.getDamager(); //Attacker
|
||||
//If attacker is player...
|
||||
if(y instanceof Player){
|
||||
int type = ((Player) y).getItemInHand().getTypeId();
|
||||
Player attacker = (Player)y;
|
||||
if(x instanceof Squid){
|
||||
if(type == 0){
|
||||
Squid defender = (Squid)event.getEntity();
|
||||
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(attacker.getItemInHand().getTypeId() == 0 && Math.random() * 10 > 8){
|
||||
if(defender.getHealth() != 0){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
}
|
||||
if(defender.getHealth() <= 0)
|
||||
mcm.getInstance().simulateNaturalDrops(defender);
|
||||
}
|
||||
}
|
||||
if(x instanceof Monster){
|
||||
if(type == 0){
|
||||
Monster defender = (Monster)event.getEntity();
|
||||
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){
|
||||
@ -46,15 +87,33 @@ public class mcEntityListener extends EntityListener {
|
||||
defender.setHealth(calculateDamage(defender, 8));
|
||||
}
|
||||
//XP
|
||||
if(attacker.getItemInHand().getTypeId() == 0 && Math.random() * 10 > 8){
|
||||
if(defender.getHealth() != 0){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
}
|
||||
if(x instanceof Skeleton && Math.random() * 10 > 8){
|
||||
if(defender.getHealth() != 0){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
}
|
||||
if(x instanceof Spider&& Math.random() * 10 > 7){
|
||||
if(defender.getHealth() != 0){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
}
|
||||
if(x instanceof Zombie && Math.random() * 100 > 95){
|
||||
if(defender.getHealth() != 0){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
}
|
||||
if(defender.getHealth() <= 0)
|
||||
mcm.getInstance().simulateNaturalDrops(defender);
|
||||
}
|
||||
}
|
||||
if(x instanceof Animals){
|
||||
if(type == 0){
|
||||
Animals defender = (Animals)event.getEntity();
|
||||
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){
|
||||
@ -72,6 +131,10 @@ public class mcEntityListener extends EntityListener {
|
||||
} else if(mcUsers.getProfile(attacker).getUnarmedInt() >= 950){
|
||||
defender.setHealth(calculateDamage(defender, 8));
|
||||
}
|
||||
if(defender.getHealth() <= 0){
|
||||
mcm.getInstance().simulateNaturalDrops(defender);
|
||||
}
|
||||
}
|
||||
}
|
||||
//If defender is player
|
||||
if(x instanceof Player){
|
||||
@ -109,11 +172,20 @@ public class mcEntityListener extends EntityListener {
|
||||
if(simulateUnarmedProc(attacker)){
|
||||
attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force.");
|
||||
Location loc = defender.getLocation();
|
||||
if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0){
|
||||
ItemStack item = defender.getItemInHand();
|
||||
if(item != null){
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
item.setTypeId(0);
|
||||
item.setAmount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(defender.getHealth() <= 0){
|
||||
for(ItemStack i : defender.getInventory().getContents()){
|
||||
if(i != null && i.getTypeId() != 0)
|
||||
defender.getLocation().getWorld().dropItemNaturally(defender.getLocation(), i);
|
||||
}
|
||||
for(Player derp : plugin.getServer().getOnlinePlayers()){
|
||||
derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName());
|
||||
mcUsers.getProfile(defender).setDead(true);
|
||||
@ -157,6 +229,15 @@ public class mcEntityListener extends EntityListener {
|
||||
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){
|
||||
|
@ -4,7 +4,14 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Pig;
|
||||
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.inventory.ItemStack;
|
||||
|
||||
public class mcm {
|
||||
@ -22,6 +29,79 @@ public class mcm {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void simulateNaturalDrops(Entity entity){
|
||||
Location loc = entity.getLocation();
|
||||
if(entity instanceof Pig){
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 319); //BACON
|
||||
}
|
||||
dropItem(loc, 319);
|
||||
}
|
||||
}
|
||||
if(entity instanceof Spider){
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 287); //SILK
|
||||
}
|
||||
dropItem(loc, 287);
|
||||
}
|
||||
}
|
||||
if(entity instanceof Skeleton){
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 262); //ARROWS
|
||||
}
|
||||
dropItem(loc, 262);
|
||||
}
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 352); //BONES
|
||||
}
|
||||
dropItem(loc, 352);
|
||||
}
|
||||
}
|
||||
if(entity instanceof Zombie){
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 288); //FEATHERS
|
||||
}
|
||||
dropItem(loc, 288);
|
||||
}
|
||||
}
|
||||
if(entity instanceof Cow){
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 334); //LEATHER
|
||||
}
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 334);
|
||||
}
|
||||
dropItem(loc, 334);
|
||||
}
|
||||
}
|
||||
if(entity instanceof Squid){
|
||||
if(Math.random() * 3 > 2){
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 351); //INK SACS
|
||||
}
|
||||
if(Math.random() * 2 > 1){
|
||||
dropItem(loc, 351);
|
||||
}
|
||||
dropItem(loc, 351);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void dropItem(Location loc, int id){
|
||||
if(loc != null){
|
||||
Material mat = Material.getMaterial(id);
|
||||
byte damage = 0;
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
}
|
||||
public boolean checkPlayerProcRepair(Player player){
|
||||
if(mcUsers.getProfile(player).getRepairInt() >= 750){
|
||||
if(Math.random() * 10 > 2){
|
||||
@ -299,19 +379,16 @@ public class mcm {
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 500){
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 150){
|
||||
//CHANCE TO GET MUSIC
|
||||
if(Math.random() * 1000 > 999){
|
||||
mat = Material.getMaterial(2256);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
//CHANCE TO GET MUSIC
|
||||
if(Math.random() * 1000 > 999){
|
||||
mat = Material.getMaterial(2257);
|
||||
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(Math.random() * 500 > 499){
|
||||
mat = Material.getMaterial(264);
|
||||
@ -319,14 +396,17 @@ public class mcm {
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 250){
|
||||
//CHANCE TO GET MUSIC
|
||||
if(Math.random() * 1000 > 999){
|
||||
mat = Material.getMaterial(2257);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
//SAND
|
||||
if(type == 12){
|
||||
if(Math.random() * 10 > 9){
|
||||
mcUsers.getProfile(player).skillUpExcavation(1);
|
||||
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by 1. Total ("+mcUsers.getProfile(player).getExcavationInt()+")");
|
||||
|
||||
}
|
||||
//CHANCE TO GET GLOWSTONE
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 50 && Math.random() * 100 > 95){
|
||||
mat = Material.getMaterial(348);
|
||||
|
@ -1,3 +1,3 @@
|
||||
name: mcMMO
|
||||
main: com.bukkit.nossr50.mcMMO.mcMMO
|
||||
version: 0.3.1
|
||||
version: 0.3.2
|
Loading…
Reference in New Issue
Block a user