mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Cleanup, changed order of some logic checks.
This commit is contained in:
parent
ad68e6057e
commit
16ad8502d2
@ -188,15 +188,15 @@ public class PlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
ItemStack is = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
Material mat;
|
Material material;
|
||||||
|
|
||||||
/* Fix for NPE on interacting with air */
|
/* Fix for NPE on interacting with air */
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
mat = Material.AIR;
|
material = Material.AIR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mat = block.getType();
|
material = block.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -204,18 +204,18 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
||||||
if (ItemChecks.isTool(is) || ItemChecks.isArmor(is)) {
|
if (ItemChecks.isTool(inHand) || ItemChecks.isArmor(inHand)) {
|
||||||
Repair.repairCheck(player, is);
|
Repair.repairCheck(player, inHand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
else if (ModChecks.isCustomTool(is) && ModChecks.getToolFromItemStack(is).isRepairable()) {
|
else if (ModChecks.isCustomTool(inHand) && ModChecks.getToolFromItemStack(inHand).isRepairable()) {
|
||||||
Repair.repairCheck(player, is);
|
Repair.repairCheck(player, inHand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
else if (ModChecks.isCustomArmor(is) && ModChecks.getArmorFromItemStack(is).isRepairable()) {
|
else if (ModChecks.isCustomArmor(inHand) && ModChecks.getArmorFromItemStack(inHand).isRepairable()) {
|
||||||
Repair.repairCheck(player, is);
|
Repair.repairCheck(player, inHand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* ACTIVATION CHECKS */
|
/* ACTIVATION CHECKS */
|
||||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
||||||
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
|
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
|
||||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,8 +236,8 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GREEN THUMB CHECK */
|
/* GREEN THUMB CHECK */
|
||||||
if (Permissions.getInstance().greenThumbBlocks(player) && BlockChecks.makeMossy(block) && is.getType().equals(Material.SEEDS)) {
|
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.getInstance().greenThumbBlocks(player)) {
|
||||||
Herbalism.greenThumbBlocks(is, player, block);
|
Herbalism.greenThumbBlocks(inHand, player, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ITEM CHECKS */
|
/* ITEM CHECKS */
|
||||||
@ -246,7 +246,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
|
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||||
BlastMining.detonate(event, player, plugin);
|
BlastMining.detonate(event, player, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public class PlayerListener implements Listener {
|
|||||||
Item.itemChecks(player);
|
Item.itemChecks(player);
|
||||||
|
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
|
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||||
BlastMining.detonate(event, player, plugin);
|
BlastMining.detonate(event, player, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,10 +280,10 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* CALL OF THE WILD CHECKS */
|
/* CALL OF THE WILD CHECKS */
|
||||||
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
|
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
|
||||||
if (is.getType().equals(Material.RAW_FISH)) {
|
if (inHand.getType().equals(Material.RAW_FISH)) {
|
||||||
Taming.animalSummon(EntityType.OCELOT, player, plugin);
|
Taming.animalSummon(EntityType.OCELOT, player, plugin);
|
||||||
}
|
}
|
||||||
else if (is.getType().equals(Material.BONE)) {
|
else if (inHand.getType().equals(Material.BONE)) {
|
||||||
Taming.animalSummon(EntityType.WOLF, player, plugin);
|
Taming.animalSummon(EntityType.WOLF, player, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,14 +365,15 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
String command = message.substring(1).split(" ")[0];
|
String command = message.substring(1).split(" ")[0];
|
||||||
|
String lowerCaseCommand = command.toLowerCase();
|
||||||
|
|
||||||
if (plugin.aliasMap.containsKey(command.toLowerCase())) {
|
if (plugin.aliasMap.containsKey(lowerCaseCommand)) {
|
||||||
//We should find a better way to avoid string replacement where the alias is equals to the command
|
//We should find a better way to avoid string replacement where the alias is equals to the command
|
||||||
if (command.equals(plugin.aliasMap.get(command.toLowerCase()))) {
|
if (command.equals(plugin.aliasMap.get(lowerCaseCommand))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setMessage(message.replace(command, plugin.aliasMap.get(command.toLowerCase())));
|
event.setMessage(message.replace(command, plugin.aliasMap.get(lowerCaseCommand)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Wolf;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
Loading…
Reference in New Issue
Block a user