diff --git a/mcMMO/Changelog.txt b/mcMMO/Changelog.txt index eff603633..0e66ae0cd 100644 --- a/mcMMO/Changelog.txt +++ b/mcMMO/Changelog.txt @@ -1,5 +1,21 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code# +Version 0.5.15 + Fixed stone swords not being recognized as swords + Fixed /a not working if you were an op but did not have permissions + +Version 0.5.14 + Added permissions for skills + +Version 0.5.13 + + Removed skillgain from succesful parries + Repair now refreshed the inventory + +Version 0.5.12 + + Fixed being able to hurt party members with the bow and arrow + Version 0.5.11 Added /mmoedit command diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java index a90318ec6..20a4dbadc 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java @@ -20,7 +20,12 @@ public class mcBlockListener extends BlockListener { } public void onBlockPlace(BlockPlaceEvent event) { Block block = event.getBlock(); + int x = block.getX(); + int y = block.getY(); + int z = block.getZ(); + String xyz = x+","+y+","+z; mcConfig.getInstance().addBlockWatch(block); + mcConfig.getInstance().addCoordsWatch(xyz); if(block.getTypeId() == 42) event.getPlayer().sendMessage(ChatColor.DARK_RED+"You have placed an anvil, anvils can repair tools and armor."); } @@ -29,24 +34,45 @@ public class mcBlockListener extends BlockListener { //STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2); Player player = event.getPlayer(); Block block = event.getBlock(); + int x = block.getX(); + 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(); - //Smooth Stone - if(dmg == 3 && !mcConfig.getInstance().isBlockWatched(block)){ + /* + * MINING + */ + if(dmg == 3 && !mcConfig.getInstance().isBlockWatched(block) && !mcConfig.getInstance().isCoordsWatched(xyz)){ + if(mcPermissions.getInstance().mining(player)) mcm.getInstance().miningBlockCheck(player, block); - //Give skill for woodcutting - if(block.getTypeId() == 17) - mcUsers.getProfile(player).addwgather(1); - //Skill up players based on gather/wgather stuff - mcm.getInstance().simulateSkillUp(player); - if(block.getTypeId() == 17){ + /* + * WOOD CUTTING + */ + if(block.getTypeId() == 17 + && mcPermissions.getInstance().woodcutting(player)){ + mcUsers.getProfile(player).addwgather(1); mcm.getInstance().woodCuttingProcCheck(player, block, loc); } + mcm.getInstance().simulateSkillUp(player); + /* + * EXCAVATION + */ + if(mcPermissions.getInstance().excavation(player)) mcm.getInstance().excavationProcCheck(block, player); - } - if(mcConfig.getInstance().isBlockWatched(block) && !(type == 39 || type == 40 || type == 37 || type == 38)); + /* + * HERBALISM + */ + if(!(type == 39 || type == 40 || type == 37 || type == 38) + && mcPermissions.getInstance().herbalism(player)); mcm.getInstance().herbalismProcCheck(block, player); //You place the blocks so we wont check if they are being watched + /* + * EXPLOIT COUNTERMEASURES + */ + mcConfig.getInstance().addCoordsWatch(xyz); + mcConfig.getInstance().addBlockWatch(block); + } } diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java index 81e076581..cd59ce170 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java @@ -13,11 +13,15 @@ public class mcConfig { 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(); 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 boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);} public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);} public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));} diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java index f844e535f..d599b53b1 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java @@ -110,6 +110,7 @@ public class mcEntityListener extends EntityListener { */ if(y instanceof Player){ Player attacker = (Player)y; + if(mcPermissions.getInstance().archery(attacker)){ /* * Defender is Monster */ @@ -177,6 +178,12 @@ public class mcEntityListener extends EntityListener { /* * 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); @@ -214,9 +221,9 @@ public class mcEntityListener extends EntityListener { if(mcUsers.getProfile(defender).isDead()) return; if(defender.getHealth() <= 0){ + mcUsers.getProfile(defender).setDead(true); for(Player derp : plugin.getServer().getOnlinePlayers()){ derp.sendMessage(ChatColor.GRAY+attacker.getName() + " has " +ChatColor.DARK_RED+"slain "+ChatColor.GRAY+defender.getName() + " with an arrow."); - mcUsers.getProfile(defender).setDead(true); } } } @@ -231,7 +238,7 @@ public class mcEntityListener extends EntityListener { } } } - + } } public void onEntityDamage(EntityDamageEvent event) { Entity x = event.getEntity(); @@ -243,42 +250,52 @@ public class mcEntityListener extends EntityListener { int y = loc.getBlockY(); int z = loc.getBlockZ(); if(type == DamageCause.FALL){ - if(mcUsers.getProfile(player).getAcrobaticsInt() >= 50 && mcUsers.getProfile(player).getAcrobaticsInt() < 250 ){ + 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 ){ + 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 ){ + 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 ){ + 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){ + 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))){ + if(!mcConfig.getInstance().isBlockWatched(loc.getWorld().getBlockAt(xx, y, z)) + && mcPermissions.getInstance().acrobatics(player)){ if(event.getDamage() >= 2 && event.getDamage() < 6){ mcUsers.getProfile(player).skillUpAcrobatics(1); player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by 1. Total ("+mcUsers.getProfile(player).getAcrobatics()+")"); diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcPermissions.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcPermissions.java index 2f85da3f7..ec36f619a 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcPermissions.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcPermissions.java @@ -98,4 +98,67 @@ public class mcPermissions { } return instance; } + public boolean mining(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.mining"); + } else { + return true; + } + } + public boolean woodcutting(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.woodcutting"); + } else { + return true; + } + } + public boolean repair(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.repair"); + } else { + return true; + } + } + public boolean unarmed(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.unarmed"); + } else { + return true; + } + } + public boolean archery(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.archery"); + } else { + return true; + } + } + public boolean herbalism(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.herbalism"); + } else { + return true; + } + } + public boolean excavation(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.excavation"); + } else { + return true; + } + } + public boolean swords(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.swords"); + } else { + return true; + } + } + public boolean acrobatics(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.skills.acrobatics"); + } else { + return true; + } + } } diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java index b1c48b9a8..47f6d7cbc 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java @@ -90,12 +90,16 @@ public class mcPlayerListener extends PlayerListener { Block block = event.getBlockClicked(); Player player = event.getPlayer(); ItemStack is = player.getItemInHand(); + if(mcPermissions.getInstance().herbalism(player)){ //BREADCHECK, CHECKS HERBALISM SKILL FOR BREAD HP MODIFIERS mcm.getInstance().breadCheck(player, is); //STEW, CHECKS HERBALISM SKILL FOR BREAD HP MODIFIERS mcm.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); + } } public void onPlayerCommand(PlayerChatEvent event) { @@ -277,7 +281,7 @@ public class mcPlayerListener extends PlayerListener { } } if(split[0].equalsIgnoreCase("/a") && (player.isOp() || mcPermissions.getInstance().adminChat(player))){ - if(!mcPermissions.getInstance().adminChat(player)){ + if(!mcPermissions.getInstance().adminChat(player) && !player.isOp()){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); return; } @@ -327,7 +331,8 @@ public class mcPlayerListener extends PlayerListener { } return; } - if((player.isOp() || mcPermissions.getInstance().adminChat(player)) && mcConfig.getInstance().isAdminToggled(player.getName())){ + if((player.isOp() || mcPermissions.getInstance().adminChat(player)) + && mcConfig.getInstance().isAdminToggled(player.getName())){ log.log(Level.INFO, "[A]"+"<"+player.getName()+"> "+event.getMessage()); event.setCancelled(true); for(Player herp : plugin.getServer().getOnlinePlayers()){ diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java index 96aba939b..2a8a0658f 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java @@ -421,7 +421,7 @@ public class mcm { 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() == 271 || is.getTypeId() == 283 || is.getTypeId() == 276){ + if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276){ return true; } else { return false; @@ -525,7 +525,7 @@ public class mcm { public void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ if(x instanceof Squid){ Squid defender = (Squid)event.getEntity(); - if(isSwords(attacker.getItemInHand()) && defender.getHealth() > 0){ + if(isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){ if(Math.random() * 10 > 9){ mcUsers.getProfile(attacker).skillUpSwords(1); attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(attacker).getSwords()+")"); @@ -534,7 +534,7 @@ public class mcm { /* * UNARMED VS SQUID */ - if(type == 0){ + if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ if(defender.getHealth() <= 0) return; if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ @@ -568,7 +568,7 @@ public class mcm { } public void playerVersusAnimalsChecks(Entity x, Player attacker, EntityDamageByEntityEvent event, int type){ if(x instanceof Animals){ - if(type == 0){ + if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ Animals defender = (Animals)event.getEntity(); if(defender.getHealth() <= 0) return; @@ -631,13 +631,15 @@ public class mcm { public void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker, Entity x, int type){ if(x instanceof Monster){ Monster defender = (Monster)event.getEntity(); - if(isSwords(attacker.getItemInHand()) && defender.getHealth() > 0){ + if(isSwords(attacker.getItemInHand()) + && defender.getHealth() > 0 + && mcPermissions.getInstance().swords(attacker)){ if(Math.random() * 10 > 9){ mcUsers.getProfile(attacker).skillUpSwords(1); attacker.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(attacker).getSwords()+")"); } } - if(type == 0){ + if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){ if(defender.getHealth() <= 0) return; if(mcUsers.getProfile(attacker).getUnarmedInt() >= 50 && mcUsers.getProfile(attacker).getUnarmedInt() < 100){ @@ -724,14 +726,14 @@ public class mcm { } } public void parryCheck(Player defender, EntityDamageByEntityEvent event, Entity y){ - if(isSwords(defender.getItemInHand())){ + 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() * 10 > 8){ + if(Math.random() * 100 > 95){ event.setCancelled(true); defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - mcUsers.getProfile(defender).skillUpSwords(1); - defender.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(defender).getSwords()+")"); if(y instanceof Player){ Player attacker = (Player)y; attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); @@ -740,12 +742,10 @@ public class mcm { } } if(mcUsers.getProfile(defender).getSwordsInt() >= 250 && mcUsers.getProfile(defender).getSwordsInt() < 450){ - if(Math.random() * 10 > 6){ + if(Math.random() * 100 > 90){ event.setCancelled(true); defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - mcUsers.getProfile(defender).skillUpSwords(1); - defender.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(defender).getSwords()+")"); if(y instanceof Player){ Player attacker = (Player)y; attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); @@ -754,12 +754,10 @@ public class mcm { } } if(mcUsers.getProfile(defender).getSwordsInt() >= 450 && mcUsers.getProfile(defender).getSwordsInt() < 775){ - if(Math.random() * 10 > 5){ + if(Math.random() * 100 > 85){ event.setCancelled(true); defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); - mcUsers.getProfile(defender).skillUpSwords(1); - defender.sendMessage(ChatColor.YELLOW+"Swords skill increased by 1. Total ("+mcUsers.getProfile(defender).getSwords()+")"); if(y instanceof Player){ Player attacker = (Player)y; attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**"); @@ -768,7 +766,7 @@ public class mcm { } } if(mcUsers.getProfile(defender).getSwordsInt() >= 775){ - if(Math.random() * 10 > 4){ + if(Math.random() * 100 > 80){ event.setCancelled(true); defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*"); defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1)); @@ -913,7 +911,9 @@ public class mcm { } } public void repairCheck(Player player, ItemStack is, Block block){ - if(block != null && block.getTypeId() == 42){ + if(block != null + && block.getTypeId() == 42 + && mcPermissions.getInstance().repair(player)){ short durability = is.getDurability(); if(player.getItemInHand().getDurability() > 0){ /* @@ -956,6 +956,7 @@ public class mcm { } else { player.sendMessage("That is at full durability."); } + player.updateInventory(); } //end if block is iron block bracket } public void herbalismProcCheck(Block block, Player player){ diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index f03e637b2..e01966378 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.bukkit.nossr50.mcMMO.mcMMO -version: 0.5.11 \ No newline at end of file +version: 0.5.15 \ No newline at end of file