Many many many fixes.

This commit is contained in:
nossr50 2011-02-09 02:26:47 -08:00
parent 7d77a5b514
commit b38c682c8c
5 changed files with 45 additions and 45 deletions

View File

@ -5,6 +5,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -105,6 +106,12 @@ public class mcEntityListener extends EntityListener {
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")"); attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
} }
} }
if(x instanceof Creeper && Math.random() * 10 > 7){
if(defender.getHealth() != 0){
mcUsers.getProfile(attacker).skillUpUnarmed(2);
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 2. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
}
}
if(defender.getHealth() <= 0) if(defender.getHealth() <= 0)
mcm.getInstance().simulateNaturalDrops(defender); mcm.getInstance().simulateNaturalDrops(defender);
} }
@ -196,7 +203,7 @@ public class mcEntityListener extends EntityListener {
} }
if(mcUsers.getProfile(defender).isDead()) if(mcUsers.getProfile(defender).isDead())
return; return;
if((defender.getHealth() - event.getDamage()) <= 0){ if((defender.getHealth() - event.getDamage()) <= 0 && defender.getHealth() != 0){
for(Player derp : plugin.getServer().getOnlinePlayers()){ for(Player derp : plugin.getServer().getOnlinePlayers()){
derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName()); derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName());
mcUsers.getProfile(defender).setDead(true); mcUsers.getProfile(defender).setDead(true);
@ -207,7 +214,7 @@ public class mcEntityListener extends EntityListener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
public boolean simulateUnarmedProc(Player player){ public boolean simulateUnarmedProc(Player player){
if(mcUsers.getProfile(player).getUnarmedInt() >= 750){ if(mcUsers.getProfile(player).getUnarmedInt() >= 750){
if(Math.random() * 10 > 4){ if(Math.random() * 10 > 4){

View File

@ -47,6 +47,7 @@ public class mcMMO extends JavaPlugin {
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_ITEM_HELD, playerListener, Priority.Normal, this);
//Displays a message when plugin is loaded //Displays a message when plugin is loaded
PluginDescriptionFile pdfFile = this.getDescription(); PluginDescriptionFile pdfFile = this.getDescription();
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -73,7 +74,7 @@ public class mcPlayerListener extends PlayerListener {
public void onPlayerJoin(PlayerEvent event) { public void onPlayerJoin(PlayerEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
mcUsers.addUser(player); mcUsers.addUser(player);
player.sendMessage(ChatColor.BLUE + "This server is running mcMMO type "+ChatColor.YELLOW+"/mcmmo "+ChatColor.BLUE+ "for help."); player.sendMessage(ChatColor.BLUE + "This server is running mcMMO "+plugin.getDescription().getVersion()+" type "+ChatColor.YELLOW+"/mcmmo "+ChatColor.BLUE+ "for help.");
player.sendMessage(ChatColor.RED+"WARNING: "+ChatColor.DARK_GRAY+ "Using /myspawn will clear your inventory!"); player.sendMessage(ChatColor.RED+"WARNING: "+ChatColor.DARK_GRAY+ "Using /myspawn will clear your inventory!");
} }
//Check if string is a player //Check if string is a player
@ -108,12 +109,9 @@ public class mcPlayerListener extends PlayerListener {
player.setHealth(player.getHealth() + 6); player.setHealth(player.getHealth() + 6);
} }
} }
if(block != null && block.getTypeId() == 42 && player.getItemInHand().getDurability() <= 0 && (mcm.getInstance().isTools(is)) || mcm.getInstance().isArmor(is)){
player.sendMessage(ChatColor.YELLOW+"That is at full durability.");
return;
}
if(block != null && block.getTypeId() == 42){ if(block != null && block.getTypeId() == 42){
short durability = is.getDurability(); short durability = is.getDurability();
if(player.getItemInHand().getDurability() > 0){
if(mcm.getInstance().isArmor(is) && block.getTypeId() == 42){ if(mcm.getInstance().isArmor(is) && block.getTypeId() == 42){
if(mcm.getInstance().isDiamondArmor(is) && mcm.getInstance().hasDiamond(player)){ if(mcm.getInstance().isDiamondArmor(is) && mcm.getInstance().hasDiamond(player)){
mcm.getInstance().removeDiamond(player); mcm.getInstance().removeDiamond(player);
@ -121,16 +119,17 @@ public class mcPlayerListener extends PlayerListener {
mcUsers.getProfile(player).skillUpRepair(1); mcUsers.getProfile(player).skillUpRepair(1);
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")"); player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")");
} else if (mcm.getInstance().isIronArmor(is) && mcm.getInstance().hasIron(player)){ } else if (mcm.getInstance().isIronArmor(is) && mcm.getInstance().hasIron(player)){
player.sendMessage(ChatColor.DARK_RED+"Changing the durability of iron armor is currently bugged."); //player.sendMessage(ChatColor.DARK_RED+"Changing the durability of iron armor is currently bugged.");
player.sendMessage(ChatColor.YELLOW+"I'm looking into this issue. -mcMMO Author"); //player.sendMessage(ChatColor.YELLOW+"I'm looking into this issue. -mcMMO Author");
/*
mcm.getInstance().removeIron(player); mcm.getInstance().removeIron(player);
is.setDurability(mcm.getInstance().getArmorRepairAmount(is, player)); player.getItemInHand().setDurability(mcm.getInstance().getArmorRepairAmount(is, player));
mcUsers.getProfile(player).skillUpRepair(1); mcUsers.getProfile(player).skillUpRepair(1);
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")"); player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")");
*/
} }
} }
} else {
player.sendMessage("That is at full durability.");
}
/* /*
* TOOLS * TOOLS
*/ */
@ -408,6 +407,13 @@ public class mcPlayerListener extends PlayerListener {
player.sendMessage("Spawn isn't configured. Have an OP set it with /setspawn"); player.sendMessage("Spawn isn't configured. Have an OP set it with /setspawn");
} }
} }
public void onItemHeldChange(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
}
private Block getBlockAt(int x, int y, int z) {
// TODO Auto-generated method stub
return null;
}
public void onPlayerChat(PlayerChatEvent event) { public void onPlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String[] split = event.getMessage().split(" "); String[] split = event.getMessage().split(" ");

View File

@ -308,6 +308,7 @@ public class mcm {
Location loc = block.getLocation(); Location loc = block.getLocation();
ItemStack is = null; ItemStack is = null;
Material mat = null; Material mat = null;
if(!mcConfig.getInstance().isBlockWatched(block)){
if(type == 39 || type == 40){ if(type == 39 || type == 40){
mcUsers.getProfile(player).skillUpHerbalism(3); mcUsers.getProfile(player).skillUpHerbalism(3);
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 3. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")"); player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 3. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")");
@ -318,38 +319,29 @@ public class mcm {
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 1. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")"); player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 1. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")");
} }
} }
if(type == 59){ if(type == 59 && block.getData() == (byte) 0x7){
mat = Material.getMaterial(296);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
mcUsers.getProfile(player).skillUpHerbalism(1); mcUsers.getProfile(player).skillUpHerbalism(1);
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 1. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")"); player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 1. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")");
if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){ if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){
if(Math.random() * 10 > 8){ if(Math.random() * 10 > 8)
mat = Material.getMaterial(59);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is); loc.getWorld().dropItemNaturally(loc, is);
} }
}
if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 350 ){ if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 350 ){
if(Math.random() * 10 > 6){ if(Math.random() * 10 > 6)
mat = Material.getMaterial(59);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is); loc.getWorld().dropItemNaturally(loc, is);
}
} }
if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 500 ){ if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 500 ){
if(Math.random() * 10 > 4){ if(Math.random() * 10 > 4)
mat = Material.getMaterial(59);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is); loc.getWorld().dropItemNaturally(loc, is);
}
} }
if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 750 ){ if(mcUsers.getProfile(player).getHerbalismInt() >= 150 && mcUsers.getProfile(player).getHerbalismInt() < 750 ){
if(Math.random() * 10 > 2){ if(Math.random() * 10 > 2)
mat = Material.getMaterial(59);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is); loc.getWorld().dropItemNaturally(loc, is);
}
} }
} }
}
} }
public void excavationProcCheck(Block block, Player player){ public void excavationProcCheck(Block block, Player player){
int type = block.getTypeId(); int type = block.getTypeId();
@ -457,45 +449,38 @@ public class mcm {
} }
} }
public void woodCuttingProcCheck(Player player, Block block, Location loc){ 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){ if(mcUsers.getProfile(player).getWoodCuttingint() > 1000){
Material mat = Material.getMaterial(block.getTypeId()); ItemStack item = new ItemStack(mat, 1, type, damage);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item); block.getWorld().dropItemNaturally(loc, item);
return; return;
} }
if(mcUsers.getProfile(player).getWoodCuttingint() > 750){ if(mcUsers.getProfile(player).getWoodCuttingint() > 750){
if((Math.random() * 10) > 2){ if((Math.random() * 10) > 2){
Material mat = Material.getMaterial(block.getTypeId()); ItemStack item = new ItemStack(mat, 1, type, damage);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item); block.getWorld().dropItemNaturally(loc, item);
return; return;
} }
} }
if(mcUsers.getProfile(player).getWoodCuttingint() > 300){ if(mcUsers.getProfile(player).getWoodCuttingint() > 300){
if((Math.random() * 10) > 4){ if((Math.random() * 10) > 4){
Material mat = Material.getMaterial(block.getTypeId()); ItemStack item = new ItemStack(mat, 1, type, damage);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item); block.getWorld().dropItemNaturally(loc, item);
return; return;
} }
} }
if(mcUsers.getProfile(player).getWoodCuttingint() > 100){ if(mcUsers.getProfile(player).getWoodCuttingint() > 100){
if((Math.random() * 10) > 6){ if((Math.random() * 10) > 6){
Material mat = Material.getMaterial(block.getTypeId()); ItemStack item = new ItemStack(mat, 1, type, damage);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item); block.getWorld().dropItemNaturally(loc, item);
return; return;
} }
} }
if(mcUsers.getProfile(player).getWoodCuttingint() > 10){ if(mcUsers.getProfile(player).getWoodCuttingint() > 10){
if((Math.random() * 10) > 8){ if((Math.random() * 10) > 8){
Material mat = Material.getMaterial(block.getTypeId()); ItemStack item = new ItemStack(mat, 1, type, damage);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item); block.getWorld().dropItemNaturally(loc, item);
return; return;
} }
@ -581,6 +566,7 @@ public class mcm {
x.setAmount(x.getAmount() - 1); x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory); player.getInventory().setContents(inventory);
} }
return;
} }
} }
} }

View File

@ -1,3 +1,3 @@
name: mcMMO name: mcMMO
main: com.bukkit.nossr50.mcMMO.mcMMO main: com.bukkit.nossr50.mcMMO.mcMMO
version: 0.3.2 version: 0.3.4