From f016ce1a9d701c6a64259d1d072a68f852a6c12d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 29 Apr 2011 15:50:55 -0700 Subject: [PATCH] Version 1.0.02 of mcMMO --- mcMMO/Changelog.txt | 18 ++++++++++- mcMMO/com/gmail/nossr50/Combat.java | 10 ++++-- mcMMO/com/gmail/nossr50/Users.java | 7 +++-- .../gmail/nossr50/config/LoadProperties.java | 3 +- .../nossr50/datatypes/PlayerProfile.java | 31 ++++++++++++++----- mcMMO/com/gmail/nossr50/m.java | 4 +-- mcMMO/com/gmail/nossr50/mcMMO.java | 4 +-- mcMMO/com/gmail/nossr50/mcPlayerListener.java | 26 +++++++--------- mcMMO/com/gmail/nossr50/skills/Axes.java | 9 ++++-- mcMMO/com/gmail/nossr50/skills/Herbalism.java | 2 +- mcMMO/com/gmail/nossr50/skills/Swords.java | 9 ++++-- mcMMO/com/gmail/nossr50/skills/Unarmed.java | 6 ++-- mcMMO/plugin.yml | 2 +- 13 files changed, 88 insertions(+), 43 deletions(-) diff --git a/mcMMO/Changelog.txt b/mcMMO/Changelog.txt index 1a584b0e2..566e52cde 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# +#Versions without changelogs probably had very small misc fixes, like tweaks to the source code +Version 1.0.02 +Fixed bug where the Timer would start before everything else was ready +Fixed bug where mcrefresh also required mcability permission node +Fixed bug where Unarmed was not checking for disarm procs +Green Thumb now checks for herbalism permissions +Added "enableGreenThumbCobbleToMossy" to config file, this also changes Green Terra +AoE abilities now harm wolves + +Version 1.0.01 +Removed debug message when wolves are struck +Fixed issue with reloading mcMMO when MySQL was enabled +Fixed a NPE with MySpawn +Fixed a NPE with removing users from PlayerProfile +Unarmed no longer starts with a damage bonus +Unarmed apprentice DMG bonus changed from 3 to 2 + Version 1.0 Players can now repair Stone/Wood tools Fixed duping bug with WG/Block Protection Plugins diff --git a/mcMMO/com/gmail/nossr50/Combat.java b/mcMMO/com/gmail/nossr50/Combat.java index 88ac8b3d2..ed07d7d84 100644 --- a/mcMMO/com/gmail/nossr50/Combat.java +++ b/mcMMO/com/gmail/nossr50/Combat.java @@ -63,6 +63,11 @@ public class Combat { Axes.axeCriticalCheck(attacker, eventb); //Axe Criticals if(!Config.getInstance().isBleedTracked(event.getEntity())) //Swords Bleed Swords.bleedCheck(attacker, event.getEntity()); + if(event.getEntity() instanceof Player){ + Player defender = (Player)event.getEntity(); + Unarmed.disarmProcCheck(attacker, defender); + } + //Modify the event damage if Attacker is Berserk if(PPa.getBerserkMode()) @@ -70,9 +75,9 @@ public class Combat { //Handle Ability Interactions if(PPa.getSkullSplitterMode() && m.isAxes(attacker.getItemInHand())) - Axes.applyAoeDamage(attacker, eventb); + Axes.applyAoeDamage(attacker, eventb, pluginx); if(PPa.getSerratedStrikesMode() && m.isSwords(attacker.getItemInHand())) - Swords.applySerratedStrikes(attacker, eventb); + Swords.applySerratedStrikes(attacker, eventb, pluginx); //Experience if(event.getEntity() instanceof Player) @@ -208,7 +213,6 @@ public class Combat { //Thick Fur if(PPo.getTamingInt() >= 250) event.setDamage(event.getDamage() / 2); - master.sendMessage("mcMMO Debug: Wolf Damage Taken "+event.getDamage()); } } } diff --git a/mcMMO/com/gmail/nossr50/Users.java b/mcMMO/com/gmail/nossr50/Users.java index f80b85636..724802308 100644 --- a/mcMMO/com/gmail/nossr50/Users.java +++ b/mcMMO/com/gmail/nossr50/Users.java @@ -77,8 +77,11 @@ public class Users { public static void removeUser(Player player){ PlayerProfile PP = Users.getProfile(player); - PP.save(); - players.remove(player); + if(PP != null){ + PP.save(); + if(players.containsKey(player)) + players.remove(player); + } } public static PlayerProfile getProfile(Player player){ diff --git a/mcMMO/com/gmail/nossr50/config/LoadProperties.java b/mcMMO/com/gmail/nossr50/config/LoadProperties.java index 0249f8d7d..d858176f0 100644 --- a/mcMMO/com/gmail/nossr50/config/LoadProperties.java +++ b/mcMMO/com/gmail/nossr50/config/LoadProperties.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.config; import com.gmail.nossr50.mcMMO; public class LoadProperties { - public static Boolean useMySQL, cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, myspawnclearsinventory, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; + public static Boolean enableCobbleToMossy, useMySQL, cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, myspawnclearsinventory, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; public static String MySQLtablePrefix, MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; public static int MySQLport, xpGainMultiplier, superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, serratedStrikeCooldown, skullSplitterCooldown, abilityDurabilityLoss, feathersConsumedByChimaeraWing, pvpxprewardmodifier, repairdiamondlevel, globalxpmodifier, tamingxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier; @@ -39,6 +39,7 @@ public class LoadProperties { * OTHER */ + enableCobbleToMossy = properties.getBoolean("enableGreenThumbCobbleToMossy", true); archeryFireRateLimit = properties.getBoolean("archeryFireRateLimit", true); xpGainMultiplier = properties.getInteger("xpGainMultiplier", 1); toolsLoseDurabilityFromAbilities = properties.getBoolean("toolsLoseDurabilityFromAbilities", true); diff --git a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java index 54ab379e9..b54febc85 100644 --- a/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/mcMMO/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -1655,19 +1655,31 @@ public class PlayerProfile save(); } public String getX(){ + if(myspawn != null) + { String[] split = myspawn.split(","); - String x = split[0]; - return x; + return split[0]; + } + else + return null; } public String getY(){ + if(myspawn != null) + { String[] split = myspawn.split(","); - String y = split[1]; - return y; + return split[1]; + } + else + return null; } public String getZ(){ + if(myspawn != null) + { String[] split = myspawn.split(","); - String z = split[2]; - return z; + return split[2]; + } + else + return null; } public void setDead(boolean x){ dead = x; @@ -1678,10 +1690,13 @@ public class PlayerProfile } public Location getMySpawn(Player player){ Location loc = null; - if(isDouble(getX()) && isDouble(getY()) && isDouble(getZ())) - loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ())); + if(myspawn != null){ + if(isDouble(getX()) && isDouble(getY()) && isDouble(getZ())) + loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ())); else return null; + } else + return null; loc.setYaw(0); loc.setPitch(0); diff --git a/mcMMO/com/gmail/nossr50/m.java b/mcMMO/com/gmail/nossr50/m.java index 8cbe842ce..624194fc0 100644 --- a/mcMMO/com/gmail/nossr50/m.java +++ b/mcMMO/com/gmail/nossr50/m.java @@ -797,10 +797,10 @@ public class m { if(PP.getUnarmedInt() < 250){ player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 250+ SKILL (UNARMED APPRENTICE)"); } else if(PP.getUnarmedInt() >= 250 && PP.getUnarmedInt() < 500){ - player.sendMessage(ChatColor.RED+"Unarmed Apprentice: "+ChatColor.YELLOW+"Damage Upgrade"); + player.sendMessage(ChatColor.RED+"Unarmed Apprentice: "+ChatColor.YELLOW+"+2 DMG Upgrade"); player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 500+ SKILL (UNARMED MASTERY)"); } else { - player.sendMessage(ChatColor.RED+"Unarmed Mastery: "+ChatColor.YELLOW+"Large Damage Upgrade"); + player.sendMessage(ChatColor.RED+"Unarmed Mastery: "+ChatColor.YELLOW+"+4 DMG Upgrade"); } player.sendMessage(ChatColor.RED+"Berserk Length: "+ChatColor.YELLOW+ticks+"s"); } diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index ca79efc78..b62de9d2d 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -51,12 +51,10 @@ public class mcMMO extends JavaPlugin { public static Database database = null; public void onEnable() { - mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000)); new File(maindirectory).mkdir(); mcProperties.makeProperties(Properties, log); //Make Props file LoadProperties.loadMain(); //Load Props file Users.getInstance().loadUsers(); //Load Users file - for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile /* * REGISTER EVENTS */ @@ -83,7 +81,9 @@ public class mcMMO extends JavaPlugin { database.createStructure(); //Make Structure if(!LoadProperties.useMySQL) Leaderboard.makeLeaderboards(); //Make the leaderboards + for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); + mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000)); } private void mcLoadMySQL() { diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index 04a5e8fb3..87af0d19e 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -136,9 +136,9 @@ public class mcPlayerListener extends PlayerListener { //GREEN THUMB if(block != null && (block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT) && player.getItemInHand().getType() == Material.SEEDS){ boolean pass = false; - if(Herbalism.hasSeeds(player)){ + if(Herbalism.hasSeeds(player) && mcPermissions.getInstance().herbalism(player)){ Herbalism.removeSeeds(player); - if(block.getType() == Material.COBBLESTONE && Math.random() * 1500 <= PP.getHerbalismInt()){ + if(LoadProperties.enableCobbleToMossy && block.getType() == Material.COBBLESTONE && Math.random() * 1500 <= PP.getHerbalismInt()){ player.sendMessage(ChatColor.GREEN+"**GREEN THUMB**"); block.setType(Material.MOSSY_COBBLESTONE); pass = true; @@ -193,21 +193,17 @@ public class mcPlayerListener extends PlayerListener { PP.toggleAbilityUse(); } } - if(split[0].equalsIgnoreCase("/details")){ - event.setCancelled(true); - player.getLocation().getWorld().spawnCreature(player.getLocation(), CreatureType.WOLF); - player.getLocation().getWorld().spawnCreature(player.getLocation(), CreatureType.WOLF); - player.sendMessage("Material : "+player.getItemInHand().getType()); - player.sendMessage("Type ID : "+player.getItemInHand().getTypeId()); - player.sendMessage("Byte Data : "+player.getItemInHand().getDurability()); - } /* * FFS -> MySQL */ - if(split[0].equalsIgnoreCase("/mmoupdate") && mcPermissions.getInstance().admin(player)) + if(split[0].equalsIgnoreCase("/mmoupdate")) { event.setCancelled(true); + if(!mcPermissions.getInstance().admin(player)){ + player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions."); + return; + } player.sendMessage(ChatColor.GRAY+"Starting conversion..."); Users.clearUsers(); m.convertToMySQL(plugin); @@ -230,7 +226,7 @@ public class mcPlayerListener extends PlayerListener { if(split.length == 1){ int p = 1; String[] info = Leaderboard.retrieveInfo("powerlevel", p); - player.sendMessage(ChatColor.YELLOW+"--MMO"+ChatColor.BLUE+" Power Level "+ChatColor.YELLOW+"Leaderboard--"); + player.sendMessage(ChatColor.YELLOW+"--mcMMO"+ChatColor.BLUE+" Power Level "+ChatColor.YELLOW+"Leaderboard--"); int n = 1 * p; //Position for(String x : info){ if(x != null){ @@ -259,7 +255,7 @@ public class mcPlayerListener extends PlayerListener { pt = 10; } String[] info = Leaderboard.retrieveInfo("powerlevel", p); - player.sendMessage("--MMO Power Level Leaderboard--"); + player.sendMessage("--mcMMO Power Level Leaderboard--"); int n = 1 * pt; //Position for(String x : info){ if(x != null){ @@ -295,7 +291,7 @@ public class mcPlayerListener extends PlayerListener { String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase(); String[] info = Leaderboard.retrieveInfo(split[1].toLowerCase(), p); - player.sendMessage(ChatColor.YELLOW+"--MMO "+ChatColor.BLUE+capitalized+ChatColor.YELLOW+" Leaderboard--"); + player.sendMessage(ChatColor.YELLOW+"--mcMMO "+ChatColor.BLUE+capitalized+ChatColor.YELLOW+" Leaderboard--"); int n = 1 * pt; //Position for(String x : info){ if(x != null){ @@ -400,7 +396,7 @@ public class mcPlayerListener extends PlayerListener { } } - if(mcPermissions.getInstance().mcAbility(player) && split[0].equalsIgnoreCase("/"+LoadProperties.mcrefresh)){ + if(split[0].equalsIgnoreCase("/"+LoadProperties.mcrefresh)){ event.setCancelled(true); if(!mcPermissions.getInstance().mcrefresh(player)){ player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions."); diff --git a/mcMMO/com/gmail/nossr50/skills/Axes.java b/mcMMO/com/gmail/nossr50/skills/Axes.java index 485c4f4eb..bf2584f04 100644 --- a/mcMMO/com/gmail/nossr50/skills/Axes.java +++ b/mcMMO/com/gmail/nossr50/skills/Axes.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.plugin.Plugin; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; @@ -48,7 +49,7 @@ public class Axes { } } - public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event){ + public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx){ int targets = 0; Entity x = event.getEntity(); targets = m.getTier(attacker); @@ -70,7 +71,11 @@ public class Axes { targets--; } if(derp instanceof Wolf){ - continue; + Wolf hurrDurr = (Wolf)derp; + if(Taming.getOwner(hurrDurr, pluginx) == attacker) + continue; + if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx))) + continue; } if(derp instanceof Animals && targets >= 1){ Animals target = (Animals)derp; diff --git a/mcMMO/com/gmail/nossr50/skills/Herbalism.java b/mcMMO/com/gmail/nossr50/skills/Herbalism.java index e518241b7..4259c7d2c 100644 --- a/mcMMO/com/gmail/nossr50/skills/Herbalism.java +++ b/mcMMO/com/gmail/nossr50/skills/Herbalism.java @@ -46,7 +46,7 @@ public class Herbalism { removeSeeds(player); if(block.getType() == Material.DIRT) block.setType(Material.GRASS); - if(block.getType() == Material.COBBLESTONE) + if(LoadProperties.enableCobbleToMossy && block.getType() == Material.COBBLESTONE) block.setType(Material.MOSSY_COBBLESTONE); } } diff --git a/mcMMO/com/gmail/nossr50/skills/Swords.java b/mcMMO/com/gmail/nossr50/skills/Swords.java index 64bf37431..e9d085be1 100644 --- a/mcMMO/com/gmail/nossr50/skills/Swords.java +++ b/mcMMO/com/gmail/nossr50/skills/Swords.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Wolf; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.plugin.Plugin; import com.gmail.nossr50.Combat; import com.gmail.nossr50.Users; @@ -45,7 +46,7 @@ public class Swords { } } } - public static void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event){ + public static void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx){ int targets = 0; Entity x = event.getEntity(); targets = m.getTier(attacker); @@ -70,7 +71,11 @@ public class Swords { targets--; } if(derp instanceof Wolf){ - continue; + Wolf hurrDurr = (Wolf)derp; + if(Taming.getOwner(hurrDurr, pluginx) == attacker) + continue; + if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx))) + continue; } if(derp instanceof Animals && targets >= 1){ if(!Config.getInstance().isBleedTracked(derp)) diff --git a/mcMMO/com/gmail/nossr50/skills/Unarmed.java b/mcMMO/com/gmail/nossr50/skills/Unarmed.java index 9ee2e772a..6fe8a481a 100644 --- a/mcMMO/com/gmail/nossr50/skills/Unarmed.java +++ b/mcMMO/com/gmail/nossr50/skills/Unarmed.java @@ -13,11 +13,11 @@ public class Unarmed { public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event) { PlayerProfile PPa = Users.getProfile(attacker); - int bonus = 2; + int bonus = 0; if (PPa.getUnarmedInt() >= 250) - bonus++; + bonus+=2; if (PPa.getUnarmedInt() >= 500) - bonus++; + bonus+=2; event.setDamage(event.getDamage()+bonus); } public static void disarmProcCheck(Player attacker, Player defender) diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index eaba66eae..1d429b8cd 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 1.0 \ No newline at end of file +version: 1.0.02 \ No newline at end of file