From d84d487435f8b37acfba5944686de5c9d413f9b9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 26 Jan 2019 08:14:06 -0800 Subject: [PATCH] Debug stick tells you about placestore & treasure data when hitting blocks --- .../nossr50/commands/skills/SkillCommand.java | 9 +++--- .../gmail/nossr50/config/AdvancedConfig.java | 6 ++++ .../nossr50/listeners/BlockListener.java | 19 +++++++++--- .../skills/excavation/ExcavationManager.java | 31 +++++++++++++++++++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 413b4d22f..4dc1a67ea 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -66,10 +66,11 @@ public abstract class SkillCommand implements TabExecutor { float skillValue = mcMMOPlayer.getSkillLevel(skill); //Send the players a few blank lines to make finding the top of the skill command easier - for(int i = 0; i < 2; i++) - { - player.sendMessage(""); - } + if(AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) + for(int i = 0; i < 2; i++) + { + player.sendMessage(""); + } permissionsCheck(player); dataCalculations(player, skillValue); diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 0b4e8281a..52ef49c9b 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -737,6 +737,12 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { } /* Notification Settings */ + + public boolean doesSkillCommandSendBlankLines() + { + return config.getBoolean("Feedback.SkillCommand.BlankLinesAboveHeader", true); + } + public boolean doesNotificationUseActionBar(NotificationType notificationType) { return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".Enabled", true); diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 8c7ffb784..30ad45d88 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.config.WorldBlacklist; +import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; @@ -394,6 +395,20 @@ public class BlockListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockDamage(BlockDamageEvent event) { + Player player = event.getPlayer(); + BlockState blockState = event.getBlock().getState(); + + if(player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) + { + if(mcMMO.getPlaceStore().isTrue(blockState)) + player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP"); + else + { + player.sendMessage("[mcMMO DEBUG] This block is natural"); + UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState); + } + } + /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) return; @@ -408,15 +423,11 @@ public class BlockListener implements Listener { if (event instanceof FakeBlockDamageEvent) { return; } - - Player player = event.getPlayer(); - if (!UserManager.hasPlayerDataKey(player)) { return; } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - BlockState blockState = event.getBlock().getState(); /* * ABILITY PREPARATION CHECKS diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index 56b1bc6c2..77cfca207 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -11,8 +11,12 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.SkillUtils; +import com.gmail.nossr50.worldguard.WorldGuardManager; +import com.gmail.nossr50.worldguard.WorldGuardUtils; +import org.apache.commons.lang.math.RandomUtils; import org.bukkit.Location; import org.bukkit.block.BlockState; +import org.bukkit.entity.Player; import java.util.List; @@ -49,6 +53,33 @@ public class ExcavationManager extends SkillManager { applyXpGain(xp, XPGainReason.PVE); } + public void printExcavationDebug(Player player, BlockState blockState) + { + if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) { + List treasures = Excavation.getTreasures(blockState); + + if (!treasures.isEmpty()) { + for (ExcavationTreasure treasure : treasures) { + player.sendMessage("|||||||||||||||||||||||||||||||||"); + player.sendMessage("[mcMMO DEBUG] Treasure found: ("+treasure.getDrop().getType().toString()+")"); + player.sendMessage("[mcMMO DEBUG] Drop Chance for Treasure: "+treasure.getDropChance()); + player.sendMessage("[mcMMO DEBUG] Skill Level Required: "+treasure.getDropLevel()); + player.sendMessage("[mcMMO DEBUG] XP for Treasure: "+treasure.getXp()); + + if(WorldGuardUtils.isWorldGuardLoaded()) + { + if(WorldGuardManager.getInstance().hasMainFlag(player)) + player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player"); + else + player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player"); + } + } + } else { + player.sendMessage("[mcMMO DEBUG] No treasures found for this block."); + } + } + } + /** * Process the Giga Drill Breaker ability. *