From afa9abfb91bb619d900703ae38c92e1fb912d668 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 11 Mar 2011 15:24:58 -0800 Subject: [PATCH] All changes up to 0.8.17 --- mcMMO/Changelog.txt | 6 + mcMMO/com/gmail/nossr50/mcBlockListener.java | 128 +++++++++--------- mcMMO/com/gmail/nossr50/mcCombat.java | 26 ++-- mcMMO/com/gmail/nossr50/mcExcavation.java | 26 ++-- mcMMO/com/gmail/nossr50/mcMMO.java | 2 +- mcMMO/com/gmail/nossr50/mcMining.java | 1 - mcMMO/com/gmail/nossr50/mcPlayerListener.java | 2 + mcMMO/com/gmail/nossr50/mcUsers.java | 4 +- mcMMO/com/gmail/nossr50/mcm.java | 8 +- mcMMO/plugin.yml | 2 +- 10 files changed, 106 insertions(+), 99 deletions(-) diff --git a/mcMMO/Changelog.txt b/mcMMO/Changelog.txt index faff92463..b723dc325 100644 --- a/mcMMO/Changelog.txt +++ b/mcMMO/Changelog.txt @@ -1,5 +1,11 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code# +Version 0.8.17 + mcmmo.users moved to plugins/mcMMO/ + Snowballs and Eggs will no longer trigger Ignition + Loot tables for excavation adjusted + Mining benefits now require the player to be holding a mining pick + Woodcutting benefits now require the player to be holding an axe Version 0.8.16 Moved configuration file to /plugins/mcMMO Arrows now have a chance to Ignite enemiesw diff --git a/mcMMO/com/gmail/nossr50/mcBlockListener.java b/mcMMO/com/gmail/nossr50/mcBlockListener.java index d5139522b..0b73e8e87 100644 --- a/mcMMO/com/gmail/nossr50/mcBlockListener.java +++ b/mcMMO/com/gmail/nossr50/mcBlockListener.java @@ -22,17 +22,14 @@ public class mcBlockListener extends BlockListener { } public void onBlockPlace(BlockPlaceEvent event) { Block block; + Player player = event.getPlayer(); if (event.getBlockReplacedState().getTypeId() == 78) { block = event.getBlockAgainst(); } else { block = event.getBlock(); } - int x = block.getX(); - int y = block.getY(); - int z = block.getZ(); - String xyz = x+","+y+","+z; - if(mcm.getInstance().shouldBeWatched(block)) + if(player != null && mcm.getInstance().shouldBeWatched(block)) mcConfig.getInstance().addBlockWatch(block); if(block.getTypeId() == 42 && mcLoadProperties.anvilmessages) event.getPlayer().sendMessage(ChatColor.DARK_RED+"You have placed an anvil, anvils can repair tools and armor."); @@ -41,12 +38,9 @@ public class mcBlockListener extends BlockListener { public void onBlockDamage(BlockDamageEvent event) { //STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2); Player player = event.getPlayer(); + ItemStack inhand = player.getItemInHand(); //player.sendMessage("mcMMO DEBUG: EVENT-OK DMG LEVEL ("+event.getDamageLevel().getLevel()+")"); Block block = event.getBlock(); - int x = block.getX(); - int y = block.getY(); - int z = block.getZ(); - String xyz = x+","+y+","+z; Location loc = block.getLocation(); int dmg = event.getDamageLevel().getLevel(); /* @@ -60,64 +54,64 @@ public class mcBlockListener extends BlockListener { * MINING */ if(player != null && dmg == 2 && !mcConfig.getInstance().isBlockWatched(block)){ - if(mcPermissions.getInstance().mining(player)) - mcMining.getInstance().miningBlockCheck(player, block); - /* - * WOOD CUTTING - */ - if(player != null && block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player)){ - mcWoodCutting.getInstance().woodCuttingProcCheck(player, block, loc); - mcUsers.getProfile(player).addWoodcuttingGather(7); - /* - * IF PLAYER IS USING TREEFELLER - */ - if(mcPermissions.getInstance().woodcuttingability(player) && mcUsers.getProfile(player).getTreeFellerMode() && block.getTypeId() == 17){ - mcWoodCutting.getInstance().treeFeller(block, player); - for(Block blockx : mcConfig.getInstance().getTreeFeller()){ - if(blockx != null){ - Material mat = Material.getMaterial(blockx.getTypeId()); - byte damage = 0; - ItemStack item = new ItemStack(mat, 1, (byte)0, damage); - blockx.setTypeId(0); - if(item.getTypeId() == 17){ - blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); - mcWoodCutting.getInstance().woodCuttingProcCheck(player, blockx, blockx.getLocation()); - mcUsers.getProfile(player).addWoodcuttingGather(7); - } - if(item.getTypeId() == 18){ - mat = Material.getMaterial(6); - item = new ItemStack(mat, 1, (byte)0, damage); - if(Math.random() * 10 > 8) - blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); - } - } - } - /* - * NOTE TO SELF - * I NEED TO REMOVE TREE FELL BLOCKS FROM BEING WATCHED AFTER THIS CODE IS EXECUTED - * OR ELSE IT COULD BE A MEMORY LEAK SITUATION - */ - mcConfig.getInstance().clearTreeFeller(); - } - } - /* - * EXCAVATION - */ - if(mcPermissions.getInstance().excavation(player) && block != null && player != null) - mcExcavation.getInstance().excavationProcCheck(block, player); - /* - * EXPLOIT COUNTERMEASURES - */ - mcConfig.getInstance().addBlockWatch(block); - 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++; - mcUsers.getProfile(player).removeWoodCuttingGather(mcUsers.getProfile(player).getXpToLevel("woodcutting")); - mcUsers.getProfile(player).skillUpWoodCutting(1); - } - player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getWoodCutting()+")"); - } + if(mcm.getInstance().isMiningPick(inhand) && mcPermissions.getInstance().mining(player)) + mcMining.getInstance().miningBlockCheck(player, block); + /* + * WOOD CUTTING + */ + if(player != null && mcm.getInstance().isAxes(inhand) && block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player)){ + mcWoodCutting.getInstance().woodCuttingProcCheck(player, block, loc); + mcUsers.getProfile(player).addWoodcuttingGather(7); + /* + * IF PLAYER IS USING TREEFELLER + */ + if(mcPermissions.getInstance().woodcuttingability(player) && mcUsers.getProfile(player).getTreeFellerMode() && block.getTypeId() == 17){ + mcWoodCutting.getInstance().treeFeller(block, player); + for(Block blockx : mcConfig.getInstance().getTreeFeller()){ + if(blockx != null){ + Material mat = Material.getMaterial(blockx.getTypeId()); + byte damage = 0; + ItemStack item = new ItemStack(mat, 1, (byte)0, damage); + blockx.setTypeId(0); + if(item.getTypeId() == 17){ + blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); + mcWoodCutting.getInstance().woodCuttingProcCheck(player, blockx, blockx.getLocation()); + mcUsers.getProfile(player).addWoodcuttingGather(7); + } + if(item.getTypeId() == 18){ + mat = Material.getMaterial(6); + item = new ItemStack(mat, 1, (byte)0, damage); + if(Math.random() * 10 > 8) + blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item); + } + } + } + /* + * NOTE TO SELF + * I NEED TO REMOVE TREE FELL BLOCKS FROM BEING WATCHED AFTER THIS CODE IS EXECUTED + * OR ELSE IT COULD BE A MEMORY LEAK SITUATION + */ + mcConfig.getInstance().clearTreeFeller(); + } + } + /* + * EXCAVATION + */ + if(mcPermissions.getInstance().excavation(player) && block != null && player != null) + mcExcavation.getInstance().excavationProcCheck(block, player); + /* + * EXPLOIT COUNTERMEASURES + */ + mcConfig.getInstance().addBlockWatch(block); + 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++; + mcUsers.getProfile(player).removeWoodCuttingGather(mcUsers.getProfile(player).getXpToLevel("woodcutting")); + mcUsers.getProfile(player).skillUpWoodCutting(1); + } + player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(player).getWoodCutting()+")"); + } } } diff --git a/mcMMO/com/gmail/nossr50/mcCombat.java b/mcMMO/com/gmail/nossr50/mcCombat.java index 762127021..fdfc0c86d 100644 --- a/mcMMO/com/gmail/nossr50/mcCombat.java +++ b/mcMMO/com/gmail/nossr50/mcCombat.java @@ -332,19 +332,6 @@ public class mcCombat { */ if(y instanceof Player){ Player attacker = (Player)y; - if(Math.random() * 1500 <= mcUsers.getProfile(attacker).getArcheryInt()){ - if(x instanceof Player){ - Player Defender = (Player)x; - if(!mcParty.getInstance().inSameParty(attacker, Defender)){ - event.getEntity().setFireTicks(120); - attacker.sendMessage(ChatColor.RED+"**IGNITION**"); - Defender.sendMessage(ChatColor.DARK_RED+"You were struck by a burning arrow!"); - } - } else { - event.getEntity().setFireTicks(160); - attacker.sendMessage(ChatColor.RED+"**IGNITION**"); - } - } if(event.getProjectile().toString().equals("CraftArrow") && mcPermissions.getInstance().archery(attacker)){ if(!mcConfig.getInstance().isTracked(x) && event.getDamage() > 0){ mcConfig.getInstance().addArrowTrack(x, 0); @@ -362,6 +349,19 @@ public class mcCombat { } } } + if(event.getDamage() > 0 && Math.random() * 1500 <= mcUsers.getProfile(attacker).getArcheryInt()){ + if(x instanceof Player){ + Player Defender = (Player)x; + if(!mcParty.getInstance().inSameParty(attacker, Defender)){ + event.getEntity().setFireTicks(120); + attacker.sendMessage(ChatColor.RED+"**IGNITION**"); + Defender.sendMessage(ChatColor.DARK_RED+"You were struck by a burning arrow!"); + } + } else { + event.getEntity().setFireTicks(160); + attacker.sendMessage(ChatColor.RED+"**IGNITION**"); + } + } /* * Defender is Monster */ diff --git a/mcMMO/com/gmail/nossr50/mcExcavation.java b/mcMMO/com/gmail/nossr50/mcExcavation.java index 6163d644e..25863aa20 100644 --- a/mcMMO/com/gmail/nossr50/mcExcavation.java +++ b/mcMMO/com/gmail/nossr50/mcExcavation.java @@ -53,8 +53,17 @@ public class mcExcavation { loc.getWorld().dropItemNaturally(loc, is); } } - if(mcUsers.getProfile(player).getExcavationInt() > 150){ - //CHANCE TO GET MUSIC + if(mcUsers.getProfile(player).getExcavationInt() > 350){ + //CHANCE TO GET DIAMOND + if(mcLoadProperties.diamond == true && Math.random() * 750 > 749){ + 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 YELLOW MUSIC if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){ mcUsers.getProfile(player).addExcavationGather(300); mat = Material.getMaterial(2256); @@ -64,16 +73,7 @@ public class mcExcavation { } 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 + //CHANCE TO GET GREEN MUSIC if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){ mcUsers.getProfile(player).addExcavationGather(300); mat = Material.getMaterial(2257); @@ -136,7 +136,7 @@ public class mcExcavation { } //CHANCE TO GET BONES if(mcLoadProperties.bones == true && mcUsers.getProfile(player).getExcavationInt() > 175){ - if(Math.random() * 10 > 6){ + if(Math.random() * 10 > 9){ mcUsers.getProfile(player).addExcavationGather(3); mat = Material.getMaterial(352); is = new ItemStack(mat, 1, (byte)0, (byte)0); diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 1a06455f5..1c713c7b5 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -32,7 +32,7 @@ public class mcMMO extends JavaPlugin { //herp public void onEnable() { - mcMMO_Timer.schedule(new mcTimer(this), 0, (long)(2000)); + //mcMMO_Timer.schedule(new mcTimer(this), 0, (long)(2000)); //Make the directory if it does not exist new File(maindirectory).mkdir(); //Make the file if it does not exist diff --git a/mcMMO/com/gmail/nossr50/mcMining.java b/mcMMO/com/gmail/nossr50/mcMining.java index 04fe45af0..3784ac009 100644 --- a/mcMMO/com/gmail/nossr50/mcMining.java +++ b/mcMMO/com/gmail/nossr50/mcMining.java @@ -26,7 +26,6 @@ public class mcMining { 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); diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index b588904ef..cc09e62bc 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -69,6 +69,7 @@ public class mcPlayerListener extends PlayerListener { Block block = event.getBlockClicked(); Player player = event.getPlayer(); ItemStack is = player.getItemInHand(); + /* if(mcPermissions.getInstance().woodcuttingability(player) && mcm.getInstance().isAxes(is)){ if(block != null){ if(!mcm.getInstance().abilityBlockCheck(block)) @@ -83,6 +84,7 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."); } } + */ if(mcPermissions.getInstance().herbalism(player)){ //BREADCHECK, CHECKS HERBALISM SKILL FOR BREAD HP MODIFIERS mcHerbalism.getInstance().breadCheck(player, is); diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index 6d4344e5f..0abac32e4 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -13,7 +13,7 @@ import org.bukkit.plugin.Plugin; public class mcUsers { private static volatile mcUsers instance; protected static final Logger log = Logger.getLogger("Minecraft"); - String location = "mcmmo.users"; + String location = "plugins/mcMMO/mcmmo.users"; public static PlayerList players = new PlayerList(); private Properties properties = new Properties(); @@ -161,7 +161,7 @@ class PlayerList Player thisplayer; char defaultColor; - String location = "mcmmo.users"; + String location = "plugins/mcMMO/mcmmo.users"; //===================================================================== diff --git a/mcMMO/com/gmail/nossr50/mcm.java b/mcMMO/com/gmail/nossr50/mcm.java index c69c0db51..0a2c0ada3 100644 --- a/mcMMO/com/gmail/nossr50/mcm.java +++ b/mcMMO/com/gmail/nossr50/mcm.java @@ -224,7 +224,13 @@ public class mcm { return false; } } - + public boolean isMiningPick(ItemStack is){ + if(is.getTypeId() == 270 || is.getTypeId() == 274 || is.getTypeId() == 285 || is.getTypeId() == 257 || is.getTypeId() == 278){ + return true; + } else { + return false; + } + } public void mcmmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ if(split[0].equalsIgnoreCase("/woodcutting")){ event.setCancelled(true); diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index cfbee228a..af1640321 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.9 WIP \ No newline at end of file +version: 0.8.17 \ No newline at end of file