diff --git a/mcMMO/Changelog.txt b/mcMMO/Changelog.txt index f0d5e5f3f..8c09bfabb 100644 --- a/mcMMO/Changelog.txt +++ b/mcMMO/Changelog.txt @@ -1,5 +1,12 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code# +Version 0.9.1 +Fixed "Unknown console command" errors with CB 556 +Added /mcability command to toggle being able to trigger abilities with right click +Added some more nullchecks for people reporting NPE errors +Compatibility with NPC mods improved (Mainly for archery!) +Other plugins can now call inSameParty() from mcMMO to increase compatibility + Version 0.9 --NEW CONTENT-- Woodcutting now has the "Tree Feller" Ability diff --git a/mcMMO/com/gmail/nossr50/mcBlockListener.java b/mcMMO/com/gmail/nossr50/mcBlockListener.java index 531d75d8d..f5a0fd7ed 100644 --- a/mcMMO/com/gmail/nossr50/mcBlockListener.java +++ b/mcMMO/com/gmail/nossr50/mcBlockListener.java @@ -22,7 +22,7 @@ public class mcBlockListener extends BlockListener { public void onBlockPlace(BlockPlaceEvent event) { Block block; Player player = event.getPlayer(); - if (event.getBlockReplacedState().getTypeId() == 78) { + if (event.getBlock() != null && event.getBlockReplacedState() != null && event.getBlockReplacedState().getTypeId() == 78) { block = event.getBlockAgainst(); } else { diff --git a/mcMMO/com/gmail/nossr50/mcCombat.java b/mcMMO/com/gmail/nossr50/mcCombat.java index 37d8c38bb..d4d0b2081 100644 --- a/mcMMO/com/gmail/nossr50/mcCombat.java +++ b/mcMMO/com/gmail/nossr50/mcCombat.java @@ -287,14 +287,16 @@ public class mcCombat { Entity x = event.getEntity(); if(x instanceof Player){ Player defender = (Player)x; + if(mcUsers.getProfile(defender) == null) + mcUsers.addUser(defender); if(mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getTypeId() == 0){ - if(mcUsers.getProfile(defender).getUnarmedInt() >= 1000){ + if(defender != null && mcUsers.getProfile(defender).getUnarmedInt() >= 1000){ if(Math.random() * 1000 <= 500){ event.setCancelled(true); defender.sendMessage(ChatColor.WHITE+"**ARROW DEFLECT**"); return; } - } else if(Math.random() * 1000 <= (mcUsers.getProfile(defender).getUnarmedInt() / 2)){ + } else if(defender != null && Math.random() * 1000 <= (mcUsers.getProfile(defender).getUnarmedInt() / 2)){ event.setCancelled(true); defender.sendMessage(ChatColor.WHITE+"**ARROW DEFLECT**"); return; diff --git a/mcMMO/com/gmail/nossr50/mcLoadProperties.java b/mcMMO/com/gmail/nossr50/mcLoadProperties.java index 816c9d5d2..368e66f77 100644 --- a/mcMMO/com/gmail/nossr50/mcLoadProperties.java +++ b/mcMMO/com/gmail/nossr50/mcLoadProperties.java @@ -2,7 +2,7 @@ package com.gmail.nossr50; public class mcLoadProperties { public static Boolean pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, myspawnclearsinventory, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; - public static String mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; + public static String mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; public static int feathersConsumedByChimaeraWing, pvpxprewardmodifier, repairdiamondlevel, globalxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier; public static void loadMain(){ @@ -57,6 +57,7 @@ public class mcLoadProperties { /* * CUSTOM COMMANDS */ + mcability = properties.getString("/mcability", "mcability"); mcrefresh = properties.getString("/mcrefresh", "mcrefresh"); mcitem = properties.getString("/mcitem", "mcitem"); mcmmo = properties.getString("/mcmmo", "mcmmo"); diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 16adbb9e9..1f7700419 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -102,6 +102,17 @@ public class mcMMO extends JavaPlugin { return false; } } + public boolean inSameParty(Player playera, Player playerb){ + if(mcUsers.getProfile(playera).inParty() && mcUsers.getProfile(playerb).inParty()){ + if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ + return true; + } else { + return false; + } + } else { + return false; + } + } public boolean isAdminChatToggled(Player player){ if(mcConfig.getInstance().isAdminToggled(player.getName())){ return true; diff --git a/mcMMO/com/gmail/nossr50/mcParty.java b/mcMMO/com/gmail/nossr50/mcParty.java index d42a3c179..633cbfa9f 100644 --- a/mcMMO/com/gmail/nossr50/mcParty.java +++ b/mcMMO/com/gmail/nossr50/mcParty.java @@ -16,6 +16,10 @@ public class mcParty { return instance; } public boolean inSameParty(Player playera, Player playerb){ + if(mcUsers.getProfile(playera) == null || mcUsers.getProfile(playerb) == null){ + mcUsers.addUser(playera); + mcUsers.addUser(playerb); + } if(mcUsers.getProfile(playera).inParty() && mcUsers.getProfile(playerb).inParty()){ if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ return true; diff --git a/mcMMO/com/gmail/nossr50/mcPermissions.java b/mcMMO/com/gmail/nossr50/mcPermissions.java index c14eb0d44..95877494a 100644 --- a/mcMMO/com/gmail/nossr50/mcPermissions.java +++ b/mcMMO/com/gmail/nossr50/mcPermissions.java @@ -114,6 +114,13 @@ public class mcPermissions { return true; } } + public boolean mcAbility(Player player) { + if (permissionsEnabled) { + return permission(player, "mcmmo.commands.ability"); + } else { + return true; + } + } public boolean mySpawn(Player player) { if (permissionsEnabled) { return permission(player, "mcmmo.commands.myspawn"); diff --git a/mcMMO/com/gmail/nossr50/mcPlayerListener.java b/mcMMO/com/gmail/nossr50/mcPlayerListener.java index 188d87f69..e6593c9b1 100644 --- a/mcMMO/com/gmail/nossr50/mcPlayerListener.java +++ b/mcMMO/com/gmail/nossr50/mcPlayerListener.java @@ -92,7 +92,17 @@ public class mcPlayerListener extends PlayerListener { String playerName = player.getName(); //Check if the command is an mcMMO related help command mcm.getInstance().mcmmoHelpCheck(split, player, event); - if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcrefresh)){ + if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcability)){ + event.setCancelled(true); + if(mcUsers.getProfile(player).getAbilityUse()){ + player.sendMessage("Ability use toggled off"); + mcUsers.getProfile(player).toggleAbilityUse(); + } else { + player.sendMessage("Ability use toggled on"); + mcUsers.getProfile(player).toggleAbilityUse(); + } + } + if(mcPermissions.getInstance().mcAbility(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcrefresh)){ event.setCancelled(true); if(!mcPermissions.getInstance().mcrefresh(player)){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); @@ -170,6 +180,7 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage(ChatColor.DARK_AQUA+"Myspawn is now cleared."); } if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mmoedit)){ + event.setCancelled(true); if(!mcPermissions.getInstance().mmoedit(player)){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); return; @@ -302,6 +313,7 @@ public class mcPlayerListener extends PlayerListener { * SETMYSPAWN COMMAND */ if(split[0].equalsIgnoreCase("/"+mcLoadProperties.setmyspawn)){ + event.setCancelled(true); if(!mcPermissions.getInstance().setMySpawn(player)){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); return; @@ -310,7 +322,6 @@ public class mcPlayerListener extends PlayerListener { player.sendMessage("You have set "+split[1]+"'s spawn!"); player = getPlayer(split[1]); } - event.setCancelled(true); double x = player.getLocation().getX(); double y = player.getLocation().getY(); double z = player.getLocation().getZ(); @@ -381,6 +392,7 @@ public class mcPlayerListener extends PlayerListener { } //Invite Command if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.invite)){ + event.setCancelled(true); if(!mcUsers.getProfile(player).inParty()){ player.sendMessage(ChatColor.RED+"You are not in a party."); return; @@ -399,6 +411,7 @@ public class mcPlayerListener extends PlayerListener { } //Accept invite if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.accept)){ + event.setCancelled(true); if(mcUsers.getProfile(player).hasPartyInvite()){ if(mcUsers.getProfile(player).inParty()){ mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline()); @@ -412,11 +425,11 @@ public class mcPlayerListener extends PlayerListener { } //Party command if(split[0].equalsIgnoreCase("/"+mcLoadProperties.party)){ + event.setCancelled(true); if(!mcPermissions.getInstance().party(player)){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); return; } - event.setCancelled(true); if(split.length == 1 && !mcUsers.getProfile(player).inParty()){ player.sendMessage("Proper usage is "+"/"+mcLoadProperties.party+" or 'q' to quit"); return; @@ -455,11 +468,11 @@ public class mcPlayerListener extends PlayerListener { } } if(split[0].equalsIgnoreCase("/p")){ + event.setCancelled(true); if(!mcPermissions.getInstance().party(player)){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); return; } - event.setCancelled(true); if(mcConfig.getInstance().isAdminToggled(player.getName())) mcConfig.getInstance().toggleAdminChat(playerName); mcConfig.getInstance().togglePartyChat(playerName); @@ -488,11 +501,11 @@ public class mcPlayerListener extends PlayerListener { * MYSPAWN */ if(split[0].equalsIgnoreCase("/"+mcLoadProperties.myspawn)){ + event.setCancelled(true); if(!mcPermissions.getInstance().mySpawn(player)){ player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions."); return; } - event.setCancelled(true); if(mcUsers.getProfile(player).getMySpawn(player) != null){ if(mcLoadProperties.myspawnclearsinventory) player.getInventory().clear(); diff --git a/mcMMO/com/gmail/nossr50/mcSkills.java b/mcMMO/com/gmail/nossr50/mcSkills.java index 62b4e7c77..f766a6f01 100644 --- a/mcMMO/com/gmail/nossr50/mcSkills.java +++ b/mcMMO/com/gmail/nossr50/mcSkills.java @@ -73,6 +73,8 @@ public class mcSkills { } } public void abilityActivationCheck(Player player, Block block){ + if(!mcUsers.getProfile(player).getAbilityUse()) + return; if(mcPermissions.getInstance().miningAbility(player) && mcm.getInstance().isMiningPick(player.getItemInHand()) && !mcUsers.getProfile(player).getPickaxePreparationMode()){ if(!mcUsers.getProfile(player).getSuperBreakerMode() && mcUsers.getProfile(player).getSuperBreakerCooldown() >= 1){ player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."); diff --git a/mcMMO/com/gmail/nossr50/mcUsers.java b/mcMMO/com/gmail/nossr50/mcUsers.java index 66705ff25..3ac77d131 100644 --- a/mcMMO/com/gmail/nossr50/mcUsers.java +++ b/mcMMO/com/gmail/nossr50/mcUsers.java @@ -156,7 +156,7 @@ class PlayerList protected final Logger log = Logger.getLogger("Minecraft"); private String playerName, gather, wgather, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation, archery, swords, axes, invite, acrobatics, repairgather, unarmedgather, herbalismgather, excavationgather, archerygather, swordsgather, axesgather, acrobaticsgather; - private boolean dead, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode, skullSplitterMode, berserkMode; + private boolean dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode, skullSplitterMode, berserkMode; private int recentlyhurt = 0, bleedticks = 0, gigaDrillBreakerCooldown = 0, gigaDrillBreakerTicks = 0, berserkTicks = 0, berserkCooldown = 0, superBreakerTicks = 0, superBreakerCooldown = 0, serratedStrikesTicks = 0, skullSplitterTicks = 0, skullSplitterCooldown = 0, serratedStrikesCooldown = 0, treeFellerTicks = 0, treeFellerCooldown = 0, axePreparationTicks = 0, pickaxePreparationTicks = 0, fistsPreparationTicks = 0, shovelPreparationTicks = 0, swordsPreparationTicks = 0; @@ -419,6 +419,16 @@ class PlayerList { return player.getName().equals(playerName); } + public boolean getAbilityUse(){ + return abilityuse; + } + public void toggleAbilityUse(){ + if(abilityuse == false){ + abilityuse = true; + } else { + abilityuse = false; + } + } public void decreaseLastHurt(){ if(recentlyhurt >= 1){ recentlyhurt--; diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 5f3c45cf8..1690a418f 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.gmail.nossr50.mcMMO -version: 0.9 \ No newline at end of file +version: 0.9.1 \ No newline at end of file